-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmelibbot_heroku.py
30 lines (26 loc) · 1020 Bytes
/
melibbot_heroku.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# Fichero usado en heroku
import logging
import os
from telegram.ext import Updater
from melibbot import melibbot
if __name__ == "__main__":
WEBHOOK_TOKEN = os.environ.get('WEBHOOK_TOKEN')
HEROKU_APP_NAME = os.environ.get('HEROKU_APP_NAME')
TELEGRAM_TOKEN = os.environ.get('TELEGRAM_TOKEN')
# Port is given by Heroku
PORT = os.environ.get('PORT', 80)
# Enable logging
logging.basicConfig(format='%(name)s - %(levelname)s - %(message)s',
level=logging.INFO)
logger = logging.getLogger(__name__)
# Set up the Updater
updater = Updater(token=TELEGRAM_TOKEN)
dp = updater.dispatcher
dp.add_handler(melibbot.get_handler())
dp.add_error_handler(melibbot.error_callback)
# Start the webhook
updater.start_webhook(listen="0.0.0.0",
port=int(PORT),
url_path=WEBHOOK_TOKEN)
updater.bot.setWebhook("https://{}.herokuapp.com/{}".format(HEROKU_APP_NAME, WEBHOOK_TOKEN))
updater.idle()