Skip to content

Commit 65c0aa7

Browse files
authored
Fix/kl/edit message event (#469)
* fix: add fields in edit message event * bump: project version to 0.66.1
1 parent 1a3eb1a commit 65c0aa7

File tree

3 files changed

+24
-5
lines changed

3 files changed

+24
-5
lines changed

pybotx/models/system_events/event_edit.py

+18-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from dataclasses import dataclass
22
from typing import Any, Dict, List, Literal, Optional
3+
from uuid import UUID
34

45
from pydantic import Field
56

@@ -10,9 +11,9 @@
1011
convert_api_attachment_to_domain,
1112
)
1213
from pybotx.models.base_command import (
13-
BaseBotAPIContext,
1414
BotAPIBaseCommand,
1515
BotAPIBaseSystemEventPayload,
16+
BotAPIUserContext,
1617
BotCommandBase,
1718
)
1819
from pybotx.models.bot_account import BotAccount
@@ -30,11 +31,17 @@ class EventEdit(BotCommandBase):
3031
3132
Attributes:
3233
body: Updated message body.
34+
sync_id: Updated message sync id.
35+
chat_id: Updated message chat id.
36+
huid: Updated message user huid.
3337
attachments: Attachments from updated message.
3438
entities: Entities from updated message.
3539
"""
3640

3741
body: Optional[str]
42+
sync_id: UUID
43+
chat_id: UUID
44+
huid: UUID
3845
attachments: List[IncomingAttachment]
3946
entities: List[Entity]
4047

@@ -48,9 +55,15 @@ class BotAPIEventEditPayload(BotAPIBaseSystemEventPayload):
4855
data: BotAPIEventEditData
4956

5057

58+
class BotAPIBotContext(BotAPIUserContext):
59+
"""Bot context."""
60+
61+
group_chat_id: UUID
62+
63+
5164
class BotAPIEventEdit(BotAPIBaseCommand):
5265
payload: BotAPIEventEditPayload = Field(..., alias="command")
53-
sender: BaseBotAPIContext = Field(..., alias="from")
66+
sender: BotAPIBotContext = Field(..., alias="from")
5467
attachments: List[BotAPIAttachment]
5568
entities: List[BotAPIEntity]
5669

@@ -73,4 +86,7 @@ def to_domain(self, raw_command: Dict[str, Any]) -> EventEdit:
7386
convert_bot_api_entity_to_domain(api_entity=entity)
7487
for entity in self.entities
7588
],
89+
sync_id=self.sync_id,
90+
chat_id=self.sender.group_chat_id,
91+
huid=self.sender.user_huid,
7692
)

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "pybotx"
3-
version = "0.66.0"
3+
version = "0.66.1"
44
description = "A python library for interacting with eXpress BotX API"
55
authors = [
66
"Sidnev Nikolay <[email protected]>",

tests/system_events/test_event_edit.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ async def test__event_edit__succeed(
6060
},
6161
],
6262
"from": {
63-
"user_huid": None,
64-
"group_chat_id": None,
63+
"user_huid": "fbc84c63-e432-4ff1-99bd-c3275f053866",
64+
"group_chat_id": "6fe9b0e7-32e3-4843-8486-897eabd69422",
6565
"ad_login": None,
6666
"ad_domain": None,
6767
"username": None,
@@ -123,4 +123,7 @@ async def event_edit_handler(event: EventEdit, _: Bot) -> None:
123123
name="Вася Иванов",
124124
),
125125
],
126+
sync_id=UUID("a465f0f3-1354-491c-8f11-f400164295cb"),
127+
huid=UUID("fbc84c63-e432-4ff1-99bd-c3275f053866"),
128+
chat_id=UUID("6fe9b0e7-32e3-4843-8486-897eabd69422"),
126129
)

0 commit comments

Comments
 (0)