-
Notifications
You must be signed in to change notification settings - Fork 0
/
osama.py
56 lines (40 loc) · 1.54 KB
/
osama.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/pyhton3.6
import os,sys
from flask import Flask,request
from pymessenger import Bot
app = Flask(__name__)
# Set GROOT_TOKEN to Access Token from your APP on Developers.facebook
GROOT_TOKEN = "EAAIFsf6srMoBAKLISKXJXPTFRw3ndXyBcywaBgMz1y9zPqOeXysdSiRU7QJepCRkvYsPBbQiU6POYRLc9SZCYRnj8orNwuMSf2QFcBGs60K9LMJxGrYok8aFaqGF0ORC4ox1sgsZBpaF7VemupBEzciyhgaHragJZAql2zdOodvZA4vkSZCKs"
GROOT = Bot(GROOT_TOKEN)
@app.route('/' , methods=['GET'])
def verify():
# Webhook
if request.args.get('hub.mode') == 'subscribe':
if not request.args.get('hub.verify_token') == "Groot" :
return "Verification token mismatch" , 403
return request.args["hub.challenge"], 200
return "Hello: I am GROOT :D" , 200
@app.route('/' , methods=['POST'])
def webhook ():
data = request.get_json()
log(data)
for entry in data['entry']:
for mess in entry['messaging']:
SENDER_ID = mess['sender']['id']
RECIPIENT_ID = mess['recipient']['id']
if mess.get('message'):