Skip to content
This repository was archived by the owner on Feb 11, 2026. It is now read-only.

Commit ebd75dd

Browse files
committed
добавил chat_marker для fetch_chats
1 parent c3ac2ad commit ebd75dd

File tree

5 files changed

+11
-5
lines changed

5 files changed

+11
-5
lines changed

src/pymax/core.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ def __init__(
121121
self.channels: list[Channel] = []
122122
self.me: Me | None = None
123123
self.contacts: list[User] = []
124+
self.chat_marker: int | None = None
124125
self._users: dict[int, User] = {}
125126

126127
self._work_dir: str = work_dir
@@ -143,7 +144,7 @@ def __init__(
143144
self._sock_lock = asyncio.Lock()
144145
self._read_buffer = bytearray()
145146

146-
self._seq: int = 0
147+
self._seq: int = -1
147148
self._error_count: int = 0
148149
self._circuit_breaker: bool = False
149150
self._last_error_time: float = 0.0

src/pymax/interfaces.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -527,17 +527,20 @@ async def _sync(self, user_agent: UserAgentPayload | None = None) -> None:
527527
token=self._token,
528528
chats_sync=0,
529529
contacts_sync=0,
530-
presence_sync=0,
530+
presence_sync=-1,
531531
drafts_sync=0,
532532
chats_count=40,
533533
user_agent=user_agent,
534-
).model_dump(by_alias=True)
534+
).model_dump(by_alias=True, exclude_none=True, exclude_unset=True)
535535
try:
536536
data = await self._send_and_wait(opcode=Opcode.LOGIN, payload=payload)
537537
raw_payload = data.get("payload", {})
538538

539539
if error := raw_payload.get("error"):
540540
MixinsUtils.handle_error(data)
541+
chat_marker = raw_payload.get("chatMarker")
542+
if chat_marker:
543+
self.chat_marker = chat_marker
541544

542545
for raw_chat in raw_payload.get("chats", []):
543546
try:

src/pymax/mixins/websocket.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ async def _recv_loop(self) -> None:
8484
while True:
8585
try:
8686
raw = await self._ws.recv()
87+
self.logger.debug("RAW IN: %s", raw)
8788
data = self._parse_json(raw)
8889

8990
if data is None:
@@ -97,7 +98,7 @@ async def _recv_loop(self) -> None:
9798
await self._dispatch_incoming(data)
9899

99100
except websockets.exceptions.ConnectionClosed as e:
100-
self.logger.info(
101+
self.logger.exception(
101102
f"WebSocket connection closed with error: {e.code}, {e.reason}; exiting recv loop"
102103
)
103104
for fut in self._pending.values():

src/pymax/payloads.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class SyncPayload(CamelModel):
7676
token: str
7777
chats_sync: int = 0
7878
contacts_sync: int = 0
79-
presence_sync: int = 0
79+
presence_sync: int = -1
8080
drafts_sync: int = 0
8181
chats_count: int = 40
8282
user_agent: UserAgentPayload = Field(

src/pymax/protocols.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ def __init__(self, logger: Logger) -> None:
4545
self.channels: list[Channel] = []
4646
self.contacts: list[User] = []
4747
self.me: Me | None = None
48+
self.chat_marker: int | None = None
4849
self.host: str
4950
self.port: int
5051
self.proxy: str | Literal[True] | None

0 commit comments

Comments
 (0)