为什么我的热解图机器人总是关闭?

发布于 2025-01-13 11:26:00 字数 511 浏览 3 评论 0原文

由于某种原因,我的机器人总是关闭,而不将任何输出打印到命令行或显示任何类型的错误。该机器人在开启后可正常运行几个小时。基本代码如下所示:

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

故事还在继续 2025-01-20 11:26:00

如果 str(message.chat.id) 不在 chat_mapping 中
在此通道中,您的语句将检查 message.chat.id 是否等于字典的键之一,而不是值。

意味着您的 message.chat.id 不能是 123 或 321。

USER_ID = some id
chat_mapping = [some ids] 
@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()

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.

USER_ID = some id
chat_mapping = [some ids] 
@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()
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文