Skip to content

Commit

Permalink
Switch to Webhooks
Browse files Browse the repository at this point in the history
Signed-off-by: infinity-plus <navdhareharsh2001@gmail.com>
  • Loading branch information
infinity-plus committed Mar 12, 2021
1 parent 821534e commit 2471346
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
3 changes: 3 additions & 0 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
},
"sheet2": {
"description": "API key from https://sheet.best"
},
"heroku": {
"description": "Heroku app link. Type App Name to get link."
}
}
}
7 changes: 5 additions & 2 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ def initilize(self):
dispatcher.add_handler(RolesHandler(
stop_button_handler, roles.chat_admins))

updater.start_polling()
updater.start_webhook(listen="0.0.0.0",
port=int(Config.PORT),
url_path=self.TOKEN)
updater.bot.setWebhook(Config.heroku + self.TOKEN)

def start(self, update, context):
context.bot.send_message(
Expand Down Expand Up @@ -174,7 +177,7 @@ def stop_quiz(self, update, context):
logger = logging.getLogger(__name__)
logging.basicConfig(
format='%(levelname)s:%(asctime)s:%(filename)s,%(lineno)d:%(name)s.%(funcName)s:%(message)s', level=logging.WARN)
if not (Config.api == "None" or Config.sheet1 == "None" or Config.sheet2 == "None"):
if not (Config.api == "None" or Config.sheet1 == "None" or Config.sheet2 == "None" or Config.heroku == "None"):
quiz_bot = Quiz(Config.api)
quiz_bot.initilize()
else:
Expand Down
2 changes: 2 additions & 0 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ class Config:
api: str = environ.get("api", "None")
sheet1: str = environ.get("sheet1", "None")
sheet2: str = environ.get("sheet2", "None")
heroku: str = environ.get("heroku", "None")
PORT: int = int(environ.get('PORT', 5000))

0 comments on commit 2471346

Please sign in to comment.