Experimental Discord bot written in Python
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

main.py 1.3KB

1234567891011121314151617181920212223242526272829303132333435
  1. """
  2. Rocketbot Discord bot. Relies on a configured config.py (copy config.sample.py
  3. for a template).
  4. Author: Ian Albert (@rocketsoup)
  5. Date: 2021-11-11
  6. """
  7. import sys
  8. MIN_PYTHON_VERSION = (3, 10, 0)
  9. if sys.version_info < MIN_PYTHON_VERSION:
  10. ver = sys.version_info
  11. raise RuntimeError(f'rocketbot requires Python {MIN_PYTHON_VERSION[0]}.{MIN_PYTHON_VERSION[1]}.{MIN_PYTHON_VERSION[2]} '
  12. f'or greater. Detected {ver[0]}.{ver[1]}.{ver[2]}.')
  13. import asyncio # noqa: E402
  14. from config import CONFIG # noqa: E402
  15. from rocketbot.bot import start_bot # noqa: E402
  16. from rocketbot.utils import bot_log # noqa: E402
  17. CURRENT_CONFIG_VERSION = 4
  18. if (CONFIG.get('__config_version') or 0) < CURRENT_CONFIG_VERSION:
  19. # If you're getting this error, it means something changed in config.py's
  20. # format. Consult config.sample.py and compare it to your own config.py.
  21. # Rename/move any values as needed. When satisfied, update "__config_version"
  22. # to the value in config.sample.py. ...I know, pretty janky migration process.
  23. raise RuntimeError('config.py format may be outdated. Review ' +
  24. 'config.sample.py, update the "__config_version" field to ' +
  25. f'{CURRENT_CONFIG_VERSION}, and try again.')
  26. try:
  27. asyncio.run(start_bot())
  28. except KeyboardInterrupt:
  29. bot_log(None, None, 'Stopping bot due to Ctrl+C key')