为什么我的热解图机器人总是关闭?
由于某种原因,我的机器人总是关闭,而不将任何输出打印到命令行或显示任何类型的错误。该机器人在开启后可正常运行几个小时。基本代码如下所示:
app = Client("my_account", '123456', '123456789abcd')
TESTING = "321"
USER_ID = "123"
chat_mapping = {TESTING: "-10011111111111", USER_ID: "-10011111111111"}
@app.on_message()
def my_handler(client, message):
if str(message.chat.id) not in chat_mapping:
return
elif str(message.chat.id) == USER_ID:
storeMsg(message)
else:
print(message.text)
app.run()
任何建议将不胜感激!
For some reason my bot always turns off without printing any output to the command line or showing any kind of error. The bot functions properly for a few hours after being turned on. Basic code looks like this:
app = Client("my_account", '123456', '123456789abcd')
TESTING = "321"
USER_ID = "123"
chat_mapping = {TESTING: "-10011111111111", USER_ID: "-10011111111111"}
@app.on_message()
def my_handler(client, message):
if str(message.chat.id) not in chat_mapping:
return
elif str(message.chat.id) == USER_ID:
storeMsg(message)
else:
print(message.text)
app.run()
Any advice would be greatly appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果 str(message.chat.id) 不在 chat_mapping 中
在此通道中,您的语句将检查
message.chat.id
是否等于字典的键之一,而不是值。意味着您的
message.chat.id
不能是 123 或 321。if str(message.chat.id) not in chat_mapping
in this lane, your statement will check if
message.chat.id
is equal one of the keys of dictionary, not values.Means your
message.chat.id
can't be 123 or 321.