我嘗試使用電視馬拉松與電報機器人進行類似測驗的對話。它應該看起來像: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
提交
取消