Spaces:
Running
Running
Update join.py
Browse files
join.py
CHANGED
|
@@ -55,6 +55,19 @@ def get_messages() -> List[Dict[str, Any]]:
|
|
| 55 |
r.raise_for_status()
|
| 56 |
return r.json().get("messages", [])
|
| 57 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
|
| 59 |
def post_welcome_message() -> None:
|
| 60 |
TITLES = get_group_titles() # {group_id: title}
|
|
|
|
| 55 |
r.raise_for_status()
|
| 56 |
return r.json().get("messages", [])
|
| 57 |
|
| 58 |
+
def get_group_titles() -> dict[int, str]:
|
| 59 |
+
url = "https://desk-api.channel.io/desk/channels/200605/groups?limit=1000"
|
| 60 |
+
response = requests.get(url)
|
| 61 |
+
response.raise_for_status()
|
| 62 |
+
|
| 63 |
+
data = response.json()
|
| 64 |
+
groups = data.get("groups", [])
|
| 65 |
+
|
| 66 |
+
return {
|
| 67 |
+
group.get("id"): group.get("title")
|
| 68 |
+
for group in groups
|
| 69 |
+
if "id" in group and "title" in group
|
| 70 |
+
}
|
| 71 |
|
| 72 |
def post_welcome_message() -> None:
|
| 73 |
TITLES = get_group_titles() # {group_id: title}
|