Search code examples
pythontelegram-bottelepot

Bot keeps showing the same error when kicked TELEPOT


I've created a telegram bot that only prints the message that I send, everything works correctly until I block it or add/kick it from a group, when I do this the bot keeps showing this error: 1

Here's the code:

import telepot
from telepot.loop import MessageLoop
from pprint import pprint
import time

TOKEN="..."

def handler(msg):
    content, chat, id=telepot.glance(msg)
    pprint(msg)

bot=telepot.Bot(TOKEN)
bot.message_loop(handler)

while True:
    time.sleep(10)

I've also tried using the getUpdates function and it keeps printing all the messages, even the old deleted ones. I think that the problem is caused by "stored" messages but I don't know how to fix it.

I'm using:

  • telepot version 12.7
  • python 3.9.0

Solution

  • I hope that you fixed this problem already.. But to help you or any future visitors I am sharing a simple solution.

    pip uninstall telepot

    pip install telepota

    As telepot is not being maintained or updated since 2018 telegrams Bot API update raised the issue which is fixed in telepota. Telepota is a fork of Telepot which is Being updated timely.. Best part is you don't need a single change in your code..