yuripeyamashita
commited on
Commit
•
af688b0
1
Parent(s):
4caed3e
Update app.py
Browse files
app.py
CHANGED
@@ -24,6 +24,15 @@ def api():
|
|
24 |
text = payload.get("msg_text")
|
25 |
print(username)
|
26 |
send_text(payload.get("token"), f"{username}:{text}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
except:
|
28 |
pass
|
29 |
return "", 200
|
@@ -31,25 +40,25 @@ def api():
|
|
31 |
|
32 |
def get_payload_dict(raw_payload):
|
33 |
print(raw_payload)
|
34 |
-
|
35 |
-
|
36 |
-
group_id = raw_payload.get("events", [{}])[0].get("source", {}).get("groupId")
|
37 |
-
user_id = raw_payload.get("events", [{}])[0].get("source", {}).get("userId")
|
38 |
-
msg_type = raw_payload.get("events", [{}])[0].get("message", {}).get("type")
|
39 |
-
msg_id = raw_payload.get("events", [{}])[0].get("message", {}).get("id")
|
40 |
-
msg_text = raw_payload.get("events", [{}])[0].get("message", {}).get("text")
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
|
54 |
|
55 |
def send_text(token, text):
|
|
|
24 |
text = payload.get("msg_text")
|
25 |
print(username)
|
26 |
send_text(payload.get("token"), f"{username}:{text}")
|
27 |
+
{"msgid":{
|
28 |
+
"payer": "userid"
|
29 |
+
"debtor":{
|
30 |
+
"userid": -10,
|
31 |
+
"userid": -20
|
32 |
+
}
|
33 |
+
}
|
34 |
+
|
35 |
+
}
|
36 |
except:
|
37 |
pass
|
38 |
return "", 200
|
|
|
40 |
|
41 |
def get_payload_dict(raw_payload):
|
42 |
print(raw_payload)
|
43 |
+
events = raw_payload.get("events", [{}])[0]
|
44 |
+
# token = raw_payload.get("events", [{}])[0].get("replyToken")
|
45 |
+
# group_id = raw_payload.get("events", [{}])[0].get("source", {}).get("groupId")
|
46 |
+
# user_id = raw_payload.get("events", [{}])[0].get("source", {}).get("userId")
|
47 |
+
# msg_type = raw_payload.get("events", [{}])[0].get("message", {}).get("type")
|
48 |
+
# msg_id = raw_payload.get("events", [{}])[0].get("message", {}).get("id")
|
49 |
+
# msg_text = raw_payload.get("events", [{}])[0].get("message", {}).get("text")
|
50 |
+
# quoted_msg_id = raw_payload.get("events", [{}])[0].get("message", {}).get("quotedMessageId")
|
51 |
+
# unsend_msg_id = raw_payload.get("events", [{}])[0].get("unsend", {}).get("messageId")
|
52 |
+
# postback_data = raw_payload.get("events", [{}])[0].get("postback", {}).get("data")
|
53 |
+
return {"token": events.get("replyToken"),
|
54 |
+
"group_id": events.get("source", {}).get("groupId"),
|
55 |
+
"user_id": events.get("source", {}).get("userId"),
|
56 |
+
"msg_type": events.get("message", {}).get("type"),
|
57 |
+
"msg_id": events.get("message", {}).get("id"),
|
58 |
+
"msg_text": events.get("message", {}).get("text"),
|
59 |
+
"quoted_msg_id": events.get("message", {}).get("quotedMessageId"),
|
60 |
+
"unsend_msg_id": events.get("unsend", {}).get("messageId")
|
61 |
+
}
|
62 |
|
63 |
|
64 |
def send_text(token, text):
|