client.py 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import logging
  2. import toml
  3. from freebies import Freebies
  4. from neoaccount import NeoAccount
  5. # Setup logs
  6. logger = logging.getLogger('neobots')
  7. logger.setLevel(logging.DEBUG)
  8. fileHandler = logging.FileHandler('debug.log')
  9. fileHandler.setLevel(logging.WARNING)
  10. consoleHandler = logging.StreamHandler()
  11. consoleHandler.setLevel(logging.DEBUG)
  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 = NeoAccount(config)
  32. if account.login():
  33. # Start daily freebies
  34. freebies = Freebies(account)
  35. freebies.doTrudy()
  36. freebies.doSnowager()
  37. freebies.doAnchor()
  38. freebies.doAppleBobbing()
  39. freebies.doAdvent()
  40. freebies.doBankCollect()
  41. freebies.doColtzan()
  42. freebies.doDailyPuzzle()
  43. freebies.doQuarry()