aiogram/examples/echo_bot.py

30 lines
568 B
Python
Raw Normal View History

"""
This is a echo bot.
It echoes any incoming text messages.
"""
2017-05-27 03:11:20 +03:00
import logging
from aiogram import Bot, Dispatcher, executor, types
2017-05-27 03:11:20 +03:00
API_TOKEN = 'BOT TOKEN HERE'
# Configure logging
2017-05-27 03:11:20 +03:00
logging.basicConfig(level=logging.INFO)
# Initialize bot and dispatcher
bot = Bot(token=API_TOKEN)
2017-05-27 03:11:20 +03:00
dp = Dispatcher(bot)
@dp.message_handler()
2017-06-03 10:53:13 +03:00
async def echo(message: types.Message):
2019-07-21 11:30:33 +03:00
# old style:
# await bot.send_message(message.chat.id, message.text)
await message.answer(message.text)
2017-05-27 03:11:20 +03:00
if __name__ == '__main__':
executor.start_polling(dp, skip_updates=True)