Experimental Discord bot written in Python
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

rocketbot.py 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. """
  2. Rocketbot Discord bot. Relies on a configured config.py (copy config.py.sample
  3. for a template).
  4. Author: Ian Albert (@rocketsoup)
  5. Date: 2021-11-11
  6. """
  7. from discord import Intents
  8. from discord.ext import commands
  9. from config import CONFIG
  10. from cogs.configcog import ConfigCog
  11. from cogs.crosspostcog import CrossPostCog
  12. from cogs.generalcog import GeneralCog
  13. from cogs.joinraidcog import JoinRaidCog
  14. from cogs.patterncog import PatternCog
  15. from cogs.urlspamcog import URLSpamCog
  16. CURRENT_CONFIG_VERSION = 3
  17. if (CONFIG.get('__config_version') or 0) < CURRENT_CONFIG_VERSION:
  18. # If you're getting this error, it means something changed in config.py's
  19. # format. Consult config.py.sample and compare it to your own config.py.
  20. # Rename/move any values as needed. When satisfied, update "__config_version"
  21. # to the value in config.py.sample.
  22. raise RuntimeError('config.py format may be outdated. Review ' +
  23. 'config.py.sample, update the "__config_version" field to ' +
  24. f'{CURRENT_CONFIG_VERSION}, and try again.')
  25. class Rocketbot(commands.Bot):
  26. """
  27. Bot subclass
  28. """
  29. def __init__(self, command_prefix, **kwargs):
  30. super().__init__(command_prefix, **kwargs)
  31. intents = Intents.default()
  32. intents.messages = True # pylint: disable=assigning-non-slot
  33. intents.members = True # pylint: disable=assigning-non-slot
  34. bot = Rocketbot(command_prefix=CONFIG['command_prefix'], intents=intents)
  35. # Core
  36. bot.add_cog(GeneralCog(bot))
  37. bot.add_cog(ConfigCog(bot))
  38. # Optional
  39. bot.add_cog(CrossPostCog(bot))
  40. bot.add_cog(JoinRaidCog(bot))
  41. bot.add_cog(PatternCog(bot))
  42. bot.add_cog(URLSpamCog(bot))
  43. bot.run(CONFIG['client_token'], bot=True, reconnect=True)
  44. print('\nBot aborted')