yuripeyamashita
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -9,6 +9,7 @@ GROUP_ID = os.environ.get("GROUP_ID")
|
|
9 |
LINE_CHANNEL_ACCESS_TOKEN = os.environ.get("LINE_CHANNEL_ACCESS_TOKEN")
|
10 |
|
11 |
message_list = {}
|
|
|
12 |
|
13 |
|
14 |
@app.route('/', methods=['GET'])
|
@@ -152,6 +153,9 @@ def api():
|
|
152 |
|
153 |
def get_payload_dict(raw_payload) -> dict:
|
154 |
# print(raw_payload)
|
|
|
|
|
|
|
155 |
events = raw_payload.get("events", [{}])[0]
|
156 |
return {"token": events.get("replyToken"),
|
157 |
"quote_token": events.get("message", {}).get("quoteToken"),
|
@@ -200,7 +204,8 @@ def get_username(user_id: str):
|
|
200 |
|
201 |
|
202 |
def get_users_number() -> int:
|
203 |
-
|
|
|
204 |
try:
|
205 |
res_json = requests.get(url, headers={"Authorization": "Bearer " + LINE_CHANNEL_ACCESS_TOKEN}).json()
|
206 |
return int(res_json.get("count"))
|
|
|
9 |
LINE_CHANNEL_ACCESS_TOKEN = os.environ.get("LINE_CHANNEL_ACCESS_TOKEN")
|
10 |
|
11 |
message_list = {}
|
12 |
+
group_id = ""
|
13 |
|
14 |
|
15 |
@app.route('/', methods=['GET'])
|
|
|
153 |
|
154 |
def get_payload_dict(raw_payload) -> dict:
|
155 |
# print(raw_payload)
|
156 |
+
global group_id
|
157 |
+
group_id = events.get("source", {}).get("groupId")
|
158 |
+
print(group_id)
|
159 |
events = raw_payload.get("events", [{}])[0]
|
160 |
return {"token": events.get("replyToken"),
|
161 |
"quote_token": events.get("message", {}).get("quoteToken"),
|
|
|
204 |
|
205 |
|
206 |
def get_users_number() -> int:
|
207 |
+
global group_id
|
208 |
+
url = f"https://api.line.me/v2/bot/group/{group_id}/members/count"
|
209 |
try:
|
210 |
res_json = requests.get(url, headers={"Authorization": "Bearer " + LINE_CHANNEL_ACCESS_TOKEN}).json()
|
211 |
return int(res_json.get("count"))
|