-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Update README.md * Add docs for FastAPI middlewares * Add docs-linter
- Loading branch information
Showing
12 changed files
with
210 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,3 +36,4 @@ jobs: | |
- name: Run lint | ||
run: | | ||
poetry run ./scripts/lint | ||
poetry run ./scripts/docs-lint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from typing import Any, Dict, Literal, Optional | ||
from urllib.error import HTTPError | ||
|
||
from httpx import AsyncClient, HTTPStatusError | ||
|
||
from pybotx_smart_logger import smart_log | ||
|
||
base_url = "" | ||
|
||
|
||
class ResponseSchema: | ||
pass # noqa: WPS420, WPS604 | ||
|
||
|
||
class RequestToAwesomeAPIError(Exception): | ||
pass # noqa: WPS420, WPS604 | ||
|
||
|
||
class InvalidStatusCodeFromAwesomeAPIError(Exception): | ||
pass # noqa: WPS420, WPS604 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from pybotx import Bot, IncomingMessage, IncomingMessageHandlerFunc, OutgoingMessage | ||
|
||
from pybotx_smart_logger import smart_log | ||
|
||
|
||
def only_subscribed_users_allowed_message(message: IncomingMessage) -> OutgoingMessage: | ||
return OutgoingMessage( | ||
bot_id=message.bot.id, | ||
chat_id=message.chat.id, | ||
body=message.body, | ||
) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from typing import Any, Dict | ||
|
||
from pybotx_smart_logger import wrap_smart_logger | ||
|
||
kwargs: Dict[Any, Any] = {} | ||
|
||
|
||
async def make_request(**kwargs1: Dict[Any, Any]) -> Dict[Any, Any]: | ||
return kwargs1 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from uuid import UUID | ||
|
||
from pybotx import Bot, HandlerCollector, IncomingMessage | ||
|
||
collector = HandlerCollector() | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from pybotx import Bot, HandlerCollector, IncomingMessage | ||
|
||
collector = HandlerCollector() | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from typing import Callable | ||
|
||
from fastapi import FastAPI, Request | ||
|
||
from pybotx_smart_logger import wrap_smart_logger | ||
|
||
|
||
def pformat_str_request(request: Request) -> str: | ||
return "" | ||
|
||
|
||
DEBUG = True | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from uuid import uuid4 | ||
|
||
from pybotx import ( | ||
Bot, | ||
BotAccountWithSecret, | ||
HandlerCollector, | ||
IncomingMessage, | ||
IncomingMessageHandlerFunc, | ||
) | ||
|
||
|
||
async def smart_logger_middleware( | ||
message: IncomingMessage, | ||
bot: Bot, | ||
call_next: IncomingMessageHandlerFunc, | ||
) -> None: | ||
return # noqa: WPS324 | ||
|
||
|
||
collector = HandlerCollector() | ||
BOT_CREDENTIALS = BotAccountWithSecret( # noqa: S106 | ||
secret_key="", | ||
host="", | ||
id=uuid4(), | ||
) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from typing import Optional | ||
|
||
from pybotx import Bot, IncomingMessage, IncomingMessageHandlerFunc | ||
|
||
from pybotx_smart_logger import wrap_smart_logger | ||
|
||
|
||
def format_raw_command(command: Optional[dict]) -> str: | ||
return str(command) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.