Skip to content

[IMSERVER-20666] add new thread methods to botAPI #51

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions bot/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,48 @@ 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):
if page_size is None and cursor is None:
raise Exception("pageSize or cursor must be provided")
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"):
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={
"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):
Expand Down