Skip to content

Commit 1da33b2

Browse files
authored
Merge pull request #55 from dmitriichernyshov/new-thread-methods
add new thread methods for bots
2 parents db4fd93 + 3f7dd31 commit 1da33b2

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

bot/bot.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,48 @@ def delete_chat_members(self, chat_id, members):
570570
"members": json.dumps([{"sn": m} for m in members])
571571
}
572572
)
573+
574+
def threads_get_subscribers(self, thread_id, page_size=None, cursor=None):
575+
if page_size is None and cursor is None:
576+
raise Exception("pageSize or cursor must be provided")
577+
params={
578+
"token": self.token,
579+
"threadId": thread_id,
580+
}
581+
if page_size:
582+
params["pageSize"]=page_size
583+
if cursor:
584+
params["cursor"]=cursor
585+
586+
return self.http_session.get(
587+
url="{}/threads/subscribers/get".format(self.api_base_url),
588+
params=params
589+
)
590+
591+
def threads_autosubscribe(self, chat_id, enable, with_existing="false"):
592+
if isinstance(enable, bool):
593+
enable = "true" if enable else "false"
594+
if isinstance(with_existing, bool):
595+
with_existing = "true" if with_existing else "false"
596+
return self.http_session.get(
597+
url="{}/threads/autosubscribe".format(self.api_base_url),
598+
params={
599+
"token": self.token,
600+
"chatId": chat_id,
601+
"enable": enable,
602+
"withExisting": with_existing
603+
}
604+
)
605+
606+
def threads_add(self, chat_id, msg_id):
607+
return self.http_session.get(
608+
url="{}/threads/add".format(self.api_base_url),
609+
params={
610+
"token": self.token,
611+
"chatId": chat_id,
612+
"msgId": msg_id
613+
}
614+
)
573615

574616

575617
class LoggingHTTPAdapter(HTTPAdapter):

0 commit comments

Comments
 (0)