yuripeyamashita
commited on
Commit
•
c915bab
1
Parent(s):
e619c58
Update app.py
Browse files
app.py
CHANGED
@@ -34,7 +34,7 @@ def api():
|
|
34 |
raise ValueError("Unsend Success")
|
35 |
|
36 |
if "$$$" in payload.get("msg_text"):
|
37 |
-
if "
|
38 |
users_number = get_users_number()
|
39 |
|
40 |
users = list({item["user_id"] for item in message_list.values()})
|
@@ -82,6 +82,31 @@ def api():
|
|
82 |
message_list[payload.get("msg_id")] = {"user_id": payload.get("user_id"),
|
83 |
"amount": get_amount(payload.get("msg_text"))}
|
84 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
# username = get_username(payload)
|
86 |
# text = payload.get("msg_text")
|
87 |
# print(username)
|
@@ -98,6 +123,7 @@ def get_payload_dict(raw_payload) -> dict:
|
|
98 |
print(raw_payload)
|
99 |
events = raw_payload.get("events", [{}])[0]
|
100 |
return {"token": events.get("replyToken"),
|
|
|
101 |
"group_id": events.get("source", {}).get("groupId"),
|
102 |
"user_id": events.get("source", {}).get("userId"),
|
103 |
"msg_type": events.get("message", {}).get("type"),
|
|
|
34 |
raise ValueError("Unsend Success")
|
35 |
|
36 |
if "$$$" in payload.get("msg_text"):
|
37 |
+
if "結算" in payload.get("msg_text"):
|
38 |
users_number = get_users_number()
|
39 |
|
40 |
users = list({item["user_id"] for item in message_list.values()})
|
|
|
82 |
message_list[payload.get("msg_id")] = {"user_id": payload.get("user_id"),
|
83 |
"amount": get_amount(payload.get("msg_text"))}
|
84 |
|
85 |
+
for msg_id, data in message_list.items():
|
86 |
+
quoted_msg_id = data.get("quoted_msg_id")
|
87 |
+
quoted_msg_list = {key: value for key, value in message_list.items() if value.get("quoted_msg_id") == msg_id}
|
88 |
+
quoted_number = len(quoted_msg_list)
|
89 |
+
|
90 |
+
if not quoted_msg_id and quoted_number != 0:
|
91 |
+
amount: float = data.get("amount")
|
92 |
+
paid: float = 0.0
|
93 |
+
for _, value in quoted_msg_list.items():
|
94 |
+
paid += value.get("amount")
|
95 |
+
print(amount, paid)
|
96 |
+
if (amount-paid > 1):
|
97 |
+
print("未付清")
|
98 |
+
break
|
99 |
+
|
100 |
+
# if quoted_msg_id:
|
101 |
+
# fr = users.index(data.get("user_id"))
|
102 |
+
# to = users.index(message_list.get(quoted_msg_id).get("user_id"))
|
103 |
+
# matrix[fr][to] += data.get("amount")
|
104 |
+
|
105 |
+
# if not quoted_msg_id and quoted_number == 0: # 要平分的情況
|
106 |
+
# to = users.index(data.get("user_id"))
|
107 |
+
# for row in matrix:
|
108 |
+
# row[to] += (data.get("amount") / users_number)
|
109 |
+
|
110 |
# username = get_username(payload)
|
111 |
# text = payload.get("msg_text")
|
112 |
# print(username)
|
|
|
123 |
print(raw_payload)
|
124 |
events = raw_payload.get("events", [{}])[0]
|
125 |
return {"token": events.get("replyToken"),
|
126 |
+
"quote_token": events.get("message", {}).get("quoteToken"),
|
127 |
"group_id": events.get("source", {}).get("groupId"),
|
128 |
"user_id": events.get("source", {}).get("userId"),
|
129 |
"msg_type": events.get("message", {}).get("type"),
|