gather_client.py 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #!/usr/bin/env python3
  2. # ---------------------------------------------------------------------
  3. # ------------------------- Plight Rising -----------------------------
  4. # -----------------------------txtsd-----------------------------------
  5. # ---------------------------------------------------------------------
  6. """Runs the bot"""
  7. # Imports -------------------------------------------------------------
  8. import os
  9. import sys
  10. import time
  11. import random
  12. import datetime
  13. from pytz import timezone
  14. from configobj import ConfigObj
  15. from validate import Validator
  16. from classes.FRAccount import FRAccount
  17. from classes.Familiar import Familiar
  18. from classes.Gather import Gather
  19. from classes.Coliseum import Coliseum
  20. # End Imports ---------------------------------------------------------
  21. configspec = ConfigObj('config.spec', encoding='UTF8', list_values=False)
  22. config = ConfigObj('config.ini', configspec=configspec)
  23. val = Validator()
  24. test = config.validate(val, preserve_errors=True)
  25. if not test is True:
  26. print(test)
  27. sys.exit()
  28. if config['account']['username'] or (not config['account']['username'] == 'herp' and config['account']['password'] == 'derp'):
  29. fruser = config['account']['username']
  30. frpass = config['account']['password']
  31. proxyaddress = config['account']['proxy']
  32. gather = True
  33. bond = False
  34. coli = False
  35. start = datetime.time(23, 58)
  36. end = datetime.time(0, 32)
  37. pst = timezone('US/Pacific')
  38. acc = FRAccount(fruser, frpass, proxyaddress)
  39. if not (start < datetime.datetime.now(tz=pst).time() or datetime.datetime.now(tz=pst).time() < end):
  40. if acc.login():
  41. gHandler = Gather(acc)
  42. fHandler = Familiar(acc)
  43. if gather:
  44. gHandler.gather()
  45. if bond:
  46. fHandler.bond()
  47. if coli:
  48. try:
  49. cHandler = None
  50. cHandler = Coliseum()
  51. cHandler.play(acc)
  52. except Exception as e:
  53. # pass
  54. # e = sys.exc_info()[0]
  55. print("clientderp")
  56. print(type(e))
  57. print(e.args)
  58. print(e)
  59. except KeyboardInterrupt:
  60. sys.exit()
  61. # finally:
  62. # # del cHandler
  63. # time.sleep(random.randint(1, 2))
  64. # # acc.login()
  65. else:
  66. if os.path.isfile(fruser + '.bin'):
  67. os.remove(fruser + '.bin')
  68. time.sleep(10)
  69. else:
  70. print('Please set up your username and password, among other things, in config.ini')
  71. sys.exit()