Skip to content

Commit f714d78

Browse files
committed
make it better
0 parents  commit f714d78

File tree

3 files changed

+39
-0
lines changed

3 files changed

+39
-0
lines changed

Procfile

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
web: gunicorn app:app --log-file -

app.py

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import requests
2+
from flask import Flask, request
3+
4+
app = Flask(__name__)
5+
6+
bot_token = '502493425:AAEhMt3wAIz6CIansaAQeq79myV8xUOznGI'
7+
8+
def get_url(method):
9+
return "https://api.telegram.org/bot{}/{}".format(bot_token,method)
10+
11+
def process_message(update):
12+
data = {}
13+
data["chat_id"] = update["message"]["from"]["id"]
14+
data["text"] = "I can hear you!"
15+
r = requests.post(get_url("sendMessage"), data=data)
16+
17+
@app.route("/", methods=["POST"])
18+
def process_update():
19+
if request.method == "POST":
20+
update = request.get_json()
21+
print(update)
22+
if "message" in update:
23+
process_message(update)
24+
return "ok!", 200
25+
if __name__ == '__main__':
26+
app.run(debug = True)

requirements.txt

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
certifi==2018.4.16
2+
chardet==3.0.4
3+
click==6.7
4+
Flask==1.0.2
5+
idna==2.7
6+
itsdangerous==0.24
7+
Jinja2==2.10
8+
MarkupSafe==1.0
9+
pkg-resources==0.0.0
10+
requests==2.19.1
11+
urllib3==1.23
12+
Werkzeug==0.14.1

0 commit comments

Comments
 (0)