maxapi-python 1.1.9__tar.gz → 1.1.10__tar.gz

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.
Files changed (45) hide show
  1. {maxapi_python-1.1.9 → maxapi_python-1.1.10}/PKG-INFO +1 -1
  2. {maxapi_python-1.1.9 → maxapi_python-1.1.10}/examples/example.py +2 -1
  3. {maxapi_python-1.1.9 → maxapi_python-1.1.10}/pyproject.toml +1 -1
  4. {maxapi_python-1.1.9 → maxapi_python-1.1.10}/src/pymax/mixins/__init__.py +2 -0
  5. {maxapi_python-1.1.9 → maxapi_python-1.1.10}/src/pymax/mixins/group.py +44 -0
  6. {maxapi_python-1.1.9 → maxapi_python-1.1.10}/src/pymax/payloads.py +4 -0
  7. {maxapi_python-1.1.9 → maxapi_python-1.1.10}/.github/FUNDING.yml +0 -0
  8. {maxapi_python-1.1.9 → maxapi_python-1.1.10}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
  9. {maxapi_python-1.1.9 → maxapi_python-1.1.10}/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
  10. {maxapi_python-1.1.9 → maxapi_python-1.1.10}/.github/ISSUE_TEMPLATE/refactor.md +0 -0
  11. {maxapi_python-1.1.9 → maxapi_python-1.1.10}/.github/pull_request_template.md +0 -0
  12. {maxapi_python-1.1.9 → maxapi_python-1.1.10}/.github/workflows/publish.yml +0 -0
  13. {maxapi_python-1.1.9 → maxapi_python-1.1.10}/.gitignore +0 -0
  14. {maxapi_python-1.1.9 → maxapi_python-1.1.10}/LICENSE +0 -0
  15. {maxapi_python-1.1.9 → maxapi_python-1.1.10}/README.md +0 -0
  16. {maxapi_python-1.1.9 → maxapi_python-1.1.10}/assets/icon.svg +0 -0
  17. {maxapi_python-1.1.9 → maxapi_python-1.1.10}/assets/logo.svg +0 -0
  18. {maxapi_python-1.1.9 → maxapi_python-1.1.10}/docs/api.md +0 -0
  19. {maxapi_python-1.1.9 → maxapi_python-1.1.10}/docs/assets/icon.svg +0 -0
  20. {maxapi_python-1.1.9 → maxapi_python-1.1.10}/docs/examples.md +0 -0
  21. {maxapi_python-1.1.9 → maxapi_python-1.1.10}/docs/index.md +0 -0
  22. {maxapi_python-1.1.9 → maxapi_python-1.1.10}/mkdocs.yml +0 -0
  23. {maxapi_python-1.1.9 → maxapi_python-1.1.10}/ruff.toml +0 -0
  24. {maxapi_python-1.1.9 → maxapi_python-1.1.10}/scripts/build.py +0 -0
  25. {maxapi_python-1.1.9 → maxapi_python-1.1.10}/src/pymax/__init__.py +0 -0
  26. {maxapi_python-1.1.9 → maxapi_python-1.1.10}/src/pymax/core.py +0 -0
  27. {maxapi_python-1.1.9 → maxapi_python-1.1.10}/src/pymax/crud.py +0 -0
  28. {maxapi_python-1.1.9 → maxapi_python-1.1.10}/src/pymax/exceptions.py +0 -0
  29. {maxapi_python-1.1.9 → maxapi_python-1.1.10}/src/pymax/files.py +0 -0
  30. {maxapi_python-1.1.9 → maxapi_python-1.1.10}/src/pymax/filters.py +0 -0
  31. {maxapi_python-1.1.9 → maxapi_python-1.1.10}/src/pymax/interfaces.py +0 -0
  32. {maxapi_python-1.1.9 → maxapi_python-1.1.10}/src/pymax/mixins/auth.py +0 -0
  33. {maxapi_python-1.1.9 → maxapi_python-1.1.10}/src/pymax/mixins/channel.py +0 -0
  34. {maxapi_python-1.1.9 → maxapi_python-1.1.10}/src/pymax/mixins/handler.py +0 -0
  35. {maxapi_python-1.1.9 → maxapi_python-1.1.10}/src/pymax/mixins/message.py +0 -0
  36. {maxapi_python-1.1.9 → maxapi_python-1.1.10}/src/pymax/mixins/self.py +0 -0
  37. {maxapi_python-1.1.9 → maxapi_python-1.1.10}/src/pymax/mixins/socket.py +0 -0
  38. {maxapi_python-1.1.9 → maxapi_python-1.1.10}/src/pymax/mixins/telemetry.py +0 -0
  39. {maxapi_python-1.1.9 → maxapi_python-1.1.10}/src/pymax/mixins/user.py +0 -0
  40. {maxapi_python-1.1.9 → maxapi_python-1.1.10}/src/pymax/mixins/websocket.py +0 -0
  41. {maxapi_python-1.1.9 → maxapi_python-1.1.10}/src/pymax/models.py +0 -0
  42. {maxapi_python-1.1.9 → maxapi_python-1.1.10}/src/pymax/navigation.py +0 -0
  43. {maxapi_python-1.1.9 → maxapi_python-1.1.10}/src/pymax/static.py +0 -0
  44. {maxapi_python-1.1.9 → maxapi_python-1.1.10}/src/pymax/types.py +0 -0
  45. {maxapi_python-1.1.9 → maxapi_python-1.1.10}/src/pymax/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: maxapi-python
