Skip to content

Commit

Permalink
fix mentions
Browse files Browse the repository at this point in the history
  • Loading branch information
Sidnev Nikolaj committed Mar 25, 2019
1 parent 149873b commit eb6ec56
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 37 deletions.
13 changes: 5 additions & 8 deletions botx/bot/asyncbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@
KeyboardElement,
Mention,
ResponseCommand,
ResponseCommandResult,
ResponseFile,
ResponseNotification,
ResponseNotificationResult,
ResponseRecipientsEnum,
ResponseResult,
Status,
SyncID,
)
Expand Down Expand Up @@ -157,16 +156,15 @@ async def _send_command_result(
bubble: List[List[BubbleElement]],
keyboard: List[List[KeyboardElement]],
) -> Tuple[str, int]:
response_result = ResponseCommandResult(
body=text, bubble=bubble, keyboard=keyboard
response_result = ResponseResult(
body=text, bubble=bubble, keyboard=keyboard, mentions=mentions
)

response = ResponseCommand(
bot_id=bot_id,
sync_id=str(chat_id),
command_result=response_result,
recipients=recipients,
mentions=mentions,
file=file,
)

Expand Down Expand Up @@ -195,15 +193,14 @@ async def _send_notification_result(
bubble: List[List[BubbleElement]],
keyboard: List[List[KeyboardElement]],
) -> Tuple[str, int]:
response_result = ResponseNotificationResult(
body=text, bubble=bubble, keyboard=keyboard
response_result = ResponseResult(
body=text, bubble=bubble, keyboard=keyboard, mentions=mentions
)
response = ResponseNotification(
bot_id=bot_id,
notification=response_result,
group_chat_ids=group_chat_ids,
recipients=recipients,
mentions=mentions,
file=file,
)

Expand Down
13 changes: 5 additions & 8 deletions botx/bot/syncbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@
KeyboardElement,
Mention,
ResponseCommand,
ResponseCommandResult,
ResponseFile,
ResponseNotification,
ResponseNotificationResult,
ResponseRecipientsEnum,
ResponseResult,
Status,
SyncID,
)
Expand Down Expand Up @@ -154,16 +153,15 @@ def _send_command_result(
bubble: List[List[BubbleElement]],
keyboard: List[List[KeyboardElement]],
) -> Tuple[str, int]:
response_result = ResponseCommandResult(
body=text, bubble=bubble, keyboard=keyboard
response_result = ResponseResult(
body=text, bubble=bubble, keyboard=keyboard, mentions=mentions
)

response = ResponseCommand(
bot_id=bot_id,
sync_id=str(chat_id),
command_result=response_result,
recipients=recipients,
mentions=mentions,
file=file,
)

Expand Down Expand Up @@ -192,15 +190,14 @@ def _send_notification_result(
bubble: List[List[BubbleElement]],
keyboard: List[List[KeyboardElement]],
) -> Tuple[str, int]:
response_result = ResponseNotificationResult(
body=text, bubble=bubble, keyboard=keyboard
response_result = ResponseResult(
body=text, bubble=bubble, keyboard=keyboard, mentions=mentions
)
response = ResponseNotification(
bot_id=bot_id,
notification=response_result,
group_chat_ids=group_chat_ids,
recipients=recipients,
mentions=mentions,
file=file,
)

Expand Down
2 changes: 0 additions & 2 deletions botx/types/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@
from .message import Message, MessageCommand, MessageUser
from .response import (
ResponseCommand,
ResponseCommandResult,
ResponseFile,
ResponseNotification,
ResponseNotificationResult,
ResponseResult,
)
from .status import Status, StatusResult
27 changes: 9 additions & 18 deletions botx/types/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,32 +15,23 @@ class ResponseResult(BotXType):
commands: List[MenuCommand] = []
keyboard: List[List[KeyboardElement]] = []
bubble: List[List[BubbleElement]] = []
mentions: List[Mention] = []


class ResponseCommandResult(ResponseResult):
pass


class ResponseNotificationResult(ResponseResult):
pass


class ResponseCommand(BotXType):
sync_id: SyncID
class BaseResponse(BotXType):
bot_id: UUID
recipients: Union[List[UUID], ResponseRecipientsEnum] = ResponseRecipientsEnum.all
command_result: ResponseCommandResult
mentions: List[Mention] = []
file: Optional[File] = None


class ResponseNotification(BotXType):
bot_id: UUID
recipients: Union[List[UUID], ResponseRecipientsEnum] = ResponseRecipientsEnum.all
class ResponseCommand(BaseResponse):
sync_id: SyncID
command_result: ResponseResult


class ResponseNotification(BaseResponse):
group_chat_ids: List[UUID] = []
notification: ResponseNotificationResult
mentions: List[Mention] = []
file: Optional[File] = None
notification: ResponseResult


class ResponseFile(BotXType):
Expand Down
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 = "botx"
version = "1.0.0a7"
version = "1.0.0a8"
description = "Python implementation for Express BotX API"
authors = [
"Michael Morozov <mmorozov@ccsteam.ru>",
Expand Down

0 comments on commit eb6ec56

Please sign in to comment.