Showcasing their subclassing example:

from dumbot import Bot

class Subbot(Bot):
    async def init(self): = await self.getMe()

    async def on_update(self, update):
        await self.sendMessage(
            text='i am {}'.format(


After rewriting:

from telethon import TelegramClient, events

class Subbot(TelegramClient):
    def __init__(self, *a, **kw):
        await super().__init__(*a, **kw)
        self.add_event_handler(self.on_update, events.NewMessage)

    async def connect():
        await super().connect() = await self.get_me()

    async def on_update(event):
        await event.reply('i am {}'.format(

bot = Subbot('bot', 11111, 'a1b2c3d4').start(bot_token='TOKEN')

Key differences:

  • Telethon method names are snake_case.
  • dumbot does not offer friendly methods like update.reply.
  • Telethon does not have an implicit on_update handler, so we need to manually register one.
分类: MTProto

0 条评论


Avatar placeholder