Telegram basic conversation

PHOTO EMBED

Thu Aug 11 2022 05:26:45 GMT+0000 (Coordinated Universal Time)

Saved by @undacova_brotha #python

from telethon import events, TelegramClient


bot = TelegramClient(BOT_SESSION,
                     BOT_API_ID,
                     BOT_API_HASH).start(bot_token=BOT_TOKEN)


@bot.on(events.NewMessage(pattern='/greeting'))
async def greeting(event):
    async with bot.conversation(await event.get_chat(), exclusive=True) as conv:
        await conv.send_message('Hi!')
        hello = await conv.get_response()
        await conv.send_message('Please tell me your name')
        name = await conv.get_response().raw_text
        await conv.send_message(f'Thanks {name}!')
content_copyCOPY