MaxApi¶
MaxApi — асинхронный высокоуровневый клиент. Он владеет выбранным backend-стеком и предоставляет операции для сообщений, чатов, реакций, опросов, групп, контактов, профиля, папок, сессий, presence и двухфакторной авторизации.
Bases: AsyncInitializerMixin, FullMixin
Asynchronous client for MAX Messenger.
The client initializes a transport, protocol, and mapper from the project registry. Initialization is asynchronous and requires the selected backend names to be available in the corresponding registries.
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If a transport, protocol, or mapper name is not supported. |
Initialize the max api.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
device_type
|
str
|
Device type reported to the API. |
'WEB'
|
password
|
str | None
|
Optional account password. |
None
|
token
|
str | None
|
Optional auth token. |
None
|
transport
|
BaseTransport | None
|
Transport backend name. |
None
|
protocol
|
BaseMaxProtocol[Any, Any] | None
|
Protocol backend name. |
None
|
mapper
|
BaseMapper[Any, Any] | None
|
Mapper backend name. |
None
|
transport_options
|
dict[str, Any] | None
|
Keyword arguments passed to the transport constructor. |
None
|
kwargs
|
Any
|
Extra keyword arguments passed to mapper initialization. |
{}
|
workflow_data
|
dict[Any, Any] | None
|
dict[Any, Any] global workflow data. |
None
|
user_agent_params
|
dict[str, Any] | None
|
dict[str, Any] params of user agent. |
required |
auth_middleware_manager
|
AuthMiddlewareManager | None
|
AuthMiddlewareManager instance of auth middleware manager. |
None
|
registration_config
|
RegistrationConfig | None
|
instance of RegistrationConfig for register account. |
None
|
token_suffix
|
str | None
|
The token suffix value. |
None
|
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If transport or protocol or mapper cannot be None. |
Source code in src/pyromax/core/client.py
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 | |
_async_init
async
¶
_async_init(
device_type: str = "WEB",
password: str | None = None,
token: str | None = None,
transport: str = "websocket",
protocol: str = "EnvelopeProtocol",
mapper: str = "EnvelopeV11",
transport_options: dict[str, Any] | None = None,
workflow_data: dict[Any, Any] | None = None,
user_agent_params: dict[str, Any] | None = None,
auth_middleware_manager: (
AuthMiddlewareManager | None
) = None,
registration_config: RegistrationConfig | None = None,
token_suffix: str | None = None,
**kwargs: Any
) -> None
Asynchronously initialize transport, protocol, and mapper.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
device_type
|
str
|
Device type reported to the API. |
'WEB'
|
password
|
str | None
|
Optional account password. |
None
|
token
|
str | None
|
Optional auth token. |
None
|
transport
|
str
|
Transport backend name. |
'websocket'
|
protocol
|
str
|
Protocol backend name. |
'EnvelopeProtocol'
|
mapper
|
str
|
Mapper backend name. |
'EnvelopeV11'
|
transport_options
|
dict[str, Any] | None
|
Keyword arguments passed to the transport constructor. |
None
|
kwargs
|
Any
|
Extra keyword arguments passed to mapper initialization. |
{}
|
workflow_data
|
dict[Any, Any] | None
|
dict[Any, Any] global workflow data. |
None
|
user_agent_params
|
dict[str, Any] | None
|
dict[str, Any] params of user agent. |
None
|
auth_middleware_manager
|
AuthMiddlewareManager | None
|
AuthMiddlewareManager instance of auth middleware manager. |
None
|
registration_config
|
RegistrationConfig | None
|
instance of RegistrationConfig for register account. |
None
|
token_suffix
|
str | None
|
The token suffix value. |
None
|
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If transport or protocol or mapper cannot be None. |
Source code in src/pyromax/core/client.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 | |
__call__
async
¶
__call__(
class_of_method: type[BaseMaxApiMethod[Any]],
*args: Any,
**kwargs: Any
) -> Any
Invoke the max api.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
class_of_method
|
type[BaseMaxApiMethod[Any]]
|
MAX API method class to instantiate and execute. |
required |
args
|
Any
|
Positional arguments forwarded to the wrapped callable. |
()
|
kwargs
|
Any
|
Keyword arguments forwarded to the wrapped callable. |
{}
|
Returns:
| Type | Description |
|---|---|
Any
|
The value returned by the wrapped callable or backend. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If try a call method before initialization, because logger has not been initialized. |
Source code in src/pyromax/core/client.py
276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 | |
listen_updates ¶
listen_updates(
context: Any,
) -> tuple[
Callable[[Response], MaxObject],
AsyncGenerator[Response, None],
]
Yield incoming updates forever.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
Any
|
Runtime context passed to the mapper. |
required |
Returns:
| Type | Description |
|---|---|
tuple[Callable[[Response], MaxObject], AsyncGenerator[Response, None]]
|
Stream of incoming updates. |
Source code in src/pyromax/core/client.py
300 301 302 303 304 305 306 307 308 309 310 311 | |
get_members_by_ids
async
¶
get_members_by_ids(
member_ids: list[int],
) -> Sequence[Contact]
Retrieve members by ids.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
member_ids
|
list[int]
|
Identifiers of the members. |
required |
Returns:
| Type | Description |
|---|---|
Sequence[Contact]
|
The Contacts collection. |
Source code in src/pyromax/core/CoreMixins/Contacts.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | |
get_member_by_id
async
¶
get_member_by_id(member_id: int) -> Contact | None
Retrieve member by id.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
member_id
|
int
|
Identifier of the member. |
required |
Returns:
| Type | Description |
|---|---|
Contact | None
|
The resulting Contact | None. |
Source code in src/pyromax/core/CoreMixins/Contacts.py
42 43 44 45 46 47 48 49 50 51 | |
get_users
async
¶
get_users(user_ids: list[int]) -> list[Contact]
Retrieve users.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user_ids
|
list[int]
|
Identifiers of the users. |
required |
Returns:
| Type | Description |
|---|---|
list[Contact]
|
The resulting collection. |
Source code in src/pyromax/core/CoreMixins/Contacts.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | |
get_user
async
¶
get_user(user_id: int) -> Contact | None
Retrieve user.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user_id
|
int
|
Identifier of the user. |
required |
Returns:
| Type | Description |
|---|---|
Contact | None
|
The resulting Contact | None. |
Source code in src/pyromax/core/CoreMixins/Contacts.py
71 72 73 74 75 76 77 78 79 80 | |
search_by_phone
async
¶
search_by_phone(phone: str) -> Contact
Search for by phone.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
phone
|
str
|
Phone number in the format accepted by MAX. |
required |
Returns:
| Type | Description |
|---|---|
Contact
|
The resulting Contact. |
Source code in src/pyromax/core/CoreMixins/Contacts.py
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | |
get_sessions
async
¶
get_sessions() -> list[Session]
Retrieve sessions.
Returns:
| Type | Description |
|---|---|
list[Session]
|
The Sessions collection. |
Source code in src/pyromax/core/CoreMixins/Contacts.py
100 101 102 103 104 105 106 107 | |
get_chat_id
async
¶
get_chat_id(first_user_id: int, second_user_id: int) -> int
Retrieve chat id.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
first_user_id
|
int
|
Identifier of the first user. |
required |
second_user_id
|
int
|
Identifier of the second user. |
required |
Returns:
| Type | Description |
|---|---|
int
|
The resulting int value. |
Source code in src/pyromax/core/CoreMixins/Contacts.py
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | |
add_contact
async
¶
add_contact(contact_id: int) -> Contact
Add contact.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
contact_id
|
int
|
Identifier of the contact. |
required |
Returns:
| Type | Description |
|---|---|
Contact
|
The resulting Contact. |
Source code in src/pyromax/core/CoreMixins/Contacts.py
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | |
remove_contact
async
¶
remove_contact(contact_id: int) -> None
Remove contact.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
contact_id
|
int
|
Identifier of the contact. |
required |
Source code in src/pyromax/core/CoreMixins/Contacts.py
145 146 147 148 149 150 151 152 153 154 155 156 157 | |
import_contacts
async
¶
import_contacts(
contacts: list[ContactInfo],
) -> list[Contact]
Import contacts.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
contacts
|
list[ContactInfo]
|
Collection of contacts. |
required |
Returns:
| Type | Description |
|---|---|
list[Contact]
|
The Contacts collection. |
Source code in src/pyromax/core/CoreMixins/Contacts.py
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 | |
download_file
async
¶
download_file(
file: BaseFileAttachment,
) -> tuple[bytes, dict[str, str]] | tuple[None, None]
Download file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file
|
BaseFileAttachment
|
File attachment to process. |
required |
Returns:
| Type | Description |
|---|---|
tuple[bytes, dict[str, str]] | tuple[None, None]
|
The resulting tuple[bytes, dict[str, str]] | tuple[None, None] value is request headers | None semantic. |
Source code in src/pyromax/core/CoreMixins/File.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | |
upload_file
async
¶
upload_file(
data: bytes | None,
typeof: type[BaseFileAttachment],
**kwargs: Any
) -> list[BaseFileAttachment | Any]
Upload file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
bytes | None
|
Contextual data passed through the processing pipeline. |
required |
typeof
|
type[BaseFileAttachment]
|
Attachment class that determines the upload type. |
required |
kwargs
|
Any
|
Keyword arguments forwarded to the wrapped callable. |
{}
|
Returns:
| Type | Description |
|---|---|
list[BaseFileAttachment | Any]
|
The resulting collection. |
Source code in src/pyromax/core/CoreMixins/File.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | |
change_profile
async
¶
change_profile(
first_name: str,
last_name: str | None = None,
description: str | None = None,
photo: bytes | None = None,
file_name: str | None = None,
photo_token: str | None = None,
) -> Profile
Change profile.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
first_name
|
str
|
The first name. |
required |
last_name
|
str | None
|
The last name. |
None
|
description
|
str | None
|
The description. |
None
|
photo
|
bytes | None
|
The photo data. |
None
|
file_name
|
str | None
|
The file name or photo file. |
None
|
photo_token
|
str | None
|
The photo token value. |
None
|
Returns:
| Type | Description |
|---|---|
Profile
|
The resulting Profile. |
Source code in src/pyromax/core/CoreMixins/User.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | |
create_folder
async
¶
create_folder(
title: str,
chat_include: list[int],
filters: list[Any] | None = None,
folder_id: str | None = None,
) -> FolderUpdate
Create folder.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
title
|
str
|
The title of folder. |
required |
chat_include
|
list[int]
|
Collection of chat include. |
required |
filters
|
list[Any] | None
|
Collection of filters. |
None
|
folder_id
|
str | None
|
Identifier of the folder. |
None
|
Returns:
| Type | Description |
|---|---|
FolderUpdate
|
The resulting FolderUpdate. |
Source code in src/pyromax/core/CoreMixins/User.py
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | |
get_folders
async
¶
get_folders(folder_sync: int = 0) -> FolderList
Retrieve folders.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
folder_sync
|
int
|
Synchronization marker. Leave as |
0
|
Returns:
| Type | Description |
|---|---|
FolderList
|
The resulting FolderList. |
Source code in src/pyromax/core/CoreMixins/User.py
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | |
update_folder
async
¶
update_folder(
folder_id: str,
title: str,
chat_include: list[int] | None = None,
filters: list[Any] | None = None,
options: list[Any] | None = None,
) -> FolderUpdate
Update folder.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
folder_id
|
str
|
Identifier of the folder. |
required |
title
|
str
|
The title of folder. |
required |
chat_include
|
list[int] | None
|
Collection of chat include. |
None
|
filters
|
list[Any] | None
|
Collection of filters. |
None
|
options
|
list[Any] | None
|
Collection of options. |
None
|
Returns:
| Type | Description |
|---|---|
FolderUpdate
|
The resulting FolderUpdate. |
Source code in src/pyromax/core/CoreMixins/User.py
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 | |
delete_folders
async
¶
delete_folders(folder_ids: list[str]) -> FolderUpdate
Delete folders.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
folder_ids
|
list[str]
|
Identifiers of the folders. |
required |
Returns:
| Type | Description |
|---|---|
FolderUpdate
|
The resulting FolderUpdate. |
Source code in src/pyromax/core/CoreMixins/User.py
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | |
delete_folder
async
¶
delete_folder(folder_id: str) -> FolderUpdate
Delete folder.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
folder_id
|
str
|
Identifier of the folder. |
required |
Returns:
| Type | Description |
|---|---|
FolderUpdate
|
The resulting FolderUpdate. |
Source code in src/pyromax/core/CoreMixins/User.py
171 172 173 174 175 176 177 178 179 | |
close_all_sessions
async
¶
close_all_sessions() -> bool
Close all sessions.
Returns:
| Type | Description |
|---|---|
bool
|
|
Source code in src/pyromax/core/CoreMixins/User.py
181 182 183 184 185 186 187 188 189 190 191 192 | |
logout
async
¶
logout() -> None
Logout.
Source code in src/pyromax/core/CoreMixins/User.py
194 195 196 | |
set_presence
async
¶
set_presence(online: bool) -> None
Set presence.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
online
|
bool
|
The online value. |
required |
Source code in src/pyromax/core/CoreMixins/User.py
198 199 200 201 202 203 204 205 206 207 208 209 210 | |
change_profile_settings
async
¶
change_profile_settings(
privacy_settings: PrivacySettings,
) -> None
Update the account privacy settings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
privacy_settings
|
PrivacySettings
|
Privacy settings to apply to the account. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If updating the privacy settings fails. |
Source code in src/pyromax/core/CoreMixins/User.py
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 | |
create_group
async
¶
create_group(
title: str,
participant_ids: list[int] | None = None,
notify: bool = True,
chat_type: str = "CHAT",
event: str = "new",
typeof: str = "CONTROL",
) -> tuple[Chat, Message] | tuple[None, None]
Create group.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
title
|
str
|
The title value. |
required |
participant_ids
|
list[int] | None
|
Identifiers of the participant objects. |
None
|
notify
|
bool
|
Whether MAX should notify affected users. |
True
|
chat_type
|
str
|
The chat type value. |
'CHAT'
|
event
|
str
|
Incoming event to process. |
'new'
|
typeof
|
str
|
Attachment class that determines the upload type. |
'CONTROL'
|
Returns:
| Type | Description |
|---|---|
tuple[Chat, Message] | tuple[None, None]
|
The resulting tuple[Chat, Message] | tuple[None, None] value. |
Source code in src/pyromax/core/CoreMixins/Chat.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | |
invite_users_to_group
async
¶
invite_users_to_group(
chat_id: int,
user_ids: list[int],
show_history: bool = True,
) -> Chat | None
Invite users to group.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chat_id
|
int
|
Identifier of the chat. |
required |
user_ids
|
list[int]
|
Identifiers of the users. |
required |
show_history
|
bool
|
Show message history to new members. |
True
|
Returns:
| Type | Description |
|---|---|
Chat | None
|
The resulting Chat | None value. |
Source code in src/pyromax/core/CoreMixins/Chat.py
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | |
remove_users_from_group
async
¶
remove_users_from_group(
chat_id: int,
user_ids: list[int] | list[str],
clean_msg_period: int,
) -> Chat | None
Remove users from group.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chat_id
|
int
|
Identifier of the chat. |
required |
user_ids
|
list[int] | list[str]
|
Identifiers of the users. |
required |
clean_msg_period
|
int
|
Cleanup period for messages from removed participants. |
required |
Returns:
| Type | Description |
|---|---|
Chat | None
|
The resulting Chat | None value. |
Source code in src/pyromax/core/CoreMixins/Chat.py
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | |
change_group_settings
async
¶
change_group_settings(
chat_id: int,
all_can_pin_message: bool | None = None,
only_owner_can_change_icon_title: bool | None = None,
only_admin_can_add_member: bool | None = None,
only_admin_can_call: bool | None = None,
members_can_see_private_link: bool | None = None,
) -> Chat | None
Change group settings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chat_id
|
int
|
Identifier of the chat. |
required |
all_can_pin_message
|
bool | None
|
All participants can pin messages. |
None
|
only_owner_can_change_icon_title
|
bool | None
|
The only owner can change icon title. |
None
|
only_admin_can_add_member
|
bool | None
|
The only admin can add member. |
None
|
only_admin_can_call
|
bool | None
|
The only admin can call. |
None
|
members_can_see_private_link
|
bool | None
|
The members can see private link. |
None
|
Returns:
| Type | Description |
|---|---|
Chat | None
|
The resulting Chat | None value. |
Source code in src/pyromax/core/CoreMixins/Chat.py
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 | |
change_group_profile
async
¶
change_group_profile(
chat_id: int,
name: str | None = None,
description: str | None = None,
) -> Chat | None
Change group profile.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chat_id
|
int
|
Identifier of the chat. |
required |
name
|
str | None
|
The name of the chat. |
None
|
description
|
str | None
|
The description of the chat. |
None
|
Returns:
| Type | Description |
|---|---|
Chat | None
|
The resulting Chat | None value. |
Source code in src/pyromax/core/CoreMixins/Chat.py
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 | |
join_group
async
¶
join_group(link: str) -> Chat
Join group.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
link
|
str
|
Invite group link. |
required |
Returns:
| Type | Description |
|---|---|
Chat
|
The resulting Chat value. |
Source code in src/pyromax/core/CoreMixins/Chat.py
198 199 200 201 202 203 204 205 206 207 208 209 210 | |
join_channel
async
¶
join_channel(link: str) -> Chat
Join channel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
link
|
str
|
Invite channel link. |
required |
Returns:
| Type | Description |
|---|---|
Chat
|
The resulting Chat value. |
Source code in src/pyromax/core/CoreMixins/Chat.py
212 213 214 215 216 217 218 219 220 221 222 223 224 | |
resolve_group_by_link
async
¶
resolve_group_by_link(link: str) -> Chat | None
Resolve group by link.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
link
|
str
|
Invite group link. |
required |
Returns:
| Type | Description |
|---|---|
Chat | None
|
The resulting Chat | None value. |
Source code in src/pyromax/core/CoreMixins/Chat.py
226 227 228 229 230 231 232 233 234 235 236 237 238 | |
revoke_invite_link
async
¶
revoke_invite_link(chat_id: int) -> Chat
Revoke invite link.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chat_id
|
int
|
Identifier of the chat. |
required |
Returns:
| Type | Description |
|---|---|
Chat
|
The resulting Chat value. |
Source code in src/pyromax/core/CoreMixins/Chat.py
240 241 242 243 244 245 246 247 248 249 250 251 252 | |
get_chats
async
¶
get_chats(chat_ids: Iterable[int]) -> list[Chat]
Retrieve chats.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chat_ids
|
Iterable[int]
|
Identifiers of the chats. |
required |
Returns:
| Type | Description |
|---|---|
list[Chat]
|
The collection from gotten chats. |
Source code in src/pyromax/core/CoreMixins/Chat.py
254 255 256 257 258 259 260 261 262 263 264 265 266 | |
get_chat
async
¶
get_chat(chat_id: int) -> Chat
Retrieve chat.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chat_id
|
int
|
Identifier of the chat. |
required |
Returns:
| Type | Description |
|---|---|
Chat
|
The resulting Chat value. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If chat not found. |
Source code in src/pyromax/core/CoreMixins/Chat.py
268 269 270 271 272 273 274 275 276 277 278 279 280 | |
leave_group
async
¶
leave_group(chat_id: int) -> Message | None
Leave group.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chat_id
|
int
|
Identifier of the chat. |
required |
Returns:
| Type | Description |
|---|---|
Message | None
|
The resulting Message | None value. |
Source code in src/pyromax/core/CoreMixins/Chat.py
282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 | |
leave_channel
async
¶
leave_channel(chat_id: int) -> Message | None
Leave channel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chat_id
|
int
|
Identifier of the chat. |
required |
Returns:
| Type | Description |
|---|---|
Message | None
|
The resulting Message | None value. |
Source code in src/pyromax/core/CoreMixins/Chat.py
299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 | |
fetch_chats
async
¶
fetch_chats(marker: int | None = None) -> list[Chat]
Fetch chats.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
marker
|
int | None
|
Pagination marker in milliseconds. If |
None
|
Returns:
| Type | Description |
|---|---|
list[Chat]
|
The resulting Chats collection. |
Source code in src/pyromax/core/CoreMixins/Chat.py
316 317 318 319 320 321 322 323 324 325 326 327 328 | |
get_join_requests
async
¶
get_join_requests(
chat_id: int, count: int = 100
) -> list[Member]
Retrieve join requests.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chat_id
|
int
|
Identifier of the chat. |
required |
count
|
int
|
Maximum number of items to retrieve. |
100
|
Returns:
| Type | Description |
|---|---|
list[Member]
|
The resulting Members collection. |
Source code in src/pyromax/core/CoreMixins/Chat.py
330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 | |
confirm_join_requests
async
¶
confirm_join_requests(
chat_id: int,
user_ids: Iterable[int],
show_history: bool = True,
) -> Chat | None
Confirm join requests.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chat_id
|
int
|
Identifier of the chat. |
required |
user_ids
|
Iterable[int]
|
Identifiers of the users. |
required |
show_history
|
bool
|
Show message history to new members. |
True
|
Returns:
| Type | Description |
|---|---|
Chat | None
|
The resulting Chat | None value. |
Source code in src/pyromax/core/CoreMixins/Chat.py
350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 | |
confirm_join_request
async
¶
confirm_join_request(
chat_id: int, user_id: int, show_history: bool = True
) -> Chat | None
Confirm join request.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chat_id
|
int
|
Identifier of the chat. |
required |
user_id
|
int
|
Identifier of the user. |
required |
show_history
|
bool
|
Show message history to new members. |
True
|
Returns:
| Type | Description |
|---|---|
Chat | None
|
The resulting Chat | None value. |
Source code in src/pyromax/core/CoreMixins/Chat.py
378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 | |
decline_join_requests
async
¶
decline_join_requests(
chat_id: int, user_ids: Iterable[int]
) -> Chat | None
Decline join requests.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chat_id
|
int
|
Identifier of the chat. |
required |
user_ids
|
Iterable[int]
|
Identifiers of the users. |
required |
Returns:
| Type | Description |
|---|---|
Chat | None
|
The resulting Chat | None value. |
Source code in src/pyromax/core/CoreMixins/Chat.py
401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 | |
decline_join_request
async
¶
decline_join_request(
chat_id: int, user_id: int
) -> Chat | None
Decline join request.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chat_id
|
int
|
Identifier of the chat. |
required |
user_id
|
int
|
Identifier of the user. |
required |
Returns:
| Type | Description |
|---|---|
Chat | None
|
The resulting Chat | None value. |
Source code in src/pyromax/core/CoreMixins/Chat.py
425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 | |
delete_chat
async
¶
delete_chat(
chat_id: int,
last_event_time: int | None = None,
for_all: bool = True,
) -> None
Delete chat.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chat_id
|
int
|
Identifier of the chat. |
required |
last_event_time
|
int | None
|
The last event time value. |
None
|
for_all
|
bool
|
Delete only for the current account. |
True
|
Source code in src/pyromax/core/CoreMixins/Chat.py
444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 | |
add_admin
async
¶
add_admin(
chat_id: int,
user_id: int,
permissions: Iterable[ChannelPermissions],
) -> None
Add admin.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chat_id
|
int
|
Identifier of the chat. |
required |
user_id
|
int
|
Identifier of the user. |
required |
permissions
|
Iterable[ChannelPermissions]
|
Collection of permissions. |
required |
Source code in src/pyromax/core/CoreMixins/Chat.py
469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 | |
send_message
async
¶
send_message(
chat_id: int,
text: str = "",
attaches: list[BaseFileAttachment] | None = None,
link: MessageLink | None = None,
notify: bool = True,
) -> Message | None
Send a message to a chat.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chat_id
|
int
|
Target chat identifier. |
required |
text
|
str
|
Message text. |
''
|
attaches
|
list[BaseFileAttachment] | None
|
Optional list of attachments. |
None
|
link
|
MessageLink | None
|
Optional message link object. |
None
|
notify
|
bool
|
Whether MAX should notify affected users. |
True
|
Returns:
| Type | Description |
|---|---|
Message | None
|
API response returned by the mapper. |
Raises:
| Type | Description |
|---|---|
SendMessageError
|
If message sending fails. |
AttributeError
|
If logger not initialized in MaxApi instance. |
Source code in src/pyromax/core/CoreMixins/Message.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | |
forward_message
async
¶
forward_message(
message_id: int | str,
to_chat_id: int,
from_chat_id: int,
notify: bool = True,
) -> Message | None
Forward message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message_id
|
int | str
|
Identifier of the message. |
required |
to_chat_id
|
int
|
Identifier of the destination chat. |
required |
from_chat_id
|
int
|
Identifier of the source chat. |
required |
notify
|
bool
|
Whether MAX should notify affected users. |
True
|
Returns:
| Type | Description |
|---|---|
Message | None
|
The resulting Message | None value. |
Raises:
| Type | Description |
|---|---|
AttributeError
|
If logger not initialized in MaxApi instance. |
Source code in src/pyromax/core/CoreMixins/Message.py
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | |
edit_message
async
¶
edit_message(
chat_id: int,
message_id: int | str,
text: str | None = None,
attaches: list[BaseFileAttachment] | None = None,
**kwargs: Any
) -> Message
Edit message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chat_id
|
int
|
Identifier of the chat. |
required |
message_id
|
int | str
|
Identifier of the message. |
required |
text
|
str | None
|
Message or textual content. |
None
|
attaches
|
list[BaseFileAttachment] | None
|
Attachments associated with the message. |
None
|
Returns:
| Type | Description |
|---|---|
Message
|
The resulting Message value. |
Source code in src/pyromax/core/CoreMixins/Message.py
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 | |
get_messages
async
¶
get_messages(
chat_id: int, message_ids: Iterable[str] | Iterable[int]
) -> list[Message]
Retrieve messages.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chat_id
|
int
|
Identifier of the chat. |
required |
message_ids
|
Iterable[str] | Iterable[int]
|
Identifiers of the messages. |
required |
Returns:
| Type | Description |
|---|---|
list[Message]
|
The resulting collection. |
Source code in src/pyromax/core/CoreMixins/Message.py
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 | |
get_message
async
¶
get_message(
chat_id: int, message_id: int | str
) -> Message | None
Retrieve message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chat_id
|
int
|
Identifier of the chat. |
required |
message_id
|
int | str
|
Identifier of the message. |
required |
Returns:
| Type | Description |
|---|---|
Message | None
|
The resulting Message | None value. |
Source code in src/pyromax/core/CoreMixins/Message.py
177 178 179 180 181 182 183 184 185 186 187 188 | |
get_chat_history
async
¶
get_chat_history(
chat_id: int,
forward: int = ...,
backward: int = ...,
backward_time: int = ...,
forward_time: int = ...,
from_time: int | None = ...,
item_type: Literal["DELAYED", "REGULAR"] = ...,
get_chat: bool = ...,
get_messages: Literal[True] = True,
interactive: bool = ...,
) -> list[Message]
get_chat_history(
chat_id: int,
forward: int = ...,
backward: int = ...,
backward_time: int = ...,
forward_time: int = ...,
from_time: int | None = None,
item_type: Literal["DELAYED", "REGULAR"] = ...,
get_chat: bool = ...,
get_messages: Literal[False] = False,
interactive: bool = ...,
) -> list[str]
get_chat_history(
chat_id: int,
forward: int = ...,
backward: int = ...,
backward_time: int = ...,
forward_time: int = ...,
from_time: int | None = ...,
item_type: Literal["DELAYED", "REGULAR"] = ...,
get_chat: bool = ...,
get_messages: bool = ...,
interactive: bool = ...,
) -> list[Message] | list[str]
get_chat_history(
chat_id: int,
forward: int = 0,
backward: int = 40,
backward_time: int = 0,
forward_time: int = 0,
from_time: int | None = None,
item_type: Literal["DELAYED", "REGULAR"] = "REGULAR",
get_chat: bool = False,
get_messages: bool = True,
interactive: bool = False,
) -> list[Message] | list[str]
Retrieve chat history.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chat_id
|
int
|
Identifier of the chat. |
required |
forward
|
int
|
How many messages to load ahead from |
0
|
backward
|
int
|
How many messages to load back from |
40
|
backward_time
|
int
|
Look-back time window in milliseconds. |
0
|
forward_time
|
int
|
Forward time window in milliseconds. |
0
|
from_time
|
int | None
|
The reference point in Unix time (milliseconds). If |
None
|
item_type
|
Literal['DELAYED', 'REGULAR']
|
History item type. |
'REGULAR'
|
get_chat
|
bool
|
Request chat data along with the history. |
False
|
get_messages
|
bool
|
The get messages value. |
True
|
interactive
|
bool
|
Request the messages themselves. |
False
|
Returns:
| Type | Description |
|---|---|
list[Message] | list[str]
|
Message collection if get_messages is True else message ids collection. |
Source code in src/pyromax/core/CoreMixins/Message.py
237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 | |
delete_messages
async
¶
delete_messages(
chat_id: int,
message_ids: list[str] | list[int],
for_me: bool = False,
) -> None
Delete messages.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chat_id
|
int
|
Identifier of the chat. |
required |
message_ids
|
list[str] | list[int]
|
Identifiers of the messages. |
required |
for_me
|
bool
|
Delete only for the current account. |
False
|
Source code in src/pyromax/core/CoreMixins/Message.py
293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 | |
pin_message
async
¶
pin_message(
chat_id: int, message_id: int | str, notify: bool = True
) -> None
Pin message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chat_id
|
int
|
Identifier of the chat. |
required |
message_id
|
int | str
|
Identifier of the message. |
required |
notify
|
bool
|
Whether MAX should notify affected users. |
True
|
Source code in src/pyromax/core/CoreMixins/Message.py
318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 | |
add_reaction
async
¶
add_reaction(
chat_id: int,
message_id: int | str,
reaction_id: str,
reaction_type: str = "EMOJI",
) -> EmojiReaction | None
Add an emoji reaction to a message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chat_id
|
int
|
Identifier of the chat containing the message. |
required |
message_id
|
int | str
|
int | str |
required |
reaction_id
|
str
|
str |
required |
reaction_type
|
str
|
str |
'EMOJI'
|
Returns:
| Type | Description |
|---|---|
EmojiReaction | None
|
info about reaction or None if cannot get this info |
Raises:
| Type | Description |
|---|---|
ReactionError
|
if adding reaction failed |
Source code in src/pyromax/core/CoreMixins/Message.py
340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 | |
remove_reaction
async
¶
remove_reaction(
chat_id: int, message_id: int | str
) -> EmojiReaction | None
Remove reaction.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chat_id
|
int
|
Identifier of the chat. |
required |
message_id
|
int | str
|
Identifier of the message. |
required |
Returns:
| Type | Description |
|---|---|
EmojiReaction | None
|
The resulting EmojiReaction | None value. |
Source code in src/pyromax/core/CoreMixins/Message.py
378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 | |
get_reactions
async
¶
get_reactions(
chat_id: int, message_ids: list[str] | list[int]
) -> dict[str, EmojiReaction] | None
Retrieve reactions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chat_id
|
int
|
Identifier of the chat. |
required |
message_ids
|
list[str] | list[int]
|
Identifiers of the messages. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, EmojiReaction] | None
|
The resulting dict[ |
Source code in src/pyromax/core/CoreMixins/Message.py
398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 | |
read_message
async
¶
read_message(
chat_id: int,
message_id: int | str,
typeof: str = "READ_MESSAGE",
mark: int | None = None,
) -> ReadState
Read message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chat_id
|
int
|
Identifier of the chat. |
required |
message_id
|
int | str
|
Identifier of the message. |
required |
typeof
|
str
|
Attachment class that determines the upload type. |
'READ_MESSAGE'
|
mark
|
int | None
|
The mark value. |
None
|
Returns:
| Type | Description |
|---|---|
ReadState
|
The resulting ReadState value. |
Source code in src/pyromax/core/CoreMixins/Message.py
418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 | |
create_poll
async
¶
create_poll(poll: Poll) -> Poll
Create poll.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
poll
|
Poll
|
Poll instance to process. |
required |
Returns:
| Type | Description |
|---|---|
Poll
|
The resulting Poll value what can be send with message in send_message method. |
Source code in src/pyromax/core/CoreMixins/Message.py
450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 | |
vote_poll
async
¶
vote_poll(
chat_id: int,
message_id: int | str,
poll_id: int,
answer_ids: list[int],
) -> PollState
Submit a vote for poll.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chat_id
|
int
|
Identifier of the chat. |
required |
message_id
|
int | str
|
Identifier of the message. |
required |
poll_id
|
int
|
Identifier of the poll. |
required |
answer_ids
|
list[int]
|
Identifiers of the answer objects. |
required |
Returns:
| Type | Description |
|---|---|
PollState
|
The resulting PollState value. |
Source code in src/pyromax/core/CoreMixins/Message.py
470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 | |
set_2fa
async
¶
set_2fa(
password: str,
email: str | None = None,
hint: str | None = None,
email_code_getter: (
Callable[[str], Coroutine[Any, Any, str]] | None
) = None,
two_factor_actions: list[TwoFactorAction] | None = None,
) -> None
Set 2fa.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
password
|
str
|
New 2FA password. |
required |
email
|
str | None
|
Email address for 2FA, if required. |
None
|
hint
|
str | None
|
Password hint, if required. |
None
|
email_code_getter
|
Callable[[str], Coroutine[Any, Any, str]] | None
|
Callable to get password, first argument is phone number. |
None
|
two_factor_actions
|
list[TwoFactorAction] | None
|
Collection of two factor actions. |
None
|
Source code in src/pyromax/core/CoreMixins/Auth.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | |
remove_2fa
async
¶
remove_2fa(
password: str,
two_factor_actions: list[TwoFactorAction] | None = None,
remove_2fa: bool = True,
) -> None
Remove 2fa.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
password
|
str
|
Account password. |
required |
two_factor_actions
|
list[TwoFactorAction] | None
|
Collection of two factor actions. |
None
|
remove_2fa
|
bool
|
The remove 2fa value. |
True
|
Source code in src/pyromax/core/CoreMixins/Auth.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | |
change_password
async
¶
change_password(
password_old: str,
password_new: str,
hint: str | None = None,
two_factor_actions: list[TwoFactorAction] | None = None,
) -> None
Change password.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
password_old
|
str
|
The password old value. |
required |
password_new
|
str
|
The password new value. |
required |
hint
|
str | None
|
Password hint. |
None
|
two_factor_actions
|
list[TwoFactorAction] | None
|
Collection of two factor actions. |
None
|
Source code in src/pyromax/core/CoreMixins/Auth.py
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 | |
check_2fa
async
¶
check_2fa() -> bool
Check 2fa.
Returns:
| Type | Description |
|---|---|
bool
|
True when the account has 2FA; otherwise False. |
Source code in src/pyromax/core/CoreMixins/Auth.py
105 106 107 108 109 110 111 112 113 114 115 116 | |
approve_qr_login
async
¶
approve_qr_login(qr_link: str) -> None
Approve qr login.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
qr_link
|
str
|
Link to the authorization QR code. |
required |
Source code in src/pyromax/core/CoreMixins/Auth.py
118 119 120 121 122 123 124 125 126 127 128 129 130 | |