Advertisement
AIwinter

Untitled

Sep 8th, 2024
25
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. import asyncio
  2. from aiogram.types import Message
  3. from aiogram import Bot, Dispatcher
  4.  
  5.  
  6. token = '7462807969:AAGTsJa6NpVfTWeupQINXU3ZP4lNMrYAXtY'
  7.  
  8. async def start_bot(bot: Bot):
  9. await bot.send_message(7462807969, text='Бот запущен')
  10.  
  11. async def stop_bot(bot: Bot):
  12. await bot.send_message(7462807969, text='Бот остановлен')
  13.  
  14. async def get_start(message: Message, bot: Bot):
  15. await bot.send_message(message.from_user.id, f'Привет {message.from_user.first_name}')
  16. await message.answer(f'Привет {message.from_user.first_name}')
  17. await message.reply(f'Привет {message.from_user.first_name}')
  18.  
  19. async def start():
  20. bot = Bot(token=token)
  21.  
  22. dp = Dispatcher()
  23. dp.startup.register(start_bot)
  24. dp.shutdown.register(stop_bot)
  25.  
  26. dp.message.register(get_start)
  27. try:
  28. await dp.start_polling(bot)
  29. finally:
  30. await bot.session.close()
  31.  
  32. if __name__ == "__main__":
  33. asyncio.run(start())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement