-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfyers_webhook.py
34 lines (23 loc) · 909 Bytes
/
fyers_webhook.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
31
32
33
34
from flask import *
import requests
app = Flask(__name__)
def telegram_bot_sendtext(bot_message):
bot_token = 'your_bot_token' #------------ replace
bot_chatID = 'your_chat_token' #------------ replace
send_text = 'https://api.telegram.org/bot' + bot_token + '/sendMessage?chat_id=' + bot_chatID + \
'&parse_mode=HTML&text=' + bot_message
return requests.get(send_text)
@app.route('/fyers',methods=['GET', 'POST'])
def fyers():
if request.content_type == 'application/json' :
json_data = request.json
message = json.dumps(json_data)
if message is not None :
telegram_bot_sendtext(message)
return 'Done'
return "Unable to read Message"
@app.route('/',methods=['GET', 'POST'])
def home():
return 'All is well'
if __name__ == "__main__":
app.run(debug=True)