arcade-slack 0.5.1__tar.gz → 0.5.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {arcade_slack-0.5.1 → arcade_slack-0.5.2}/PKG-INFO +1 -1
- {arcade_slack-0.5.1 → arcade_slack-0.5.2}/arcade_slack/utils.py +34 -25
- {arcade_slack-0.5.1 → arcade_slack-0.5.2}/pyproject.toml +1 -1
- {arcade_slack-0.5.1 → arcade_slack-0.5.2}/.gitignore +0 -0
- {arcade_slack-0.5.1 → arcade_slack-0.5.2}/.pre-commit-config.yaml +0 -0
- {arcade_slack-0.5.1 → arcade_slack-0.5.2}/.ruff.toml +0 -0
- {arcade_slack-0.5.1 → arcade_slack-0.5.2}/LICENSE +0 -0
- {arcade_slack-0.5.1 → arcade_slack-0.5.2}/Makefile +0 -0
- {arcade_slack-0.5.1 → arcade_slack-0.5.2}/arcade_slack/__init__.py +0 -0
- {arcade_slack-0.5.1 → arcade_slack-0.5.2}/arcade_slack/constants.py +0 -0
- {arcade_slack-0.5.1 → arcade_slack-0.5.2}/arcade_slack/conversation_retrieval.py +0 -0
- {arcade_slack-0.5.1 → arcade_slack-0.5.2}/arcade_slack/critics.py +0 -0
- {arcade_slack-0.5.1 → arcade_slack-0.5.2}/arcade_slack/custom_types.py +0 -0
- {arcade_slack-0.5.1 → arcade_slack-0.5.2}/arcade_slack/exceptions.py +0 -0
- {arcade_slack-0.5.1 → arcade_slack-0.5.2}/arcade_slack/message_retrieval.py +0 -0
- {arcade_slack-0.5.1 → arcade_slack-0.5.2}/arcade_slack/models.py +0 -0
- {arcade_slack-0.5.1 → arcade_slack-0.5.2}/arcade_slack/tools/__init__.py +0 -0
- {arcade_slack-0.5.1 → arcade_slack-0.5.2}/arcade_slack/tools/chat.py +0 -0
- {arcade_slack-0.5.1 → arcade_slack-0.5.2}/arcade_slack/tools/users.py +0 -0
- {arcade_slack-0.5.1 → arcade_slack-0.5.2}/arcade_slack/user_retrieval.py +0 -0
- {arcade_slack-0.5.1 → arcade_slack-0.5.2}/conftest.py +0 -0
- {arcade_slack-0.5.1 → arcade_slack-0.5.2}/evals/chat/eval_get_metadata.py +0 -0
- {arcade_slack-0.5.1 → arcade_slack-0.5.2}/evals/chat/eval_get_users_in_conversation.py +0 -0
- {arcade_slack-0.5.1 → arcade_slack-0.5.2}/evals/chat/eval_list_conversations.py +0 -0
- {arcade_slack-0.5.1 → arcade_slack-0.5.2}/evals/chat/messages/eval_get_channel_messages.py +0 -0
- {arcade_slack-0.5.1 → arcade_slack-0.5.2}/evals/chat/messages/eval_get_dm_messages.py +0 -0
- {arcade_slack-0.5.1 → arcade_slack-0.5.2}/evals/chat/messages/eval_get_mpim_messages.py +0 -0
- {arcade_slack-0.5.1 → arcade_slack-0.5.2}/evals/chat/messages/eval_send_messages.py +0 -0
- {arcade_slack-0.5.1 → arcade_slack-0.5.2}/evals/eval_users.py +0 -0
- {arcade_slack-0.5.1 → arcade_slack-0.5.2}/tests/__init__.py +0 -0
- {arcade_slack-0.5.1 → arcade_slack-0.5.2}/tests/test_chat.py +0 -0
- {arcade_slack-0.5.1 → arcade_slack-0.5.2}/tests/test_models.py +0 -0
- {arcade_slack-0.5.1 → arcade_slack-0.5.2}/tests/test_user_retrieval.py +0 -0
- {arcade_slack-0.5.1 → arcade_slack-0.5.2}/tests/test_users.py +0 -0
- {arcade_slack-0.5.1 → arcade_slack-0.5.2}/tests/test_utils.py +0 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import asyncio
|
|
2
2
|
import json
|
|
3
|
+
import logging
|
|
3
4
|
import re
|
|
4
5
|
from collections.abc import Callable, Sequence
|
|
5
6
|
from datetime import datetime, timezone
|
|
@@ -30,6 +31,8 @@ from arcade_slack.models import (
|
|
|
30
31
|
SlackUserList,
|
|
31
32
|
)
|
|
32
33
|
|
|
34
|
+
logger = logging.getLogger(__name__)
|
|
35
|
+
|
|
33
36
|
|
|
34
37
|
def format_users(user_list_response: SlackUserList) -> str:
|
|
35
38
|
"""Format a list of Slack users into a CSV string.
|
|
@@ -535,32 +538,38 @@ async def populate_users_in_messages(auth_token: str, messages: list[dict]) -> l
|
|
|
535
538
|
users_by_id = {user["id"]: {"id": user["id"], "name": user["name"]} for user in users}
|
|
536
539
|
|
|
537
540
|
for message in messages:
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
# Message author
|
|
542
|
-
message["user"] = users_by_id.get(
|
|
543
|
-
message.get("user"), {"id": message["user"], "name": None}
|
|
544
|
-
)
|
|
541
|
+
try:
|
|
542
|
+
if "user" not in message or message.get("type") != "message":
|
|
543
|
+
continue
|
|
545
544
|
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
user = users_by_id.get(user_id, {"id": user_id, "name": None})
|
|
551
|
-
name = user.get("name")
|
|
552
|
-
message["text"] = message["text"].replace(
|
|
553
|
-
f"<@{user_id}>", f"<@{name} (id:{user_id})>" if name else f"<@{user_id}>"
|
|
554
|
-
)
|
|
545
|
+
# Message author
|
|
546
|
+
message["user"] = users_by_id.get(
|
|
547
|
+
message.get("user"), {"id": message["user"], "name": None}
|
|
548
|
+
)
|
|
555
549
|
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
550
|
+
# User mentions in the message text
|
|
551
|
+
text_mentions = re.findall(r"<@([A-Z0-9]+)>", message.get("text", ""))
|
|
552
|
+
for user_id in text_mentions:
|
|
553
|
+
if user_id in users_by_id:
|
|
554
|
+
user = users_by_id.get(user_id, {"id": user_id, "name": None})
|
|
555
|
+
name = user.get("name")
|
|
556
|
+
message["text"] = message["text"].replace(
|
|
557
|
+
f"<@{user_id}>", f"<@{name} (id:{user_id})>" if name else f"<@{user_id}>"
|
|
558
|
+
)
|
|
559
|
+
|
|
560
|
+
# User mentions in reactions
|
|
561
|
+
reactions = message.get("reactions")
|
|
562
|
+
if isinstance(reactions, list):
|
|
563
|
+
for reaction in reactions:
|
|
564
|
+
reaction_users = []
|
|
565
|
+
for user_id in reaction.get("users", []):
|
|
566
|
+
reaction_users.append(
|
|
567
|
+
users_by_id.get(user_id, {"id": user_id, "name": None})
|
|
568
|
+
)
|
|
569
|
+
reaction["users"] = reaction_users
|
|
570
|
+
# If any data is missing, just leave the message as it is
|
|
571
|
+
except Exception as exc:
|
|
572
|
+
logger.exception(exc) # noqa: TRY401
|
|
564
573
|
|
|
565
574
|
return messages
|
|
566
575
|
|
|
@@ -573,7 +582,7 @@ async def get_users_from_messages(auth_token: str, messages: list[dict]) -> list
|
|
|
573
582
|
|
|
574
583
|
user_ids = get_user_ids_from_messages(messages)
|
|
575
584
|
response = await get_users_by_id(auth_token, user_ids)
|
|
576
|
-
|
|
585
|
+
|
|
577
586
|
return response["users"]
|
|
578
587
|
|
|
579
588
|
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "arcade_slack"
|
|
7
|
-
version = "0.5.
|
|
7
|
+
version = "0.5.2"
|
|
8
8
|
description = "Arcade.dev LLM tools for Slack"
|
|
9
9
|
requires-python = ">=3.10"
|
|
10
10
|
dependencies = [ "aiodns>=1.0,<2.0.0", "typing; python_version < '3.7'", "aiohttp>=3.7.3,<4.0.0", "arcade-tdk>=2.0.0,<3.0.0", "slack-sdk>=3.31.0,<4.0.0",]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|