我嘗試使用電視馬拉松與電報(bào)機(jī)器人進(jìn)行類似測驗(yàn)的對(duì)話。它應(yīng)該看起來像: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我使用了這個(gè)例子: 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))但它不會(huì)運(yùn)行。文檔中寫道,聊天代表一個(gè)實(shí)體。所以我嘗試了發(fā)件人 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))
Telethon client.conversation() 不起作用
人到中年有點(diǎn)甜
2023-10-26 10:41:38