maxapi-python 1.1.20__py3-none-any.whl → 1.2.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
pymax/mixins/self.py CHANGED
@@ -23,15 +23,16 @@ class SelfMixin(ClientProtocol):
23
23
  description: str | None = None,
24
24
  ) -> bool:
25
25
  """
26
- Изменяет профиль
27
-
28
- Args:
29
- first_name (str): Имя.
30
- last_name (str | None, optional): Фамилия. Defaults to None.
31
- description (str | None, optional): Описание. Defaults to None.
32
-
33
- Returns:
34
- bool: True, если профиль изменен
26
+ Изменяет информацию профиля текущего пользователя.
27
+
28
+ :param first_name: Имя пользователя.
29
+ :type first_name: str
30
+ :param last_name: Фамилия пользователя. По умолчанию None.
31
+ :type last_name: str | None
32
+ :param description: Описание профиля. По умолчанию None.
33
+ :type description: str | None
34
+ :return: True, если профиль успешно изменен.
35
+ :rtype: bool
35
36
  """
36
37
 
37
38
  payload = ChangeProfilePayload(
@@ -54,15 +55,16 @@ class SelfMixin(ClientProtocol):
54
55
  self, title: str, chat_include: list[int], filters: list[Any] | None = None
55
56
  ) -> FolderUpdate:
56
57
  """
57
- Создает папку для чатов
58
-
59
- Args:
60
- title (str): Название папки
61
- chat_include (list[int]): Список ID чатов для включения в папку
62
- filters (list[Any] | None, optional): Список фильтров для папки (Неизвестный параметр, использование на свой страх и риск)
63
-
64
- Returns:
65
- bool: True, если папка создана
58
+ Создает новую папку для группировки чатов.
59
+
60
+ :param title: Название папки.
61
+ :type title: str
62
+ :param chat_include: Список ID чатов для включения в папку.
63
+ :type chat_include: list[int]
64
+ :param filters: Список фильтров для папки (опциональный параметр).
65
+ :type filters: list[Any] | None
66
+ :return: Объект FolderUpdate с информацией о созданной папке.
67
+ :rtype: FolderUpdate
66
68
  """
67
69
  self.logger.info("Creating folder")
68
70
 
@@ -82,11 +84,12 @@ class SelfMixin(ClientProtocol):
82
84
 
83
85
  async def get_folders(self, folder_sync: int = 0) -> FolderList:
84
86
  """
85
- Получает список папок
86
- Args:
87
- folder_sync (int, optional): Синхронизационный маркер папок. По умолчанию 0. (Неизвестный параметр, использование на свой страх и риск)
88
- Returns:
89
- FolderList: Список папок
87
+ Получает список всех папок пользователя.
88
+
89
+ :param folder_sync: Синхронизационный маркер папок. По умолчанию 0.
90
+ :type folder_sync: int
91
+ :return: Объект FolderList с информацией о папках.
92
+ :rtype: FolderList
90
93
  """
91
94
  self.logger.info("Fetching folders")
92
95
 
@@ -106,17 +109,22 @@ class SelfMixin(ClientProtocol):
106
109
  chat_include: list[int] | None = None,
107
110
  filters: list[Any] | None = None,
108
111
  options: list[Any] | None = None,
109
- ):
112
+ ) -> FolderUpdate | None:
110
113
  """
111
- Обновляет папку для чатов
112
-
113
- Args:
114
- folder_id (str): ID папки
115
- title (str): Название папки
116
- chat_include (list[int] | None, optional): Список ID чатов для включения в папку. По умолчанию None.
117
- filters (list[Any] | None, optional): Список фильтров для папки. По умолчанию None.
118
- options (list[Any] | None, optional): Список опций для папки. По умолчанию None.
119
- Returns:
114
+ Обновляет параметры существующей папки.
115
+
116
+ :param folder_id: Идентификатор папки.
117
+ :type folder_id: str
118
+ :param title: Название папки.
119
+ :type title: str
120
+ :param chat_include: Список ID чатов для включения в папку.
121
+ :type chat_include: list[int] | None
122
+ :param filters: Список фильтров для папки.
123
+ :type filters: list[Any] | None
124
+ :param options: Список опций для папки.
125
+ :type options: list[Any] | None
126
+ :return: Объект FolderUpdate с результатом или None.
127
+ :rtype: FolderUpdate | None
120
128
  """
121
129
  self.logger.info("Updating folder")
122
130
 
@@ -135,15 +143,14 @@ class SelfMixin(ClientProtocol):
135
143
 
136
144
  return FolderUpdate.from_dict(data.get("payload", {}))
137
145
 
138
- async def delete_folder(self, folder_id: str) -> FolderUpdate:
146
+ async def delete_folder(self, folder_id: str) -> FolderUpdate | None:
139
147
  """
140
- Удаляет папку для чатов
141
-
142
- Args:
143
- folder_id (str): ID папки
148
+ Удаляет папку.
144
149
 
145
- Returns:
146
- bool: True, если папка удалена
150
+ :param folder_id: Идентификатор папки для удаления.
151
+ :type folder_id: str
152
+ :return: Объект FolderUpdate с результатом операции или None.
153
+ :rtype: FolderUpdate | None
147
154
  """
148
155
  self.logger.info("Deleting folder")
149
156
 
@@ -153,3 +160,35 @@ class SelfMixin(ClientProtocol):
153
160
  MixinsUtils.handle_error(data)
154
161
 
155
162
  return FolderUpdate.from_dict(data.get("payload", {}))
163
+
164
+ async def close_all_sessions(self) -> bool:
165
+ """
166
+ Закрывает все активные сессии, кроме текущей.
167
+
168
+ :return: True, если операция выполнена успешно.
169
+ :rtype: bool
170
+ """
171
+ self.logger.info("Closing all other sessions")
172
+
173
+ data = await self._send_and_wait(opcode=Opcode.SESSIONS_CLOSE, payload={})
174
+
175
+ if data.get("payload", {}).get("error"):
176
+ MixinsUtils.handle_error(data)
177
+
178
+ return True
179
+
180
+ async def logout(self) -> bool:
181
+ """
182
+ Выполняет выход из текущей сессии.
183
+
184
+ :return: True, если выход выполнен успешно.
185
+ :rtype: bool
186
+ """
187
+ self.logger.info("Logging out")
188
+
189
+ data = await self._send_and_wait(opcode=Opcode.LOGOUT, payload={})
190
+
191
+ if data.get("payload", {}).get("error"):
192
+ MixinsUtils.handle_error(data)
193
+
194
+ return True