client.py 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import logging
  2. import toml
  3. from account import OrnaAccount
  4. from grind_at_home import GrindAtHome
  5. # Setup logs
  6. logger = logging.getLogger('ornauto')
  7. logger.setLevel(logging.DEBUG)
  8. fileHandler = logging.FileHandler('debug.log')
  9. fileHandler.setLevel(logging.WARNING)
  10. consoleHandler = logging.StreamHandler()
  11. consoleHandler.setLevel(logging.INFO)
  12. logFormat = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
  13. fileHandler.setFormatter(logFormat)
  14. consoleHandler.setFormatter(logFormat)
  15. logger.addHandler(fileHandler)
  16. logger.addHandler(consoleHandler)
  17. # Read config
  18. logger.debug('Reading config.toml')
  19. with open('config.toml') as f:
  20. config_file = f.read()
  21. logger.debug('Finished reading config.toml')
  22. try:
  23. logger.debug('Parsing config.toml')
  24. configs = toml.loads(config_file)
  25. logger.debug('Finished parsing config.toml')
  26. except Exception as e:
  27. logger.error('Failed to parse config.toml!')
  28. # Pick the first account
  29. config = configs['account'][0]
  30. # Login to the first account
  31. account = OrnaAccount(config)
  32. logger.debug('Logging in')
  33. grind = GrindAtHome(account)
  34. grind.firstRequests()
  35. grind.idle()
  36. # grind.arena_battle()