Skip to content

Commit

Permalink
Add method for chat.getMentionedMessages
Browse files Browse the repository at this point in the history
  • Loading branch information
jadolg authored Oct 4, 2024
1 parent 3d79e93 commit f8a2358
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
8 changes: 8 additions & 0 deletions rocketchat_API/APISections/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,11 @@ def chat_get_thread_messages(self, thread_msg_id, **kwargs):
tmid=thread_msg_id,
kwargs=kwargs,
)

def chat_get_mentioned_messages(self, room_id, **kwargs):
"""Get the messages in which you are mentioned (users are mentioned with the @ symbol)."""
return self.call_api_get(
"chat.getMentionedMessages",
roomId=room_id,
kwargs=kwargs,
)
16 changes: 16 additions & 0 deletions tests/test_chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,3 +211,19 @@ def test_chat_get_thread_messages(logged_rocket):
"msg"
) == chat_post_message3.get("message").get("msg")
assert chat_get_thread_messages.get("success")


def test_chat_get_mentioned_messages(logged_rocket):
chat_post_message_with_mention = logged_rocket.chat_post_message(
"hello @user1",
channel="GENERAL",
).json()
assert chat_post_message_with_mention.get("success")

chat_get_mentioned_messages = logged_rocket.chat_get_mentioned_messages(
room_id="GENERAL"
).json()
assert chat_get_mentioned_messages.get("success")
assert "messages" in chat_get_mentioned_messages
assert len(chat_get_mentioned_messages.get("messages")) > 0
assert chat_get_mentioned_messages.get("messages")[0].get("msg") == "hello @user1"

0 comments on commit f8a2358

Please sign in to comment.