3
- Version: 1.1.9
3
+ Version: 1.1.10
4
4
  Summary: Python wrapper для API мессенджера Max
5
5
  Project-URL: Homepage, https://github.com/noxzion/PyMax
6
6
  Project-URL: Repository, https://github.com/noxzion/PyMax
@@ -25,7 +25,8 @@ async def handle_start() -> None:
25
25
  for session in sessions:
26
26
  print(session.client)
27
27
  # print(client.dialogs)
28
- # history = await client.fetch_history(chat_id=0)
28
+ chat = await client.join_group("join/sdfdfsfdf")
29
+ print(chat.title)
29
30
  # if history:
30
31
  # for message in history:
31
32
  # if message.link:
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "maxapi-python"
3
- version = "1.1.9"
3
+ version = "1.1.10"
4
4
  description = "Python wrapper для API мессенджера Max"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.10"
@@ -1,5 +1,6 @@
1
1
  from .auth import AuthMixin
2
2
  from .channel import ChannelMixin
3
+ from .group import GroupMixin
3
4
  from .handler import HandlerMixin
4
5
  from .message import MessageMixin
5
6
  from .self import SelfMixin
@@ -17,6 +18,7 @@ class ApiMixin(
17
18
  SelfMixin,
18
19
  MessageMixin,
19
20
  TelemetryMixin,
21
+ GroupMixin,
20
22
  ):
21
23
  pass
22
24
 
@@ -9,6 +9,7 @@ from pymax.payloads import (
9
9
  CreateGroupMessage,
10
10
  CreateGroupPayload,
11
11
  InviteUsersPayload,
12
+ JoinGroupPayload,
12
13
  RemoveUsersPayload,
13
14
  )
14
15
  from pymax.static import Opcode
@@ -218,3 +219,46 @@ class GroupMixin(ClientProtocol):
218
219
 
219
220
  except Exception:
220
221
  self.logger.exception("Change group profile failed")
222
+
223
+ def _process_chat_join_link(self, link: str) -> str | None:
224
+ idx = link.find("join/")
225
+ return link[idx:] if idx != -1 else None
226
+
227
+ async def join_group(self, link: str) -> Chat | None:
228
+ """
229
+ Вступает в группу по ссылке
230
+
231
+ Args:
232
+ link (str): Ссылка на группу.
233
+
234
+ Returns:
235
+ bool: True, если успешно вступил в группу
236
+ """
237
+ try:
238
+ proceed_link = self._process_chat_join_link(link)
239
+ if proceed_link is None:
240
+ self.logger.error("Invalid group link: %s", link)
241
+ return None
242
+
243
+ payload = JoinGroupPayload(link=proceed_link).model_dump(by_alias=True)
244
+
245
+ data = await self._send_and_wait(opcode=Opcode.CHAT_JOIN, payload=payload)
246
+
247
+ if error := data.get("payload", {}).get("error"):
248
+ self.logger.error("Join group error: %s", error)
249
+ return None
250
+
251
+ chat = Chat.from_dict(data["payload"]["chat"])
252
+ if chat:
253
+ cached_chat = await self._get_chat(chat.id)
254
+ if cached_chat is None:
255
+ self.chats.append(chat)
256
+ else:
257
+ idx = self.chats.index(cached_chat)
258
+ self.chats[idx] = chat
259
+
260
+ return chat
261
+
262
+ except Exception:
263
+ self.logger.exception("Join group failed")
264
+ return None
@@ -209,3 +209,7 @@ class GetFilePayload(CamelModel):
209
209
 
210
210
  class SearchByPhonePayload(CamelModel):
211
211
  phone: str
212
+
213
+
214
+ class JoinGroupPayload(CamelModel):
215
+ link: str
File without changes
File without changes
File without changes
File without changes
File without changes