7

我将setWebhook用于我的电报机器人,现在我需要使用getUpdates。我已经阅读了文档,他们说我只能使用一种方法。

问题是,我在控制台中有:

{"ok":false,"error_code":409,"description":"Error: Conflict: another webhook is active"}

所以问题是,如何取消设置webhook并使用getUpdates

4

4 回答 4

12

在浏览器中发送以下请求:

https://api.telegram.org/bot655390656:bhFS50...ff3zO4/setwebhook
于 2016-07-02T01:41:16.790 回答
11

如 Telegram bot api 文档中所述,您只需将空字符串传递给url参数。

> base_url = 'https://api.telegram.org/bot' + TOKEN + '/'
> data = {"url": ""}
> requests.post(base_url + 'setWebhook', data=data)
于 2015-09-12T09:27:56.473 回答
0

你可以调用该方法

deleteWebhook()

https://core.telegram.org/bots/api#deletewebhook

例如使用 Telepot

import telepot
bot = telepot.Bot('YOUR_AUTHORIZATION_TOKEN')
bot.deleteWebhook()
于 2017-07-05T00:23:35.187 回答
0

我为这项工作写了一个小耙子任务

require 'net/https'

namespace :telegram_custom do
  desc "Deactives webhook - this is needed to enable polling in development"
  task deactivate_webhook: :environment do
    token = "YOUR_BOT_TOKEN"
    base_url = "https://api.telegram.org/bot#{token}/setwebhook"
    uri = URI.parse(base_url)

    res = Net::HTTP.get URI(base_url)
    puts res
  end
end

如果您将令牌存储在凭据中,则可以通过以下方式获取它们:token = Rails.application.credentials.telegram[:bot]

于 2018-12-30T17:37:56.557 回答