Guest User

Untitled

a guest
Jun 6th, 2020
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.01 KB | None | 0 0
  1. import logging
  2.  
  3. from aiogram import Bot, Dispatcher, executor, types
  4.  
  5. API_TOKEN = 'Тут токен'
  6. PROXY_URL = 'socks5://104.248.63.17:30588/'
  7.  
  8. # Configure logging
  9. logging.basicConfig(level=logging.INFO)
  10.  
  11. # Initialize bot and dispatcher
  12. bot = Bot(token=API_TOKEN)
  13. dp = Dispatcher(bot)
  14.  
  15.  
  16.  
  17. @dp.message_handler(regexp='(^cat[s]?$|puss)')
  18. async def cats(message: types.Message):
  19.     with open('data/cats.jpg', 'rb') as photo:
  20.         '''
  21.        # Old fashioned way:
  22.        await bot.send_photo(
  23.            message.chat.id,
  24.            photo,
  25.            caption='Cats are here 😺',
  26.            reply_to_message_id=message.message_id,
  27.        )
  28.        '''
  29.  
  30.         await message.reply_photo(photo, caption='Cats are here 😺')
  31.  
  32.  
  33. @dp.message_handler()
  34. async def echo(message: types.Message):
  35.     # old style:
  36.     # await bot.send_message(message.chat.id, message.text)
  37.  
  38.     await message.answer(message.text)
  39.  
  40.  
  41. if __name__ == '__main__':
  42.     executor.start_polling(dp, skip_updates=True)
Advertisement
Add Comment
Please, Sign In to add comment