Guest User

Untitled

a guest
Jan 14th, 2024
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. import asyncio
  2.  
  3. from telegram import Update
  4. from telegram.constants import ParseMode as PM
  5. from telegram.ext import ApplicationBuilder, Defaults
  6.  
  7. import config
  8. from Abishnoi.setup import setup_
  9.  
  10. defaults = Defaults(parse_mode=PM.HTML, disable_web_page_preview=True, block=False)
  11.  
  12.  
  13. def main() -> None:
  14. application = (
  15. ApplicationBuilder()
  16. .token(config.TOKEN)
  17. .defaults(defaults)
  18. .post_init(setup_)
  19. .build()
  20. )
  21. application.run_polling(drop_pending_updates=True, allowed_updates=Update.ALL_TYPES)
  22.  
  23.  
  24. if __name__ == "__main__":
  25. main()
  26.  
  27. # Works Good .
  28. """
  29. async def main() -> None:
  30. application = (
  31. ApplicationBuilder()
  32. .token(config.TOKEN)
  33. .defaults(defaults)
  34. .post_init(setup_)
  35. .build()
  36. )
  37. async with application:
  38. await application.start()
  39. await application.updater.start_polling(
  40. drop_pending_updates=True, allowed_updates=Update.ALL_TYPES
  41. )
  42.  
  43. await application.updater.stop()
  44. await application.stop()
  45.  
  46.  
  47. if __name__ == "__main__":
  48. asyncio.run(main())
  49.  
  50. # Works good but only for 1 sec.
  51. """
Advertisement
Add Comment
Please, Sign In to add comment