我尝试使用电视马拉松与电报机器人进行类似测验的对话。它应该看起来像:user1 > /startbot > Hello who send you?user1 > user0bot > Thank you. So do you want in channel1 or channel2 or both?user1 > channel1*Bot invites the user我使用了这个例子: https://arabic-telethon.readthedocs.io/en/stable/extra/examples/telegram-client.html#conversations-waiting-for-messages-or-replies 示例代码:with bot.conversation(chat) as conv: conv.send_message('Hi!') hello = conv.get_response() conv.send_message('Please tell me your name') name = conv.get_response().raw_text while not any(x.isalpha() for x in name): conv.send_message("Your name didn't have any letters! Try again") name = conv.get_response().raw_text conv.send_message('Thanks {}!'.format(name))但它不会运行。文档中写道,聊天代表一个实体。所以我尝试了发件人 ID 和用户名...我的代码:@bot.on(events.NewMessage(chats=bot.get_entity('Just Another Test Group'),blacklist_chats=True,pattern='/access'))async def access(event): print("jop") temp = await event.get_sender() temp2 = await event.get_chat() print(temp) print(temp2.id) with bot.conversation(temp.id) as conv: print("started") event.respond("hmm") conv.send_message('Hi!') hello = conv.get_response() conv.send_message('Please tell me your name') name = conv.get_response().raw_text while not any(x.isalpha() for x in name): conv.send_message("Your name didn't have any letters! Try again") name = conv.get_response().raw_text conv.send_message('Thanks {}!'.format(name))
1 回答
幕布斯6054654
TA贡献1876条经验 获得超7个赞
天啊……对不起。这是关于 Telegram Web 的。
当我使用手机或桌面应用程序时,我会完美地重新排列所有内容......
我对此感到抱歉。
添加回答
举报
0/150
提交
取消