在以下位置找不到 <telethon.tl.types.PeerUser 对象的输入实体

Ror*_*oro 6 python-3.x telethon

我收到错误ValueError:找不到 . 请阅读https://docs.telethon.dev/en/latest/concepts/entities.html以了解更多详细信息。. 此错误来自 client.send_message(bot_id, 'reset')。

def run_test(self,name,bot_id):
        self.start = time.time()
        api_id = 10*****
        api_hash = 'c1*********************************'

        with TelegramClient('anon', api_id, api_hash) as client:
            #breakpoint()
            results = {'results':[], 'start': time.asctime(time.localtime(self.start)), 'conversations': len(self.conversations['tests'])}

            Button(self, text='Cancel', width=20, font=("Lucinda Sans", 12),command=self.cancel(client)).pack()

            statusintro = 'Bot Instance ' + name +': '
            testtitle = ""

            self.show_output(statusintro + testtitle)

            if self.conversationReset is False:
                client.send_message(bot_id, self.conversations['tests'][self.test_counter]['questions'][self.question_counter])
            else:
                print (bot_id)                
                client.send_message(bot_id, 'reset')
                self.conversationReset = False
Run Code Online (Sandbox Code Playgroud)

小智 1

不知道还有没有人需要这个。但几分钟前我遇到了这个问题,修复方法是使用机器人名称代替机器人 ID。

client.send_message(client.get_entity('enter bot name here'),"Message")
Run Code Online (Sandbox Code Playgroud)