You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

69 lines
1.8KB

  1. import logging.handlers
  2. import platform, traceback
  3. from lib import config
  4. from lib.BotClass import BotClass
  5. extensions = [
  6. 'cmds.l4p1n',
  7. 'cmds.anti_pub',
  8. 'cmds.fun',
  9. 'cmds.info',
  10. 'cmds.admin',
  11. 'cmds.utils',
  12. 'cmds.server_events',
  13. 'cmds.servers_stats',
  14. 'cmds.bot_stats',
  15. 'cmds.polls',
  16. 'cmds.logging',
  17. 'cmds.mod_tools',
  18. 'cmds.issues',
  19. 'cmds.backup',
  20. 'cmds.event_utils',
  21. 'cmds.socket_server',
  22. 'cmds.scheduled_messages',
  23. 'cmds.members_count'
  24. ]
  25. if __name__ == '__main__':
  26. bot = BotClass([config.BOT_COMMAND_PREFIX])
  27. bot.remove_command('help')
  28. # Setup le logging
  29. application = logging.getLogger('discord-bot')
  30. application.setLevel(logging.INFO)
  31. discord_logger = logging.getLogger('discord')
  32. discord_logger.setLevel(logging.INFO)
  33. root_logger = logging.getLogger()
  34. root_logger.setLevel(logging.INFO)
  35. formatter = logging.Formatter('%(asctime)s :: %(levelname)s :: %(name)s :: %(message)s')
  36. # Setup les handlers
  37. file_handler = logging.handlers.RotatingFileHandler('logs/bot.log', maxBytes=100_000_000, backupCount=10)
  38. file_handler.setFormatter(formatter)
  39. if platform.node() == 'l4p1n-archf':
  40. # stream_handler = logging.StreamHandler()1§
  41. # stream_handler.setFormatter(formatter)
  42. # root_logger.addHandler(stream_handler)
  43. pass
  44. root_logger.addHandler(file_handler)
  45. application.info('Enregistrement des extensions')
  46. for extension in extensions:
  47. try:
  48. application.info(f'Chargement de l\'extension {extension}')
  49. bot.load_extension(extension)
  50. except Exception:
  51. tr = traceback.format_exc()
  52. application.error(f'Ne peut pas charger l\'extension {extension}')
  53. application.error(tr)
  54. application.info('Exécution du bot')
  55. bot.run(config.BOT_TOKEN)