From f8a2358cdfe277633ca446518f34ecc50ee4fde1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Alberto=20D=C3=ADaz=20Orozco=20=28Akiel=29?= Date: Fri, 4 Oct 2024 10:45:45 +0000 Subject: [PATCH] Add method for chat.getMentionedMessages --- rocketchat_API/APISections/chat.py | 8 ++++++++ tests/test_chat.py | 16 ++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/rocketchat_API/APISections/chat.py b/rocketchat_API/APISections/chat.py index b974bad..1df28c0 100644 --- a/rocketchat_API/APISections/chat.py +++ b/rocketchat_API/APISections/chat.py @@ -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, + ) diff --git a/tests/test_chat.py b/tests/test_chat.py index 492263a..4f32897 100644 --- a/tests/test_chat.py +++ b/tests/test_chat.py @@ -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"