yuripeyamashita
commited on
Commit
•
d1df012
1
Parent(s):
61ddc9c
Update app.py
Browse files
app.py
CHANGED
@@ -77,23 +77,32 @@ def api():
|
|
77 |
if payload.get("quoted_msg_id"):
|
78 |
message_list[payload.get("msg_id")] = {"user_id": payload.get("user_id"),
|
79 |
"amount": get_amount(payload.get("msg_text")),
|
80 |
-
"quoted_msg_id": payload.get("quoted_msg_id")
|
81 |
else:
|
82 |
message_list[payload.get("msg_id")] = {"user_id": payload.get("user_id"),
|
83 |
"amount": get_amount(payload.get("msg_text")),
|
84 |
-
"quote_token": payload.get("quote_token")
|
|
|
85 |
|
86 |
for msg_id, data in message_list.items():
|
87 |
quoted_msg_id = data.get("quoted_msg_id")
|
88 |
quoted_msg_list = {key: value for key, value in message_list.items() if value.get("quoted_msg_id") == msg_id}
|
89 |
|
90 |
-
if not quoted_msg_id and len(quoted_msg_list) != 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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
97 |
send_text(payload.get("token"), f"$ {amount-paid} 未付清", data.get("quote_token"))
|
98 |
break
|
99 |
|
@@ -120,7 +129,7 @@ def api():
|
|
120 |
|
121 |
|
122 |
def get_payload_dict(raw_payload) -> dict:
|
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"),
|
|
|
77 |
if payload.get("quoted_msg_id"):
|
78 |
message_list[payload.get("msg_id")] = {"user_id": payload.get("user_id"),
|
79 |
"amount": get_amount(payload.get("msg_text")),
|
80 |
+
"quoted_msg_id": payload.get("quoted_msg_id")}
|
81 |
else:
|
82 |
message_list[payload.get("msg_id")] = {"user_id": payload.get("user_id"),
|
83 |
"amount": get_amount(payload.get("msg_text")),
|
84 |
+
"quote_token": payload.get("quote_token"),
|
85 |
+
"msg_text": payload.get("msg_text")}
|
86 |
|
87 |
for msg_id, data in message_list.items():
|
88 |
quoted_msg_id = data.get("quoted_msg_id")
|
89 |
quoted_msg_list = {key: value for key, value in message_list.items() if value.get("quoted_msg_id") == msg_id}
|
90 |
|
91 |
+
if not quoted_msg_id and len(quoted_msg_list) != 0:
|
92 |
amount: float = data.get("amount")
|
93 |
paid: float = 0.0
|
94 |
for _, value in quoted_msg_list.items():
|
95 |
paid += value.get("amount")
|
96 |
print(amount, paid)
|
97 |
+
|
98 |
+
if amount-paid <= 1 and payload.get("quoted_msg_id") == msg_id:
|
99 |
+
s = f"{data.get("msg_text")} paid by {get_username(data.get("user_id"))}\n\n"
|
100 |
+
for _, q_data in quoted_msg_list.items():
|
101 |
+
s += f"{get_username(q_data.get("user_id"))} : {q_data.get("amount")}\n"
|
102 |
+
send_text(payload.get("token"), s, data.get("quote_token"))
|
103 |
+
break
|
104 |
+
|
105 |
+
if amount-paid > 1 and payload.get("quoted_msg_id") != msg_id:
|
106 |
send_text(payload.get("token"), f"$ {amount-paid} 未付清", data.get("quote_token"))
|
107 |
break
|
108 |
|
|
|
129 |
|
130 |
|
131 |
def get_payload_dict(raw_payload) -> dict:
|
132 |
+
# print(raw_payload)
|
133 |
events = raw_payload.get("events", [{}])[0]
|
134 |
return {"token": events.get("replyToken"),
|
135 |
"quote_token": events.get("message", {}).get("quoteToken"),
|