DEV Community

Nurjalol
Nurjalol

Posted on

AI makes telegram bot with aiogram! 🤯

I tried make telegram bot with AI(ChatGPT). And it works!
Input:

Create aiogram bot in python it could:
- When user sends "emoji" bot replys a random emoji
Enter fullscreen mode Exit fullscreen mode

Output:

from aiogram import Bot, Dispatcher, executor, types

# Initialize bot and dispatcher
bot = Bot(token="2132793876:AAGsWvWHejeFpitoGZ9ujvlSsXe0hOeJSvk")
dp = Dispatcher(bot)

# Import random to generate a random emoji
import random


# Emoji list
EmojiList = ["😄", "😆", "😊", "😎", "😍",
             "😚", "😜", "😁"]

# On message handler
@dp.message_handler()
async def message_handler(message: types.Message):
    # Reply random emoji
    await message.answer(random.choice(EmojiList))

# Start command
if __name__ == '__main__':
    executor.start_polling(dp, skip_updates=True)
Enter fullscreen mode Exit fullscreen mode

And this code had no bugs 🪲🤯

Top comments (1)

Collapse
 
jalol_dev profile image
Nurjalol

🔥🔥🔥