Skip to content

Commit 125f094

Browse files
committed
Merge remote-tracking branch 'origin/master' into fix/docs-update-and-dropped-support-3.8
# Conflicts: # .github/workflows/python-app.yml # README.md # poetry.lock # pyproject.toml
2 parents 110b2bf + 99ede80 commit 125f094

File tree

90 files changed

+4479
-262
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+4479
-262
lines changed

.github/dependabot.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "pip"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"
7+
labels:
8+
- dependencies

.github/renovate.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

pybotx/__init__.py

Lines changed: 56 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,31 @@
33
UnsupportedBotAPIVersionError,
44
)
55
from pybotx.bot.api.responses.bot_disabled import (
6+
BotAPIBotDisabledErrorData,
67
BotAPIBotDisabledResponse,
78
build_bot_disabled_response,
89
)
910
from pybotx.bot.api.responses.command_accepted import build_command_accepted_response
11+
from pybotx.bot.api.responses.unverified_request import (
12+
BotAPIUnverifiedRequestErrorData,
13+
BotAPIUnverifiedRequestResponse,
14+
build_unverified_request_response,
15+
)
1016
from pybotx.bot.bot import Bot
1117
from pybotx.bot.callbacks.callback_repo_proto import CallbackRepoProto
1218
from pybotx.bot.exceptions import (
1319
AnswerDestinationLookupError,
1420
BotShuttingDownError,
1521
BotXMethodCallbackNotFoundError,
22+
RequestHeadersNotProvidedError,
1623
UnknownBotAccountError,
24+
UnverifiedRequestError,
25+
)
26+
from pybotx.bot.handler import (
27+
IncomingMessageHandlerFunc,
28+
Middleware,
29+
SyncSmartAppEventHandlerFunc,
1730
)
18-
from pybotx.bot.handler import IncomingMessageHandlerFunc, Middleware
1931
from pybotx.bot.handler_collector import HandlerCollector
2032
from pybotx.bot.testing import lifespan_wrapper
2133
from pybotx.client.exceptions.callbacks import (
@@ -40,12 +52,22 @@
4052
InvalidBotXResponsePayloadError,
4153
InvalidBotXStatusCodeError,
4254
)
55+
from pybotx.client.exceptions.message import MessageNotFoundError
4356
from pybotx.client.exceptions.notifications import (
4457
BotIsNotChatMemberError,
4558
FinalRecipientsListEmptyError,
4659
StealthModeDisabledError,
4760
)
4861
from pybotx.client.exceptions.users import UserNotFoundError
62+
from pybotx.client.smartapps_api.exceptions import SyncSmartAppEventHandlerNotFoundError
63+
from pybotx.client.smartapps_api.smartapp_manifest import (
64+
SmartappManifest,
65+
SmartappManifestAndroidParams,
66+
SmartappManifestAuroraParams,
67+
SmartappManifestIosParams,
68+
SmartappManifestUnreadCounterParams,
69+
SmartappManifestWebParams,
70+
)
4971
from pybotx.client.stickers_api.exceptions import (
5072
InvalidEmojiError,
5173
InvalidImageError,
@@ -61,13 +83,15 @@
6183
OutgoingAttachment,
6284
)
6385
from pybotx.models.bot_account import BotAccount, BotAccountWithSecret
86+
from pybotx.models.bot_catalog import BotsListItem
6487
from pybotx.models.bot_sender import BotSender
6588
from pybotx.models.chats import Chat, ChatInfo, ChatInfoMember, ChatListItem
6689
from pybotx.models.enums import (
6790
AttachmentTypes,
6891
ChatTypes,
6992
ClientPlatforms,
7093
MentionTypes,
94+
SmartappManifestWebLayoutChoices,
7195
SyncSourceTypes,
7296
UserKinds,
7397
)
@@ -103,11 +127,18 @@
103127
from pybotx.models.smartapps import SmartApp
104128
from pybotx.models.status import BotMenu, StatusRecipient
105129
from pybotx.models.stickers import Sticker, StickerPack
130+
from pybotx.models.sync_smartapp_event import (
131+
BotAPISyncSmartAppEventErrorResponse,
132+
BotAPISyncSmartAppEventResponse,
133+
BotAPISyncSmartAppEventResultResponse,
134+
)
106135
from pybotx.models.system_events.added_to_chat import AddedToChatEvent
107136
from pybotx.models.system_events.chat_created import ChatCreatedEvent, ChatCreatedMember
137+
from pybotx.models.system_events.chat_deleted_by_user import ChatDeletedByUserEvent
108138
from pybotx.models.system_events.cts_login import CTSLoginEvent
109139
from pybotx.models.system_events.cts_logout import CTSLogoutEvent
110140
from pybotx.models.system_events.deleted_from_chat import DeletedFromChatEvent
141+
from pybotx.models.system_events.event_edit import EventEdit
111142
from pybotx.models.system_events.internal_bot_notification import (
112143
InternalBotNotificationEvent,
113144
)
@@ -118,14 +149,20 @@
118149
__all__ = (
119150
"AddedToChatEvent",
120151
"AnswerDestinationLookupError",
121-
"AttachmentTypes",
122152
"AttachmentDocument",
123153
"AttachmentImage",
124-
"AttachmentVoice",
154+
"AttachmentTypes",
125155
"AttachmentVideo",
156+
"AttachmentVoice",
126157
"Bot",
158+
"BotAPIBotDisabledErrorData",
127159
"BotAPIBotDisabledResponse",
128160
"BotAPIMethodFailedCallback",
161+
"BotAPISyncSmartAppEventErrorResponse",
162+
"BotAPISyncSmartAppEventResponse",
163+
"BotAPISyncSmartAppEventResultResponse",
164+
"BotAPIUnverifiedRequestErrorData",
165+
"BotAPIUnverifiedRequestResponse",
129166
"BotAccount",
130167
"BotAccountWithSecret",
131168
"BotIsNotChatMemberError",
@@ -134,6 +171,7 @@
134171
"BotShuttingDownError",
135172
"BotXMethodCallbackNotFoundError",
136173
"BotXMethodFailedCallbackReceivedError",
174+
"BotsListItem",
137175
"BubbleMarkup",
138176
"Button",
139177
"ButtonRow",
@@ -148,6 +186,7 @@
148186
"ChatCreatedMember",
149187
"ChatCreationError",
150188
"ChatCreationProhibitedError",
189+
"ChatDeletedByUserEvent",
151190
"ChatInfo",
152191
"ChatInfoMember",
153192
"ChatListItem",
@@ -157,6 +196,7 @@
157196
"DeletedFromChatEvent",
158197
"Document",
159198
"EditMessage",
199+
"EventEdit",
160200
"EventNotFoundError",
161201
"File",
162202
"FileDeletedError",
@@ -185,6 +225,7 @@
185225
"MentionList",
186226
"MentionTypes",
187227
"MentionUser",
228+
"MessageNotFoundError",
188229
"MessageStatus",
189230
"Middleware",
190231
"OutgoingAttachment",
@@ -193,18 +234,28 @@
193234
"RateLimitReachedError",
194235
"Reply",
195236
"ReplyMessage",
237+
"RequestHeadersNotProvidedError",
196238
"SmartApp",
197239
"SmartAppEvent",
198-
"SmartAppEvent",
240+
"SmartappManifest",
241+
"SmartappManifestAndroidParams",
242+
"SmartappManifestAuroraParams",
243+
"SmartappManifestIosParams",
244+
"SmartappManifestUnreadCounterParams",
245+
"SmartappManifestWebLayoutChoices",
246+
"SmartappManifestWebParams",
199247
"StatusRecipient",
200248
"StealthModeDisabledError",
201249
"Sticker",
202250
"StickerPack",
203251
"StickerPackOrStickerNotFoundError",
252+
"SyncSmartAppEventHandlerFunc",
253+
"SyncSmartAppEventHandlerNotFoundError",
204254
"SyncSourceTypes",
205255
"UnknownBotAccountError",
206256
"UnknownSystemEventError",
207257
"UnsupportedBotAPIVersionError",
258+
"UnverifiedRequestError",
208259
"UserDevice",
209260
"UserFromCSV",
210261
"UserFromSearch",
@@ -215,6 +266,7 @@
215266
"Voice",
216267
"build_bot_disabled_response",
217268
"build_command_accepted_response",
269+
"build_unverified_request_response",
218270
"lifespan_wrapper",
219271
)
220272

