Skip to content

Commit

Permalink
Fix/kl/edit message event (#469)
Browse files Browse the repository at this point in the history
* fix: add fields in edit message event

* bump: project version to 0.66.1
  • Loading branch information
Kiruha01 committed May 22, 2024
1 parent 1a3eb1a commit 65c0aa7
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
20 changes: 18 additions & 2 deletions pybotx/models/system_events/event_edit.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from dataclasses import dataclass
from typing import Any, Dict, List, Literal, Optional
from uuid import UUID

from pydantic import Field

Expand All @@ -10,9 +11,9 @@
convert_api_attachment_to_domain,
)
from pybotx.models.base_command import (
BaseBotAPIContext,
BotAPIBaseCommand,
BotAPIBaseSystemEventPayload,
BotAPIUserContext,
BotCommandBase,
)
from pybotx.models.bot_account import BotAccount
Expand All @@ -30,11 +31,17 @@ class EventEdit(BotCommandBase):
Attributes:
body: Updated message body.
sync_id: Updated message sync id.
chat_id: Updated message chat id.
huid: Updated message user huid.
attachments: Attachments from updated message.
entities: Entities from updated message.
"""

body: Optional[str]
sync_id: UUID
chat_id: UUID
huid: UUID
attachments: List[IncomingAttachment]
entities: List[Entity]

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


class BotAPIBotContext(BotAPIUserContext):
"""Bot context."""

group_chat_id: UUID


class BotAPIEventEdit(BotAPIBaseCommand):
payload: BotAPIEventEditPayload = Field(..., alias="command")
sender: BaseBotAPIContext = Field(..., alias="from")
sender: BotAPIBotContext = Field(..., alias="from")
attachments: List[BotAPIAttachment]
entities: List[BotAPIEntity]

Expand All @@ -73,4 +86,7 @@ def to_domain(self, raw_command: Dict[str, Any]) -> EventEdit:
convert_bot_api_entity_to_domain(api_entity=entity)
for entity in self.entities
],
sync_id=self.sync_id,
chat_id=self.sender.group_chat_id,
huid=self.sender.user_huid,
)
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "pybotx"
version = "0.66.0"
version = "0.66.1"
description = "A python library for interacting with eXpress BotX API"
authors = [
"Sidnev Nikolay <nsidnev@ccsteam.ru>",
Expand Down
7 changes: 5 additions & 2 deletions tests/system_events/test_event_edit.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ async def test__event_edit__succeed(
},
],
"from": {
"user_huid": None,
"group_chat_id": None,
"user_huid": "fbc84c63-e432-4ff1-99bd-c3275f053866",
"group_chat_id": "6fe9b0e7-32e3-4843-8486-897eabd69422",
"ad_login": None,
"ad_domain": None,
"username": None,
Expand Down Expand Up @@ -123,4 +123,7 @@ async def event_edit_handler(event: EventEdit, _: Bot) -> None:
name="Вася Иванов",
),
],
sync_id=UUID("a465f0f3-1354-491c-8f11-f400164295cb"),
huid=UUID("fbc84c63-e432-4ff1-99bd-c3275f053866"),
chat_id=UUID("6fe9b0e7-32e3-4843-8486-897eabd69422"),
)

0 comments on commit 65c0aa7

Please sign in to comment.