iT邦幫忙

1

Telegram Bot問題 webhook 和直接寫的分别?

Telegram Bot問題 webhook 和直接寫的分别?
哪個好 ?

現在我是

def on_chat_message(msg):
    content_type, chat_type, chat_id = telepot.glance(msg)
    if msg['text'] == '/start':
        mark_up = ReplyKeyboardMarkup(keyboard=[['Hello'], ['test1'], ['test2']], one_time_keyboard=True)
        bot.sendMessage(chat_id, text='Pleasae Select the demo?', reply_markup=mark_up)

    elif msg['text'] == 'Hello':
        bot.sendMessage(chat_id, 'Hello!')
        ...

解決 JS VS PYTHON

dragonH iT邦超人 5 級 ‧ 2020-03-05 17:42:17 檢舉
Telegram 取得訊息的方式有兩種

Long Polling => 我們的程式不停發請求給 Telegram 取得新訊息
Webhook => 有新訊息時 Telegram 自己傳訊息到我們的程式

使用上
正式端我會使用 Webhook
測試使用 Long Polling

不過這是我的習慣,僅供參考
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

1 個回答

0
echochio
iT邦高手 1 級 ‧ 2020-03-06 20:52:44

我有上線 Telegram Bot
當初急用上線 Polling 方式 發現 python 三不五時當掉, Telegram Bot 沒反應
後來改成 Webhook
架構是 :

Telegram Bot => google apps script => uwsgi => python django

注意的是 google apps script 每天有次數限制的 好像一天 2000 次吧
對我來講夠用
我的需求是 user 在群內發 /check XXX
後端會將 XXX 做檢查將結果在 Telegram 顯示

我要發表回答

立即登入回答