import asyncio import logging from aiogram import Bot, types from aiogram.dispatcher import Dispatcher API_TOKEN = 'BOT TOKEN HERE' logging.basicConfig(level=logging.INFO) loop = asyncio.get_event_loop() bot = Bot(token=API_TOKEN, loop=loop) dp = Dispatcher(bot) @dp.message_handler(commands=['start', 'help']) async def send_welcome(message: types.Message): await message.reply("Hi!\nI'm EchoBot!\nPowered by aiogram.") @dp.message_handler(regexp='(^cat[s]?$|puss)') async def cats(message: types.Message): with open('data/cats.jpg', 'rb') as photo: await bot.send_photo(message.chat.id, photo, caption='Cats is here 😺', reply_to_message_id=message.message_id) @dp.message_handler() async def echo(message: types.Message): await bot.send_message(message.chat.id, message.text) async def main(): count = await dp.skip_updates() print(f"Skipped {count} updates.") await dp.start_pooling() if __name__ == '__main__': try: loop.run_until_complete(main()) except KeyboardInterrupt: loop.stop()