python-trueconf-bot 1.0.0__py3-none-any.whl
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.
- python_trueconf_bot-1.0.0.dist-info/METADATA +115 -0
- python_trueconf_bot-1.0.0.dist-info/RECORD +120 -0
- python_trueconf_bot-1.0.0.dist-info/WHEEL +5 -0
- python_trueconf_bot-1.0.0.dist-info/licenses/LICENSE +32 -0
- python_trueconf_bot-1.0.0.dist-info/top_level.txt +1 -0
- trueconf/__init__.py +18 -0
- trueconf/_version.py +34 -0
- trueconf/client/__init__.py +0 -0
- trueconf/client/bot.py +1269 -0
- trueconf/client/context_controller.py +27 -0
- trueconf/client/session.py +60 -0
- trueconf/dispatcher/__init__.py +0 -0
- trueconf/dispatcher/dispatcher.py +56 -0
- trueconf/dispatcher/router.py +207 -0
- trueconf/enums/__init__.py +23 -0
- trueconf/enums/aouth_error.py +15 -0
- trueconf/enums/chat_participant_role.py +18 -0
- trueconf/enums/chat_type.py +17 -0
- trueconf/enums/envelope_author_type.py +13 -0
- trueconf/enums/file_ready_state.py +14 -0
- trueconf/enums/incoming_update_method.py +14 -0
- trueconf/enums/message_type.py +27 -0
- trueconf/enums/parse_mode.py +14 -0
- trueconf/enums/survey_type.py +6 -0
- trueconf/enums/update_type.py +14 -0
- trueconf/exceptions.py +17 -0
- trueconf/filters/__init__.py +11 -0
- trueconf/filters/base.py +8 -0
- trueconf/filters/command.py +32 -0
- trueconf/filters/instance_of.py +11 -0
- trueconf/filters/message.py +15 -0
- trueconf/filters/method.py +12 -0
- trueconf/loggers.py +4 -0
- trueconf/methods/__init__.py +59 -0
- trueconf/methods/add_participant_to_chat.py +22 -0
- trueconf/methods/auth.py +25 -0
- trueconf/methods/base.py +107 -0
- trueconf/methods/create_channel.py +20 -0
- trueconf/methods/create_group_chat.py +20 -0
- trueconf/methods/create_p2p_chat.py +20 -0
- trueconf/methods/edit_message.py +25 -0
- trueconf/methods/edit_survey.py +32 -0
- trueconf/methods/forward_message.py +22 -0
- trueconf/methods/get_chat_by_id.py +20 -0
- trueconf/methods/get_chat_history.py +24 -0
- trueconf/methods/get_chat_participants.py +24 -0
- trueconf/methods/get_chats.py +22 -0
- trueconf/methods/get_file_info.py +20 -0
- trueconf/methods/get_message_by_id.py +19 -0
- trueconf/methods/get_user_display_name.py +20 -0
- trueconf/methods/has_chat_participant.py +22 -0
- trueconf/methods/remove_chat.py +20 -0
- trueconf/methods/remove_message.py +23 -0
- trueconf/methods/remove_participant_from_chat.py +23 -0
- trueconf/methods/send_file.py +25 -0
- trueconf/methods/send_message.py +29 -0
- trueconf/methods/send_survey.py +40 -0
- trueconf/methods/subscribe_file_progress.py +21 -0
- trueconf/methods/unsubscribe_file_progress.py +21 -0
- trueconf/methods/upload_file.py +21 -0
- trueconf/py.typed +0 -0
- trueconf/types/__init__.py +25 -0
- trueconf/types/author_box.py +17 -0
- trueconf/types/chat_participant.py +11 -0
- trueconf/types/content/__init__.py +25 -0
- trueconf/types/content/attachment.py +14 -0
- trueconf/types/content/base.py +8 -0
- trueconf/types/content/chat_created.py +9 -0
- trueconf/types/content/document.py +71 -0
- trueconf/types/content/forward_message.py +21 -0
- trueconf/types/content/photo.py +70 -0
- trueconf/types/content/remove_participant.py +9 -0
- trueconf/types/content/sticker.py +70 -0
- trueconf/types/content/survey.py +19 -0
- trueconf/types/content/text.py +9 -0
- trueconf/types/content/video.py +71 -0
- trueconf/types/last_message.py +33 -0
- trueconf/types/message.py +411 -0
- trueconf/types/parser.py +90 -0
- trueconf/types/requests/__init__.py +21 -0
- trueconf/types/requests/added_chat_participant.py +40 -0
- trueconf/types/requests/created_channel.py +42 -0
- trueconf/types/requests/created_group_chat.py +42 -0
- trueconf/types/requests/created_personal_chat.py +42 -0
- trueconf/types/requests/edited_message.py +37 -0
- trueconf/types/requests/removed_chat.py +32 -0
- trueconf/types/requests/removed_chat_participant.py +39 -0
- trueconf/types/requests/removed_message.py +37 -0
- trueconf/types/requests/uploading_progress.py +34 -0
- trueconf/types/responses/__init__.py +57 -0
- trueconf/types/responses/add_chat_participant_response.py +8 -0
- trueconf/types/responses/api_error.py +38 -0
- trueconf/types/responses/auth_response_payload.py +9 -0
- trueconf/types/responses/create_channel_response.py +8 -0
- trueconf/types/responses/create_group_chat_response.py +8 -0
- trueconf/types/responses/create_p2p_chat_response.py +8 -0
- trueconf/types/responses/edit_message_response.py +9 -0
- trueconf/types/responses/edit_survey_response.py +9 -0
- trueconf/types/responses/forward_message_response.py +10 -0
- trueconf/types/responses/get_chat_by_id_response.py +13 -0
- trueconf/types/responses/get_chat_history_response.py +13 -0
- trueconf/types/responses/get_chat_participants_response.py +12 -0
- trueconf/types/responses/get_chats_response.py +12 -0
- trueconf/types/responses/get_file_info_response.py +24 -0
- trueconf/types/responses/get_message_by_id_response.py +26 -0
- trueconf/types/responses/get_user_display_name_response.py +8 -0
- trueconf/types/responses/has_chat_participant_response.py +8 -0
- trueconf/types/responses/remove_chat_participant_response.py +8 -0
- trueconf/types/responses/remove_chat_response.py +8 -0
- trueconf/types/responses/remove_message_response.py +8 -0
- trueconf/types/responses/send_file_response.py +10 -0
- trueconf/types/responses/send_message_response.py +10 -0
- trueconf/types/responses/send_survey_response.py +10 -0
- trueconf/types/responses/subscribe_file_progress_response.py +8 -0
- trueconf/types/responses/unsubscribe_file_progress_response.py +8 -0
- trueconf/types/responses/upload_file_response.py +8 -0
- trueconf/types/update.py +12 -0
- trueconf/utils/__init__.py +3 -0
- trueconf/utils/generate_secret_for_survey.py +10 -0
- trueconf/utils/token.py +78 -0
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
from .add_participant_to_chat import AddChatParticipant
|
|
2
|
+
from .auth import AuthMethod
|
|
3
|
+
from .base import MessageIdCounter
|
|
4
|
+
from .base import ReturnResolver
|
|
5
|
+
from trueconf.methods.base import TrueConfMethod
|
|
6
|
+
from .create_channel import CreateChannel
|
|
7
|
+
from .create_group_chat import CreateGroupChat
|
|
8
|
+
from .create_p2p_chat import CreateP2PChat
|
|
9
|
+
from .edit_message import EditMessage
|
|
10
|
+
from .edit_survey import EditSurvey
|
|
11
|
+
from .forward_message import ForwardMessage
|
|
12
|
+
from .get_chat_by_id import GetChatByID
|
|
13
|
+
from .get_chat_history import GetChatHistory
|
|
14
|
+
from .get_chat_participants import GetChatParticipants
|
|
15
|
+
from .get_chats import GetChats
|
|
16
|
+
from .get_file_info import GetFileInfo
|
|
17
|
+
from .get_message_by_id import GetMessageById
|
|
18
|
+
from .get_user_display_name import GetUserDisplayName
|
|
19
|
+
from .has_chat_participant import HasChatParticipant
|
|
20
|
+
from .remove_chat import RemoveChat
|
|
21
|
+
from .remove_message import RemoveMessage
|
|
22
|
+
from .remove_participant_from_chat import RemoveChatParticipant
|
|
23
|
+
from .send_file import SendFile
|
|
24
|
+
from .send_message import SendMessage
|
|
25
|
+
from .send_survey import SendSurvey
|
|
26
|
+
from .subscribe_file_progress import SubscribeFileProgress
|
|
27
|
+
from .unsubscribe_file_progress import UnsubscribeFileProgress
|
|
28
|
+
from .upload_file import UploadFile
|
|
29
|
+
|
|
30
|
+
__all__ = [
|
|
31
|
+
'CreateGroupChat',
|
|
32
|
+
'AuthMethod',
|
|
33
|
+
'EditSurvey',
|
|
34
|
+
'GetFileInfo',
|
|
35
|
+
'RemoveChatParticipant',
|
|
36
|
+
'GetUserDisplayName',
|
|
37
|
+
'ForwardMessage',
|
|
38
|
+
'SendMessage',
|
|
39
|
+
'CreateChannel',
|
|
40
|
+
'EditMessage',
|
|
41
|
+
'GetChatHistory',
|
|
42
|
+
'GetChatParticipants',
|
|
43
|
+
'HasChatParticipant',
|
|
44
|
+
'UnsubscribeFileProgress',
|
|
45
|
+
'SendSurvey',
|
|
46
|
+
'RemoveMessage',
|
|
47
|
+
'GetChats',
|
|
48
|
+
'GetMessageById',
|
|
49
|
+
'SubscribeFileProgress',
|
|
50
|
+
'SendFile',
|
|
51
|
+
'UploadFile',
|
|
52
|
+
'CreateP2PChat',
|
|
53
|
+
'RemoveChat',
|
|
54
|
+
'ReturnResolver',
|
|
55
|
+
'MessageIdCounter',
|
|
56
|
+
'TrueConfMethod',
|
|
57
|
+
'GetChatByID',
|
|
58
|
+
'AddChatParticipant'
|
|
59
|
+
]
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
from dataclasses import dataclass
|
|
3
|
+
from trueconf.methods.base import TrueConfMethod
|
|
4
|
+
from trueconf.types.responses.add_chat_participant_response import AddChatParticipantResponse
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@dataclass
|
|
8
|
+
class AddChatParticipant(TrueConfMethod[AddChatParticipantResponse]):
|
|
9
|
+
__api_method__ = "addChatParticipant"
|
|
10
|
+
__returning__ = AddChatParticipantResponse
|
|
11
|
+
|
|
12
|
+
chat_id: str
|
|
13
|
+
user_id: str
|
|
14
|
+
|
|
15
|
+
def __post_init__(self):
|
|
16
|
+
super().__init__()
|
|
17
|
+
|
|
18
|
+
def payload(self):
|
|
19
|
+
return {
|
|
20
|
+
"chatId": self.chat_id,
|
|
21
|
+
"userId": self.user_id
|
|
22
|
+
}
|
trueconf/methods/auth.py
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
from dataclasses import dataclass
|
|
3
|
+
from trueconf.methods.base import TrueConfMethod
|
|
4
|
+
from trueconf.types.responses.auth_response_payload import AuthResponsePayload
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@dataclass
|
|
8
|
+
class AuthMethod(TrueConfMethod[AuthResponsePayload]):
|
|
9
|
+
__api_method__ = "auth"
|
|
10
|
+
__returning__ = AuthResponsePayload
|
|
11
|
+
|
|
12
|
+
token: str
|
|
13
|
+
tokenType: str = "JWT"
|
|
14
|
+
receive_unread_messages: bool = False
|
|
15
|
+
|
|
16
|
+
def __post_init__(self):
|
|
17
|
+
super().__init__()
|
|
18
|
+
|
|
19
|
+
def payload(self) -> dict:
|
|
20
|
+
return {
|
|
21
|
+
"token": self.token,
|
|
22
|
+
"tokenType": self.tokenType,
|
|
23
|
+
"receiveUnread": self.receive_unread_messages
|
|
24
|
+
|
|
25
|
+
}
|
trueconf/methods/base.py
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
import logging
|
|
3
|
+
from asyncio import get_running_loop
|
|
4
|
+
from abc import ABC, abstractmethod
|
|
5
|
+
from typing import TypeVar, Generic, TYPE_CHECKING, ClassVar, Protocol, runtime_checkable
|
|
6
|
+
from trueconf.exceptions import ApiError as ApiErrorException
|
|
7
|
+
from trueconf.types.responses.api_error import ApiError
|
|
8
|
+
|
|
9
|
+
logger = logging.getLogger("chat_bot")
|
|
10
|
+
|
|
11
|
+
T = TypeVar("T")
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
@runtime_checkable
|
|
15
|
+
class ReturnResolver(Protocol[T]):
|
|
16
|
+
@staticmethod
|
|
17
|
+
def parse(resp: dict) -> T: ...
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class MessageIdCounter:
|
|
21
|
+
_counter = 0
|
|
22
|
+
|
|
23
|
+
@classmethod
|
|
24
|
+
def get_next_id(cls) -> int:
|
|
25
|
+
cls._counter += 1
|
|
26
|
+
return cls._counter
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class TrueConfMethod(ABC, Generic[T]):
|
|
30
|
+
def __init__(self):
|
|
31
|
+
self.id = MessageIdCounter.get_next_id()
|
|
32
|
+
|
|
33
|
+
if TYPE_CHECKING:
|
|
34
|
+
__api_method__: ClassVar[str]
|
|
35
|
+
__returning__: ClassVar[type[T]]
|
|
36
|
+
else:
|
|
37
|
+
@property
|
|
38
|
+
@abstractmethod
|
|
39
|
+
def __api_method__(self) -> str:
|
|
40
|
+
...
|
|
41
|
+
|
|
42
|
+
@property
|
|
43
|
+
@abstractmethod
|
|
44
|
+
def __returning__(self) -> type[T]:
|
|
45
|
+
...
|
|
46
|
+
|
|
47
|
+
@abstractmethod
|
|
48
|
+
def payload(self) -> dict:
|
|
49
|
+
...
|
|
50
|
+
|
|
51
|
+
def _parse_return(self, resp: dict) -> T:
|
|
52
|
+
ret = self.__returning__
|
|
53
|
+
|
|
54
|
+
payload = (resp.get("payload") or {})
|
|
55
|
+
|
|
56
|
+
# 2) Ошибка API имеет приоритет
|
|
57
|
+
if isinstance(payload, dict) and payload.get("errorCode", 0) != 0:
|
|
58
|
+
return ApiError.from_dict(payload) # type: ignore[return-value] # type: ignore[return-value]
|
|
59
|
+
|
|
60
|
+
# 1) Кастомный парсер (если класс его предоставляет)
|
|
61
|
+
if hasattr(ret, "parse"):
|
|
62
|
+
return ret.parse(resp) # type: ignore[return-value]
|
|
63
|
+
|
|
64
|
+
# 3) Если просят dict — отдать как есть
|
|
65
|
+
if ret is dict:
|
|
66
|
+
return payload # type: ignore[return-value]
|
|
67
|
+
|
|
68
|
+
# 4) Поддержка mashumaro: есть from_dict -> используем alias-ы
|
|
69
|
+
if hasattr(ret, "from_dict"):
|
|
70
|
+
if isinstance(payload, list):
|
|
71
|
+
return ret.from_dict({"chats": payload}) # type: ignore[return-value]
|
|
72
|
+
return ret.from_dict(payload) # type: ignore[return-value]
|
|
73
|
+
|
|
74
|
+
# 5) Фоллбек: прямой конструктор (без alias-ов)
|
|
75
|
+
return ret(**payload) # type: ignore[misc]
|
|
76
|
+
|
|
77
|
+
async def __call__(self, bot: "ChatBot") -> T:
|
|
78
|
+
loop = get_running_loop()
|
|
79
|
+
future = loop.create_future()
|
|
80
|
+
bot._register_future(self.id, future)
|
|
81
|
+
|
|
82
|
+
try:
|
|
83
|
+
message = {
|
|
84
|
+
"type": 1,
|
|
85
|
+
"id": self.id,
|
|
86
|
+
"method": self.__api_method__,
|
|
87
|
+
"payload": self.payload(),
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
except AttributeError:
|
|
91
|
+
raise RuntimeError(
|
|
92
|
+
f"{type(self).__name__} must define __api_method__ and __returning__"
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
logger.debug(f"📤 Sending message: {message}")
|
|
96
|
+
|
|
97
|
+
await bot._send_ws_payload(message)
|
|
98
|
+
|
|
99
|
+
data = await future
|
|
100
|
+
logger.debug(f"✅ Received response for {self.__api_method__}: {data}")
|
|
101
|
+
|
|
102
|
+
result = self._parse_return(data)
|
|
103
|
+
|
|
104
|
+
if isinstance(result, ApiError):
|
|
105
|
+
raise ApiErrorException(str(result))
|
|
106
|
+
|
|
107
|
+
return result
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
from dataclasses import dataclass
|
|
3
|
+
from trueconf.methods.base import TrueConfMethod
|
|
4
|
+
from trueconf.types.responses.create_channel_response import CreateChannelResponse
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@dataclass
|
|
8
|
+
class CreateChannel(TrueConfMethod[CreateChannelResponse]):
|
|
9
|
+
__api_method__ = "createChannel"
|
|
10
|
+
__returning__ = CreateChannelResponse
|
|
11
|
+
|
|
12
|
+
title: str
|
|
13
|
+
|
|
14
|
+
def __post_init__(self):
|
|
15
|
+
super().__init__()
|
|
16
|
+
|
|
17
|
+
def payload(self):
|
|
18
|
+
return {
|
|
19
|
+
"title": self.title,
|
|
20
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
from dataclasses import dataclass
|
|
3
|
+
from trueconf.methods.base import TrueConfMethod
|
|
4
|
+
from trueconf.types.responses.create_group_chat_response import CreateGroupChatResponse
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@dataclass
|
|
8
|
+
class CreateGroupChat(TrueConfMethod[CreateGroupChatResponse]):
|
|
9
|
+
__api_method__ = "createGroupChat"
|
|
10
|
+
__returning__ = CreateGroupChatResponse
|
|
11
|
+
|
|
12
|
+
title: str
|
|
13
|
+
|
|
14
|
+
def __post_init__(self):
|
|
15
|
+
super().__init__()
|
|
16
|
+
|
|
17
|
+
def payload(self):
|
|
18
|
+
return {
|
|
19
|
+
"title": self.title,
|
|
20
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
from dataclasses import dataclass
|
|
3
|
+
from trueconf.methods.base import TrueConfMethod
|
|
4
|
+
from trueconf.types.responses.create_p2p_chat_response import CreateP2PChatResponse
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@dataclass
|
|
8
|
+
class CreateP2PChat(TrueConfMethod[CreateP2PChatResponse]):
|
|
9
|
+
__api_method__ = "createP2PChat"
|
|
10
|
+
__returning__ = CreateP2PChatResponse
|
|
11
|
+
|
|
12
|
+
user_id: str
|
|
13
|
+
|
|
14
|
+
def __post_init__(self):
|
|
15
|
+
super().__init__()
|
|
16
|
+
|
|
17
|
+
def payload(self):
|
|
18
|
+
return {
|
|
19
|
+
"userId": self.user_id,
|
|
20
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
from dataclasses import dataclass
|
|
3
|
+
from trueconf.methods.base import TrueConfMethod
|
|
4
|
+
from trueconf.types.responses.edit_message_response import EditMessageResponse
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@dataclass
|
|
8
|
+
class EditMessage(TrueConfMethod[EditMessageResponse]):
|
|
9
|
+
__api_method__ = "editMessage"
|
|
10
|
+
__returning__ = EditMessageResponse
|
|
11
|
+
message_id: str
|
|
12
|
+
text: str
|
|
13
|
+
parse_mode: str
|
|
14
|
+
|
|
15
|
+
def __post_init__(self):
|
|
16
|
+
super().__init__()
|
|
17
|
+
|
|
18
|
+
def payload(self):
|
|
19
|
+
return {
|
|
20
|
+
"messageId": self.message_id,
|
|
21
|
+
"content": {
|
|
22
|
+
"text": self.text,
|
|
23
|
+
"parseMode": self.parse_mode,
|
|
24
|
+
},
|
|
25
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
from dataclasses import dataclass
|
|
3
|
+
from trueconf.methods.base import TrueConfMethod
|
|
4
|
+
from trueconf.types.responses.edit_survey_response import EditSurveyResponse
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@dataclass
|
|
8
|
+
class EditSurvey(TrueConfMethod[EditSurveyResponse]):
|
|
9
|
+
__api_method__ = "editSurvey"
|
|
10
|
+
__returning__ = EditSurveyResponse
|
|
11
|
+
|
|
12
|
+
message_id: str
|
|
13
|
+
server: str
|
|
14
|
+
path: str
|
|
15
|
+
title: str
|
|
16
|
+
description: str
|
|
17
|
+
button_text: str = "{{Go to survey}}"
|
|
18
|
+
|
|
19
|
+
def __post_init__(self):
|
|
20
|
+
super().__init__()
|
|
21
|
+
|
|
22
|
+
def payload(self):
|
|
23
|
+
return {
|
|
24
|
+
"messageId": self.message_id,
|
|
25
|
+
"content": {
|
|
26
|
+
"path": self.path,
|
|
27
|
+
"title": self.title,
|
|
28
|
+
"description": self.description,
|
|
29
|
+
"buttonText": self.button_text,
|
|
30
|
+
"alt": f"📊 <a href='https://{self.server}/webtools/survey?id={self.path}&error=autologin_not_supported'>{self.title}</a>"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
from dataclasses import dataclass
|
|
3
|
+
from trueconf.methods.base import TrueConfMethod
|
|
4
|
+
from trueconf.types.responses.forward_message_response import ForwardMessageResponse
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@dataclass
|
|
8
|
+
class ForwardMessage(TrueConfMethod[ForwardMessageResponse]):
|
|
9
|
+
__api_method__ = "forwardMessage"
|
|
10
|
+
__returning__ = ForwardMessageResponse
|
|
11
|
+
|
|
12
|
+
message_id: str
|
|
13
|
+
chat_id: str
|
|
14
|
+
|
|
15
|
+
def __post_init__(self):
|
|
16
|
+
super().__init__()
|
|
17
|
+
|
|
18
|
+
def payload(self):
|
|
19
|
+
return {
|
|
20
|
+
"messageId": self.message_id,
|
|
21
|
+
"chatId": self.chat_id,
|
|
22
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
from dataclasses import dataclass
|
|
3
|
+
from trueconf.methods.base import TrueConfMethod
|
|
4
|
+
from trueconf.types.responses.get_chat_by_id_response import GetChatByIdResponse
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@dataclass
|
|
8
|
+
class GetChatByID(TrueConfMethod[GetChatByIdResponse]):
|
|
9
|
+
__api_method__ = "getChatByID"
|
|
10
|
+
__returning__ = GetChatByIdResponse
|
|
11
|
+
|
|
12
|
+
chat_id: str
|
|
13
|
+
|
|
14
|
+
def __post_init__(self):
|
|
15
|
+
super().__init__()
|
|
16
|
+
|
|
17
|
+
def payload(self):
|
|
18
|
+
return {
|
|
19
|
+
"chatId": self.chat_id
|
|
20
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
from dataclasses import dataclass
|
|
3
|
+
from trueconf.methods.base import TrueConfMethod
|
|
4
|
+
from trueconf.types.responses.get_chat_history_response import GetChatHistoryResponse
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@dataclass
|
|
8
|
+
class GetChatHistory(TrueConfMethod[GetChatHistoryResponse]):
|
|
9
|
+
__api_method__ = "getChatHistory"
|
|
10
|
+
__returning__ = GetChatHistoryResponse
|
|
11
|
+
|
|
12
|
+
chat_id: str
|
|
13
|
+
count: int
|
|
14
|
+
from_message_id: str | None = None
|
|
15
|
+
|
|
16
|
+
def __post_init__(self):
|
|
17
|
+
super().__init__()
|
|
18
|
+
|
|
19
|
+
def payload(self):
|
|
20
|
+
return {
|
|
21
|
+
"chatId": self.chat_id,
|
|
22
|
+
"count": self.count,
|
|
23
|
+
"fromMessageId": self.from_message_id,
|
|
24
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
from dataclasses import dataclass
|
|
3
|
+
from trueconf.methods.base import TrueConfMethod
|
|
4
|
+
from trueconf.types.responses.get_chat_participants_response import GetChatParticipantsResponse
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@dataclass
|
|
8
|
+
class GetChatParticipants(TrueConfMethod[GetChatParticipantsResponse]):
|
|
9
|
+
__api_method__ = "getChatParticipants"
|
|
10
|
+
__returning__ = GetChatParticipantsResponse
|
|
11
|
+
|
|
12
|
+
chat_id: str
|
|
13
|
+
page_size: int
|
|
14
|
+
page_number: int
|
|
15
|
+
|
|
16
|
+
def __post_init__(self):
|
|
17
|
+
super().__init__()
|
|
18
|
+
|
|
19
|
+
def payload(self):
|
|
20
|
+
return {
|
|
21
|
+
"chatId": self.chat_id,
|
|
22
|
+
"pageSize": self.page_size,
|
|
23
|
+
"pageNumber": self.page_number,
|
|
24
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
from dataclasses import dataclass
|
|
3
|
+
from trueconf.methods.base import TrueConfMethod
|
|
4
|
+
from trueconf.types.responses.get_chats_response import GetChatsResponse
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@dataclass
|
|
8
|
+
class GetChats(TrueConfMethod[GetChatsResponse]):
|
|
9
|
+
__api_method__ = "getChats"
|
|
10
|
+
__returning__ = GetChatsResponse
|
|
11
|
+
|
|
12
|
+
count: int
|
|
13
|
+
page: int
|
|
14
|
+
|
|
15
|
+
def __post_init__(self):
|
|
16
|
+
super().__init__()
|
|
17
|
+
|
|
18
|
+
def payload(self):
|
|
19
|
+
return {
|
|
20
|
+
"count": self.count,
|
|
21
|
+
"page": self.page,
|
|
22
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
from dataclasses import dataclass
|
|
3
|
+
from trueconf.methods.base import TrueConfMethod
|
|
4
|
+
from trueconf.types.responses.get_file_info_response import GetFileInfoResponse
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@dataclass
|
|
8
|
+
class GetFileInfo(TrueConfMethod[GetFileInfoResponse]):
|
|
9
|
+
__api_method__ = "getFileInfo"
|
|
10
|
+
__returning__ = GetFileInfoResponse
|
|
11
|
+
|
|
12
|
+
file_id: str
|
|
13
|
+
|
|
14
|
+
def __post_init__(self):
|
|
15
|
+
super().__init__()
|
|
16
|
+
|
|
17
|
+
def payload(self):
|
|
18
|
+
return {
|
|
19
|
+
"fileId": self.file_id
|
|
20
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
from dataclasses import dataclass
|
|
3
|
+
from trueconf.methods.base import TrueConfMethod
|
|
4
|
+
from trueconf.types.responses.get_message_by_id_response import GetMessageByIdResponse
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@dataclass
|
|
8
|
+
class GetMessageById(TrueConfMethod[GetMessageByIdResponse]):
|
|
9
|
+
__api_method__ = "getMessageById"
|
|
10
|
+
__returning__ = GetMessageByIdResponse
|
|
11
|
+
message_id: str
|
|
12
|
+
|
|
13
|
+
def __post_init__(self):
|
|
14
|
+
super().__init__()
|
|
15
|
+
|
|
16
|
+
def payload(self):
|
|
17
|
+
return {
|
|
18
|
+
"messageId": self.message_id
|
|
19
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
from dataclasses import dataclass
|
|
3
|
+
from trueconf.methods.base import TrueConfMethod
|
|
4
|
+
from trueconf.types.responses.get_user_display_name_response import GetUserDisplayNameResponse
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@dataclass
|
|
8
|
+
class GetUserDisplayName(TrueConfMethod[GetUserDisplayNameResponse]):
|
|
9
|
+
__api_method__ = "getUserDisplayName"
|
|
10
|
+
__returning__ = GetUserDisplayNameResponse
|
|
11
|
+
|
|
12
|
+
user_id: str
|
|
13
|
+
|
|
14
|
+
def __post_init__(self):
|
|
15
|
+
super().__init__()
|
|
16
|
+
|
|
17
|
+
def payload(self):
|
|
18
|
+
return {
|
|
19
|
+
"userId": self.user_id,
|
|
20
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
from dataclasses import dataclass
|
|
3
|
+
from trueconf.methods.base import TrueConfMethod
|
|
4
|
+
from trueconf.types.responses.has_chat_participant_response import HasChatParticipantResponse
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@dataclass
|
|
8
|
+
class HasChatParticipant(TrueConfMethod[HasChatParticipantResponse]):
|
|
9
|
+
__api_method__ = "hasChatParticipant"
|
|
10
|
+
__returning__ = HasChatParticipantResponse
|
|
11
|
+
|
|
12
|
+
chat_id: str
|
|
13
|
+
user_id: str
|
|
14
|
+
|
|
15
|
+
def __post_init__(self):
|
|
16
|
+
super().__init__()
|
|
17
|
+
|
|
18
|
+
def payload(self):
|
|
19
|
+
return {
|
|
20
|
+
"chatId": self.chat_id,
|
|
21
|
+
"userId": self.user_id
|
|
22
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
from dataclasses import dataclass
|
|
3
|
+
from trueconf.methods.base import TrueConfMethod
|
|
4
|
+
from trueconf.types.responses.remove_chat_response import RemoveChatResponse
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@dataclass
|
|
8
|
+
class RemoveChat(TrueConfMethod[RemoveChatResponse]):
|
|
9
|
+
__api_method__ = "removeChat"
|
|
10
|
+
__returning__ = RemoveChatResponse
|
|
11
|
+
|
|
12
|
+
chat_id: str
|
|
13
|
+
|
|
14
|
+
def __post_init__(self):
|
|
15
|
+
super().__init__()
|
|
16
|
+
|
|
17
|
+
def payload(self):
|
|
18
|
+
return {
|
|
19
|
+
"chatId": self.chat_id,
|
|
20
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
from dataclasses import dataclass
|
|
4
|
+
from trueconf.methods.base import TrueConfMethod
|
|
5
|
+
from trueconf.types.responses.remove_message_response import RemoveMessageResponse
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@dataclass
|
|
9
|
+
class RemoveMessage(TrueConfMethod[RemoveMessageResponse]):
|
|
10
|
+
__api_method__ = "removeMessage"
|
|
11
|
+
__returning__ = RemoveMessageResponse
|
|
12
|
+
|
|
13
|
+
message_id: str
|
|
14
|
+
for_all: bool
|
|
15
|
+
|
|
16
|
+
def __post_init__(self):
|
|
17
|
+
super().__init__()
|
|
18
|
+
|
|
19
|
+
def payload(self):
|
|
20
|
+
return {
|
|
21
|
+
"messageId": self.message_id,
|
|
22
|
+
"forAll": self.for_all
|
|
23
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
from dataclasses import dataclass
|
|
4
|
+
from trueconf.methods.base import TrueConfMethod
|
|
5
|
+
from trueconf.types.responses.remove_chat_participant_response import RemoveChatParticipantResponse
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@dataclass
|
|
9
|
+
class RemoveChatParticipant(TrueConfMethod[RemoveChatParticipantResponse]):
|
|
10
|
+
__api_method__ = "removeChatParticipant"
|
|
11
|
+
__returning__ = RemoveChatParticipantResponse
|
|
12
|
+
|
|
13
|
+
chat_id: str
|
|
14
|
+
user_id: str
|
|
15
|
+
|
|
16
|
+
def __post_init__(self):
|
|
17
|
+
super().__init__()
|
|
18
|
+
|
|
19
|
+
def payload(self):
|
|
20
|
+
return {
|
|
21
|
+
"chatId": self.chat_id,
|
|
22
|
+
"userId": self.user_id
|
|
23
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
from dataclasses import dataclass
|
|
4
|
+
from trueconf.methods.base import TrueConfMethod
|
|
5
|
+
from trueconf.types.responses.send_file_response import SendFileResponse
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@dataclass
|
|
9
|
+
class SendFile(TrueConfMethod[SendFileResponse]):
|
|
10
|
+
__api_method__ = "sendFile"
|
|
11
|
+
__returning__ = SendFileResponse
|
|
12
|
+
|
|
13
|
+
chat_id: str
|
|
14
|
+
temporal_file_id: str
|
|
15
|
+
|
|
16
|
+
def __post_init__(self):
|
|
17
|
+
super().__init__()
|
|
18
|
+
|
|
19
|
+
def payload(self):
|
|
20
|
+
return {
|
|
21
|
+
"chatId": self.chat_id,
|
|
22
|
+
"content": {
|
|
23
|
+
"temporalFileId": self.temporal_file_id,
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
from dataclasses import dataclass
|
|
4
|
+
from typing import Optional
|
|
5
|
+
from trueconf.methods.base import TrueConfMethod
|
|
6
|
+
from trueconf.types.responses.send_message_response import SendMessageResponse
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@dataclass
|
|
10
|
+
class SendMessage(TrueConfMethod[SendMessageResponse]):
|
|
11
|
+
__api_method__ = "sendMessage"
|
|
12
|
+
__returning__ = SendMessageResponse
|
|
13
|
+
chat_id: str
|
|
14
|
+
text: str
|
|
15
|
+
parse_mode: str
|
|
16
|
+
reply_message_id: Optional[str] = None
|
|
17
|
+
|
|
18
|
+
def __post_init__(self):
|
|
19
|
+
super().__init__()
|
|
20
|
+
|
|
21
|
+
def payload(self):
|
|
22
|
+
return {
|
|
23
|
+
"chatId": self.chat_id,
|
|
24
|
+
"replyMessageId": self.reply_message_id,
|
|
25
|
+
"content": {
|
|
26
|
+
"text": self.text,
|
|
27
|
+
"parseMode": self.parse_mode,
|
|
28
|
+
},
|
|
29
|
+
}
|