pybotx/async_buffer.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,6 @@ async def write(self, content: bytes) -> int:
2020
... # noqa: WPS428
2121

2222

23-
class AsyncBufferUnicodeWritable(AsyncBufferBase):
24-
async def write(self, content: str) -> int:
25-
... # noqa: WPS428
26-
27-
2823
class AsyncBufferReadable(AsyncBufferBase):
2924
async def read(self, bytes_to_read: Optional[int] = None) -> bytes:
3025
... # noqa: WPS428

pybotx/bot/api/responses/bot_disabled.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class BotAPIBotDisabledResponse:
2323
def build_bot_disabled_response(status_message: str) -> Dict[str, Any]:
2424
"""Build bot disabled response for BotX.
2525
26-
It should be send if the bot can't process the command.
26+
It should be sent if the bot can't process the command.
2727
If you would like to build complex response, see `BotAPIBotDisabledResponse`.
2828
2929
:param status_message: Status message.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
from dataclasses import asdict, dataclass, field
2+
from typing import Any, Dict, List, Literal
3+
4+
5+
@dataclass
6+
class BotAPIUnverifiedRequestErrorData:
7+
status_message: str
8+
9+
10+
@dataclass
11+
class BotAPIUnverifiedRequestResponse:
12+
"""`Unverified request` response model.
13+
14+
Only `.error_data.status_message` attribute will be displayed to
15+
user. Other attributes will be visible only in BotX logs.
16+
"""
17+
18+
error_data: BotAPIUnverifiedRequestErrorData
19+
errors: List[str] = field(default_factory=list)
20+
reason: Literal["unverified_request"] = "unverified_request"
21+
22+
23+
def build_unverified_request_response(status_message: str) -> Dict[str, Any]:
24+
"""Build `unverified request` response for BotX.
25+
26+
It should be sent if the header with the authorization token is missing or
27+
the authorization token is invalid.
28+
If you would like to build complex response, see `BotAPIUnverifiedRequestResponse`.
29+
30+
:param status_message: Status message.
31+
32+
:return: Built `unverified request` response.
33+
"""
34+
35+
response = BotAPIUnverifiedRequestResponse(
36+
error_data=BotAPIUnverifiedRequestErrorData(status_message=status_message),
37+
)
38+
39+
return asdict(response)

0 commit comments

Comments
 (0)