有人会犯这样的错误吗?我怎么才能治好他们?
2021-11-07 08:29:38,643 - telegram.ext.updater - ERROR - Error while getting Updates: Conflict: terminated by other getUpdates request; make sure that only one bot instance is running
2021-11-07 08:29:38,644 - telegram.ext.dispatcher - ERROR - No error handlers are registered, logging exception.
Traceback (most recent call last):
File "/usr/local/lib/python3.8/dist-packages/telegram/ext/updater.py", line 646, in _network_loop_retry
if not action_cb():
File "/usr/local/lib/python3.8/dist-packages/telegram/ext/updater.py", line 597, in polling_action_cb
updates = self.bot.get_updates(
File "/usr/local/lib/python3.8/dist-packages/telegram/ext/extbot.py", line 222, in get_updates
updates = super().get_updates(
File "/usr/local/lib/python3.8/dist-packages/telegram/bot.py", line 130, in decorator
result = func(*args, **kwargs)
File "/usr/local/lib/python3.8/dist-packages/telegram/bot.py", line 2861, in get_updates
self._post(
File "/usr/local/lib/python3.8/dist-packages/telegram/bot.py", line 295, in _post
return self.request.post(
File "/usr/local/lib/python3.8/dist-packages/telegram/utils/request.py", line 356, in post
result = self._request_wrapper(
File "/usr/local/lib/python3.8/dist-packages/telegram/utils/request.py", line 283, in _request_wrapper
raise Conflict(message)
telegram.error.Conflict: Conflict: terminated by other getUpdates request; make sure that only one bot instance is running
我从API那里得到这些答案
api.telegram.org/bot<token>/getWebhookInfo --> {"ok":true,"result":"url":"","has_custom_certificate":false,"pending_update_count":0}}
api.telegram.org/bot<token>/getUpdates --> {"ok":false,"error_code":409,"description":"Conflict: terminated by other getUpdates request; make sure that only one bot instance is running"}
发布于 2021-11-07 11:38:52
当两个不同的客户端为一个bot令牌向电报服务器发送getUpdates
方法时,就会发生这种情况。
您应该确保您的脚本不同时运行一次以上,或者您的bot令牌不会在其他地方使用。
如果您确信您的脚本是单独执行的,并且没有其他实例,那么从https://t.me/botfather中撤消您的bot令牌并获得一个新的令牌。
发布于 2022-03-01 12:07:48
我解决了这个问题,像这样排列代码:
from telegram.ext import CommandHandler, Updater
from logging import basicConfig, getLogger, INFO
basicConfig(level=INFO)
log = getLogger()
def start(update, context):
update.message.reply_text(
"start this bot",
parse_mode="markdown")
def help(update, context):
update.message.reply_text(
"help for this bot",
parse_mode="markdown")
def main():
updater = Updater(token=BOT_TOKEN, use_context=True)
dispatcher = updater.dispatcher
start_handler = CommandHandler("start", start)
help_handler = CommandHandler("help", help)
dispatcher.add_handler(start_handler)
dispatcher.add_handler(help_handler)
updater.start_polling()
if __name__ == '__main__':
main()
如果您正在使用烧瓶,不要在您的开发服务器上将调试模式设置为true,首先调用主函数,然后调用烧瓶服务器,如下所示:-
app = Flask(__name__)
if __name__ == '__main__':
main()
app.run()
发布于 2022-06-01 04:26:46
停止bot,关闭IDE,确保所有python进程都在任务管理器中结束,然后再试一次。这对我有帮助。
https://stackoverflow.com/questions/69870914
复制相似问题