1

所以,我有一个机器人并从@botfather 将隐私设置为禁用,因此机器人可以访问该组的消息。当我尝试将其添加到群组时,Telegram 会向我发送一条通知,该机器人一旦添加到群组中,将能够访问群组中的最后 100 条消息。

如何在我的机器人代码中实现它?由于限制是 100,我想它与 GetUpdates 函数有关,但是无论我设置什么偏移值,机器人都不会返回在它被添加到组之前发送的消息(我什至尝试设置随机数来查看是否有什么会改变)。这是使用 Telepot 的相关代码:

bot = telepot.Bot(token)

def handle(msg):
    content_type, chat_type, chat_id = telepot.glance(msg)
    #rest of code handling text messages

pprint(bot.getUpdates()) #no differences in results for various parameters passed to function
print("one time operation done\nbeginning loop")
#in theory the bot should get the last 100 messages in the group with getUpdates as a one-time operation and then start the loop

telepot.loop.MessageLoop(bot, handle).run_as_thread() #start loop
while 1:
    time.sleep(10)
4

0 回答 0