yuripeyamashita
commited on
Commit
•
13edd55
1
Parent(s):
5f02930
Update app.py
Browse files
app.py
CHANGED
@@ -20,9 +20,9 @@ def api():
|
|
20 |
try:
|
21 |
payload = get_payload_dict(request.get_json())
|
22 |
print(payload)
|
23 |
-
get_username(payload
|
24 |
-
|
25 |
-
|
26 |
except:
|
27 |
pass
|
28 |
return "", 200
|
@@ -62,10 +62,13 @@ def send_text(token, text):
|
|
62 |
]
|
63 |
})
|
64 |
|
65 |
-
def get_username(
|
66 |
-
url = f"https://api.line.me/v2/bot/group/{
|
67 |
-
|
68 |
-
|
|
|
|
|
|
|
69 |
|
70 |
|
71 |
if __name__ == "__main__":
|
|
|
20 |
try:
|
21 |
payload = get_payload_dict(request.get_json())
|
22 |
print(payload)
|
23 |
+
username = get_username(payload)
|
24 |
+
print(username)
|
25 |
+
send_text(payload.get("token"), f"{username}:{payload.get("msg_text")}")
|
26 |
except:
|
27 |
pass
|
28 |
return "", 200
|
|
|
62 |
]
|
63 |
})
|
64 |
|
65 |
+
def get_username(payload):
|
66 |
+
url = f"https://api.line.me/v2/bot/group/{payload.get("group_id")}/member/{payload.get("user_id")}"
|
67 |
+
try:
|
68 |
+
res_json = requests.get(url, headers={"Authorization": "Bearer " + LINE_CHANNEL_ACCESS_TOKEN}).json()
|
69 |
+
return res_json.get("displayName")
|
70 |
+
except:
|
71 |
+
return "Unknow"
|
72 |
|
73 |
|
74 |
if __name__ == "__main__":
|