__init__.py 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. """Deep Exploration Planner"""
  2. import os
  3. import logging
  4. import telegram
  5. from sqlalchemy import create_engine
  6. from sqlalchemy.orm import sessionmaker
  7. from dotenv import load_dotenv
  8. from apscheduler.schedulers.background import BackgroundScheduler
  9. load_dotenv()
  10. # Telegram
  11. TELEGRAM_BOT = telegram.Bot(os.environ['TELEGRAM_KEY'])
  12. # database
  13. ENGINE = create_engine(os.environ["DATABASE_URI"])
  14. SESSION = sessionmaker(bind=ENGINE)
  15. # scheduler
  16. SCHEDULER = BackgroundScheduler(
  17. daemon=True,
  18. job_defaults={'misfire_grace_time': 300},
  19. )
  20. SCHEDULER.start()
  21. # get logger
  22. LOGGER = logging.getLogger(__name__)
  23. LOGGER.setLevel(logging.INFO)
  24. SCHEDULER_LOGGER = logging.getLogger('apscheduler')
  25. SCHEDULER_LOGGER.setLevel(logging.DEBUG)
  26. # create file handler
  27. FILE_HANDLER = logging.FileHandler('output.log')
  28. FILE_HANDLER.setLevel(logging.DEBUG)
  29. # create console handler
  30. STREAM_HANDLER = logging.StreamHandler()
  31. STREAM_HANDLER.setLevel(logging.INFO)
  32. # create formatter and add it to the handlers
  33. FORMATTER = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
  34. STREAM_HANDLER.setFormatter(FORMATTER)
  35. FILE_HANDLER.setFormatter(FORMATTER)
  36. # add the handlers to logger
  37. LOGGER.addHandler(STREAM_HANDLER)
  38. LOGGER.addHandler(FILE_HANDLER)
  39. SCHEDULER_LOGGER.addHandler(STREAM_HANDLER)
  40. SCHEDULER_LOGGER.addHandler(FILE_HANDLER)
  41. # api
  42. BASE_URL = os.environ["API_URL"]
  43. HEADERS = {
  44. 'Authorization': os.environ["AUTHORIZATION"]
  45. }
  46. RESOURCE_IDS = {
  47. 0: 'gold',
  48. 3: 'oil',
  49. 4: 'ore',
  50. 11: 'uranium',
  51. 15: 'diamond',
  52. }
  53. RESOURCE_NAMES = {
  54. 'gold': 0,
  55. 'oil': 3,
  56. 'ore': 4,
  57. 'uranium': 11,
  58. 'diamond': 15,
  59. 'diamonds': 15,
  60. }
  61. DEEP_EXPLORATION_MAX = {
  62. 0: 637,
  63. 3: 371,
  64. 4: 356,
  65. 11: 25,
  66. 15: 27,
  67. }
  68. RESOURCE_MAX = {
  69. 0: 2500,
  70. 3: 600,
  71. 4: 500,
  72. 11: 60,
  73. 15: 75,
  74. }
  75. KOEF_FACTOR = {
  76. 0: 0.4,
  77. 3: 0.65,
  78. 4: 0.65,
  79. 11: 0.75,
  80. 15: 0.75,
  81. }