Created
August 14, 2022 16:09
-
-
Save mezgoodle/00d04a5586ed7d7d4ba9eaee1abf0834 to your computer and use it in GitHub Desktop.
Echo bot from Dev.to post
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
API_TOKEN = os.getenv('TOKEN', '5135575762:AAHdGW6cidFikmIKMKPVZjEpS0e8iAsmEwg') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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