forked from V8ST8K/BTC-Wallet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
44 lines (33 loc) · 1.03 KB
/
app.py
File metadata and controls
44 lines (33 loc) · 1.03 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# -*- coding:utf-8 -*-?
import os
import flask
import telebot
import logging
from bot import Bot
WEBHOOK_URL = os.environ["WEBHOOK_URL"]+"/bot/"+os.environ["BOT_TOKEN"]
WEBHOOK_PATH = "/"+os.environ["BOT_TOKEN"]
BOT_TOKEN = os.environ["BOT_TOKEN"]
app = flask.Flask(__name__)
app.comission = 32000
@app.route("/bot/<token>", methods=['POST'])
def getMessage(token):
if token == BOT_TOKEN:
update = telebot.types.Update.de_json(flask.request.stream.read().decode("utf-8"))
if update.message is not None:
bot._process_message(update.message)
if update.callback_query is not None:
bot._process_callback(update.callback_query)
return "", 200
else:
return "", 404
@app.route("/")
def webhook():
return "Hola!", 200
@app.route("/set")
def set_webhook():
bot.telegram.remove_webhook()
bot.telegram.set_webhook(url=WEBHOOK_URL)
bot.logger.info("Webhook set")
return "Webhook setted", 200
bot = Bot(debug=False)
if __name__=="__main__": app.run(port=8080)