Spaces:
Running
Running
Update join.py
Browse files
join.py
CHANGED
|
@@ -13,10 +13,7 @@ if not X_ACCOUNT:
|
|
| 13 |
|
| 14 |
BASE = "https://desk-api.channel.io/desk/channels/200605"
|
| 15 |
GROUP_ID = 463667
|
| 16 |
-
CHECK_PERSON_ID = "
|
| 17 |
-
# ===== ブラックリスト設定 =====
|
| 18 |
-
BLACKLIST_CHAT_IDS = ["463667", "481108"] #481108:テスト用 463667:あいつ
|
| 19 |
-
MANAGER_BASE = "https://desk-api.channel.io/desk/channels/200605/managers"
|
| 20 |
|
| 21 |
HEADERS = {
|
| 22 |
"accept": "application/json",
|
|
@@ -99,36 +96,16 @@ def invite_person(group_id: int, person_id: str) -> None:
|
|
| 99 |
requests.post(url, headers=HEADERS, params=params, timeout=20).raise_for_status()
|
| 100 |
print(f"[INFO] personId={person_id} を group {group_id} に招待しました")
|
| 101 |
|
| 102 |
-
def delete_manager(person_id: str) -> None:
|
| 103 |
-
url = f"{MANAGER_BASE}/{person_id}"
|
| 104 |
|
| 105 |
-
# OPTIONS を送信
|
| 106 |
-
opt = requests.options(url, headers=HEADERS, timeout=20)
|
| 107 |
-
opt.raise_for_status()
|
| 108 |
-
|
| 109 |
-
# DELETE を送信
|
| 110 |
-
delete = requests.delete(url, headers=HEADERS, timeout=20)
|
| 111 |
-
delete.raise_for_status()
|
| 112 |
-
|
| 113 |
-
print(f"[INFO] ブラックリスト対象 personId={person_id} を削除しました")
|
| 114 |
# ===== ロジック =====
|
| 115 |
def process():
|
| 116 |
messages = get_messages()
|
| 117 |
-
for m in messages:
|
| 118 |
-
chat_id = str(m.get("chatId", ""))
|
| 119 |
-
person_id = str(m.get("personId", ""))
|
| 120 |
-
|
| 121 |
-
if chat_id in BLACKLIST_CHAT_IDS and person_id:
|
| 122 |
-
try:
|
| 123 |
-
delete_manager(person_id)
|
| 124 |
-
except Exception as e:
|
| 125 |
-
print(f"[ERROR] ブラックリスト削除失敗: {e}")
|
| 126 |
|
| 127 |
# personId=599642 の最新発言時刻
|
| 128 |
latest_599642 = max(
|
| 129 |
(int(m.get("createdAt", 0))
|
| 130 |
for m in messages
|
| 131 |
-
if str(m.get("
|
| 132 |
default=0
|
| 133 |
)
|
| 134 |
|
|
|
|
| 13 |
|
| 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",
|
|
|
|
| 96 |
requests.post(url, headers=HEADERS, params=params, timeout=20).raise_for_status()
|
| 97 |
print(f"[INFO] personId={person_id} を group {group_id} に招待しました")
|
| 98 |
|
|
|
|
|
|
|
| 99 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 100 |
# ===== ロジック =====
|
| 101 |
def process():
|
| 102 |
messages = get_messages()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 103 |
|
| 104 |
# personId=599642 の最新発言時刻
|
| 105 |
latest_599642 = max(
|
| 106 |
(int(m.get("createdAt", 0))
|
| 107 |
for m in messages
|
| 108 |
+
if str(m.get("personId")) == CHECK_PERSON_ID),
|
| 109 |
default=0
|
| 110 |
)
|
| 111 |
|