Spaces:
Running
Running
Update join.py
Browse files
join.py
CHANGED
|
@@ -14,7 +14,7 @@ if not X_ACCOUNT:
|
|
| 14 |
BASE = "https://desk-api.channel.io/desk/channels/200605"
|
| 15 |
GROUP_ID = 463667
|
| 16 |
CHECK_PERSON_ID = "604730"
|
| 17 |
-
|
| 18 |
HEADERS = {
|
| 19 |
"accept": "application/json",
|
| 20 |
"accept-language": "ja",
|
|
@@ -51,6 +51,19 @@ INVITE_GROUPS = [
|
|
| 51 |
]
|
| 52 |
|
| 53 |
# ===== API =====
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
def get_messages() -> List[Dict[str, Any]]:
|
| 55 |
url = f"{BASE}/groups/{GROUP_ID}/messages"
|
| 56 |
r = requests.get(url, headers=HEADERS, params=GET_PARAMS, timeout=20)
|
|
@@ -115,11 +128,17 @@ def process():
|
|
| 115 |
log = m.get("log") or {}
|
| 116 |
if log.get("action") != "join":
|
| 117 |
continue
|
| 118 |
-
|
| 119 |
created_at = int(m.get("createdAt", 0))
|
| 120 |
person_id = str(m.get("personId", ""))
|
| 121 |
-
|
| 122 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 123 |
if created_at > latest_599642:
|
| 124 |
join_targets.append(person_id)
|
| 125 |
|
|
|
|
| 14 |
BASE = "https://desk-api.channel.io/desk/channels/200605"
|
| 15 |
GROUP_ID = 463667
|
| 16 |
CHECK_PERSON_ID = "604730"
|
| 17 |
+
BLACKLIST_CHAT_IDS = ["463667", "481108"]
|
| 18 |
HEADERS = {
|
| 19 |
"accept": "application/json",
|
| 20 |
"accept-language": "ja",
|
|
|
|
| 51 |
]
|
| 52 |
|
| 53 |
# ===== API =====
|
| 54 |
+
def blacklist_manager(person_id: str) -> None:
|
| 55 |
+
url = f"https://desk-api.channel.io/desk/channels/200605/managers/{person_id}"
|
| 56 |
+
|
| 57 |
+
# OPTIONS
|
| 58 |
+
opt = requests.options(url, headers=HEADERS, timeout=20)
|
| 59 |
+
opt.raise_for_status()
|
| 60 |
+
|
| 61 |
+
# DELETE
|
| 62 |
+
delete = requests.delete(url, headers=HEADERS, timeout=20)
|
| 63 |
+
delete.raise_for_status()
|
| 64 |
+
|
| 65 |
+
print(f"[INFO] personId={person_id} をブラックリスト処理しました")
|
| 66 |
+
|
| 67 |
def get_messages() -> List[Dict[str, Any]]:
|
| 68 |
url = f"{BASE}/groups/{GROUP_ID}/messages"
|
| 69 |
r = requests.get(url, headers=HEADERS, params=GET_PARAMS, timeout=20)
|
|
|
|
| 128 |
log = m.get("log") or {}
|
| 129 |
if log.get("action") != "join":
|
| 130 |
continue
|
| 131 |
+
|
| 132 |
created_at = int(m.get("createdAt", 0))
|
| 133 |
person_id = str(m.get("personId", ""))
|
| 134 |
+
chat_id = str(m.get("chatId", ""))
|
| 135 |
+
|
| 136 |
+
# ===== ブラックリスト判定 =====
|
| 137 |
+
if chat_id in BLACKLIST_CHAT_IDS:
|
| 138 |
+
blacklist_manager(person_id)
|
| 139 |
+
continue
|
| 140 |
+
|
| 141 |
+
# ===== 通常処理 =====
|
| 142 |
if created_at > latest_599642:
|
| 143 |
join_targets.append(person_id)
|
| 144 |
|