From 571eea0596dba27bd3aa4341077823b3dfdc1bad Mon Sep 17 00:00:00 2001 From: dmitrii chernyshov Date: Thu, 17 Jul 2025 09:57:04 +0300 Subject: [PATCH 1/3] [IMSERVER-20666] add new thread methods to botAPI --- bot/bot.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/bot/bot.py b/bot/bot.py index 59a7887..5dffefd 100644 --- a/bot/bot.py +++ b/bot/bot.py @@ -570,6 +570,42 @@ def delete_chat_members(self, chat_id, members): "members": json.dumps([{"sn": m} for m in members]) } ) + + def threads_get_subscribers(self, thread_id, page_size=None, cursor=None): + params={ + "token": self.token, + "threadId": thread_id, + } + if page_size: + params["pageSize"]=page_size + if cursor: + params["cursor"]=cursor + + return self.http_session.get( + url="{}/threads/subscribers/get".format(self.api_base_url), + params=params + ) + + def threads_autosubscribe(self, chat_id, enable, with_existing="false"): + return self.http_session.get( + url="{}/threads/autosubscribe".format(self.api_base_url), + params={ + "token": self.token, + "chatId": chat_id, + "enable": enable, + "withExisting": with_existing + } + ) + + def threads_add(self, chat_id, msg_id): + return self.http_session.get( + url="{}/threads/add".format(self.api_base_url), + params={ + "token": self.token, + "chatId": chat_id, + "msgId": msg_id + } + ) class LoggingHTTPAdapter(HTTPAdapter): From fce4287420c7dfa89cbfb0ed5b89e1da754667d6 Mon Sep 17 00:00:00 2001 From: dmitrii chernyshov Date: Wed, 23 Jul 2025 16:39:47 +0300 Subject: [PATCH 2/3] [IMSERVER-20666] add pageSize and cursor check to threads_get_subscribers() --- bot/bot.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bot/bot.py b/bot/bot.py index 5dffefd..a6663cd 100644 --- a/bot/bot.py +++ b/bot/bot.py @@ -572,6 +572,8 @@ def delete_chat_members(self, chat_id, members): ) def threads_get_subscribers(self, thread_id, page_size=None, cursor=None): + if page_size is None and cursor is None: + raise Exception("pageSize or cursor must be provided") params={ "token": self.token, "threadId": thread_id, From 80231d3d4e40a5fecc9676c6c6c9a92ca49fc224 Mon Sep 17 00:00:00 2001 From: dmitrii chernyshov Date: Fri, 25 Jul 2025 09:51:43 +0300 Subject: [PATCH 3/3] [IMSERVER-20666] add bool to str convertion in threads_autosubscribe() --- bot/bot.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bot/bot.py b/bot/bot.py index a6663cd..0a6cf6d 100644 --- a/bot/bot.py +++ b/bot/bot.py @@ -589,6 +589,10 @@ def threads_get_subscribers(self, thread_id, page_size=None, cursor=None): ) def threads_autosubscribe(self, chat_id, enable, with_existing="false"): + if isinstance(enable, bool): + enable = "true" if enable else "false" + if isinstance(with_existing, bool): + with_existing = "true" if with_existing else "false" return self.http_session.get( url="{}/threads/autosubscribe".format(self.api_base_url), params={