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.

60 lines
1.4KB

  1. #!/usr/env python
  2. import configparser
  3. import discord
  4. from discord.ext.commands import Bot
  5. from config.config import Config
  6. from cogs import cogs
  7. __version__ = '0.3.6'
  8. # TODO: make that constants file
  9. settings = configparser.ConfigParser()
  10. settings.read('config/settings.ini')
  11. token = settings["Credentials"]["Token"]
  12. owner_id = settings["RoxBot"]["OwnerID"]
  13. command_prefix = settings["RoxBot"]["CommandPrefix"]
  14. bot = Bot(command_prefix=command_prefix)
  15. con = Config(bot)
  16. def blacklisted(user):
  17. with open("config/blacklist.txt", "r") as fp:
  18. for line in fp.readlines():
  19. if user.id+"\n" == line:
  20. return True
  21. return False
  22. @bot.event
  23. async def on_ready():
  24. # TODO: First part needs to be moved to wait_until_ready
  25. con.config_errorcheck()
  26. print("Discord.py version: "+discord.__version__)
  27. print("Client logged in\n")
  28. await bot.change_presence(game=discord.Game(name="v"+__version__), afk=False)
  29. print("Cods loaded:")
  30. for cog in cogs:
  31. bot.load_extension(cog)
  32. print("{}".format(cog))
  33. print("")
  34. print("Servers I am currently in:")
  35. for server in bot.servers:
  36. print(server)
  37. print("")
  38. @bot.event
  39. async def on_message(message):
  40. if blacklisted(message.author):
  41. return
  42. else:
  43. return await bot.process_commands(message)
  44. if __name__ == "__main__":
  45. bot.run(token)