Skip to content
This repository has been archived by the owner on Jan 8, 2022. It is now read-only.

Commit

Permalink
update settings for smooth deploy to heroku
Browse files Browse the repository at this point in the history
  • Loading branch information
aahnik committed Nov 26, 2020
1 parent bf68e9e commit ecc0f64
Showing 1 changed file with 14 additions and 22 deletions.
36 changes: 14 additions & 22 deletions bot/config.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
from urllib.parse import urljoin
import os

try:
with open('token.txt') as f:
BOT_API_TOKEN = f.readline().strip()
except:
BOT_API_TOKEN = os.getenv('BOT_API_TOKEN')

assert BOT_API_TOKEN
from secrets import token_urlsafe

with open('messages/start.txt') as f:
START_MESSAGE = f.read()
Expand All @@ -18,20 +10,20 @@
with open('messages/code.txt') as f:
CODE_INFO = f.read()

PROJECT_SUBDOMAIN = os.getenv('APP_NAME')
DOMAIN = os.getenv('DOMAIN')

# webhook settings
WEBHOOK_HOST = f'https://{PROJECT_SUBDOMAIN}.{DOMAIN}.com'
WEBHOOK_PATH = '/webhook/' + BOT_API_TOKEN[::-1]
WEBHOOK_URL = urljoin(WEBHOOK_HOST, WEBHOOK_PATH)
API_TOKEN = os.getenv('API_TOKEN')
assert API_TOKEN

HEROKU_APP_NAME = os.getenv('HEROKU_APP_NAME')
assert HEROKU_APP_NAME

# webapp settings
WEBAPP_HOST = '*'
# WEBAPP_PORT = os.getenv('PORT')
WEBAPP_PORT = 8443
webhook_secret = token_urlsafe(32)

# webhook settings
WEBHOOK_HOST = f'https://{HEROKU_APP_NAME}.herokuapp.com'
WEBHOOK_PATH = f'/webhook/{webhook_secret}'
WEBHOOK_URL = f'{WEBHOOK_HOST}{WEBHOOK_PATH}'

# way to run
METHOD = os.getenv('METHOD', 'polling')
# METHOD can be `polling` or `webhook`
# webserver settings
WEBAPP_HOST = '0.0.0.0'
WEBAPP_PORT = int(os.getenv('PORT'))

0 comments on commit ecc0f64

Please sign in to comment.