Skip to content

Commit

Permalink
make it better
Browse files Browse the repository at this point in the history
  • Loading branch information
markroxor committed Jun 18, 2018
0 parents commit f714d78
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: gunicorn app:app --log-file -
26 changes: 26 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import requests
from flask import Flask, request

app = Flask(__name__)

bot_token = '502493425:AAEhMt3wAIz6CIansaAQeq79myV8xUOznGI'

def get_url(method):
return "https://api.telegram.org/bot{}/{}".format(bot_token,method)

def process_message(update):
data = {}
data["chat_id"] = update["message"]["from"]["id"]
data["text"] = "I can hear you!"
r = requests.post(get_url("sendMessage"), data=data)

@app.route("/", methods=["POST"])
def process_update():
if request.method == "POST":
update = request.get_json()
print(update)
if "message" in update:
process_message(update)
return "ok!", 200
if __name__ == '__main__':
app.run(debug = True)
12 changes: 12 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
certifi==2018.4.16
chardet==3.0.4
click==6.7
Flask==1.0.2
idna==2.7
itsdangerous==0.24
Jinja2==2.10
MarkupSafe==1.0
pkg-resources==0.0.0
requests==2.19.1
urllib3==1.23
Werkzeug==0.14.1

0 comments on commit f714d78

Please sign in to comment.