Skip to content

Instantly share code, notes, and snippets.

@mezgoodle
Created August 14, 2022 16:09
Show Gist options
  • Save mezgoodle/00d04a5586ed7d7d4ba9eaee1abf0834 to your computer and use it in GitHub Desktop.
Save mezgoodle/00d04a5586ed7d7d4ba9eaee1abf0834 to your computer and use it in GitHub Desktop.
Echo bot from Dev.to post
import os
API_TOKEN = os.getenv('TOKEN', '5135575762:AAHdGW6cidFikmIKMKPVZjEpS0e8iAsmEwg')
import logging
from aiogram import Bot, Dispatcher, executor
from aiogram.types import Message
from config import API_TOKEN
# Configure logging
logging.basicConfig(level=logging.INFO)
# Initialize bot and dispatcher
bot = Bot(token=API_TOKEN)
dp = Dispatcher(bot)
@dp.message_handler(commands=['start', 'help'])
async def handle_start(message: Message) -> Message:
return await message.reply("Hi!\nI'm TestBot!")
@dp.message_handler()
async def echo(message: Message) -> Message:
return await message.answer(message.text)
if __name__ == '__main__':
executor.start_polling(dp, skip_updates=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment