aiogram-webhook 3.0.1__tar.gz → 3.1.0__tar.gz
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.
- {aiogram_webhook-3.0.1 → aiogram_webhook-3.1.0}/PKG-INFO +5 -32
- {aiogram_webhook-3.0.1 → aiogram_webhook-3.1.0}/README.md +4 -31
- {aiogram_webhook-3.0.1 → aiogram_webhook-3.1.0}/pyproject.toml +6 -1
- {aiogram_webhook-3.0.1 → aiogram_webhook-3.1.0}/src/aiogram_webhook/engines/base.py +0 -10
- {aiogram_webhook-3.0.1 → aiogram_webhook-3.1.0}/src/aiogram_webhook/web/fastapi.py +15 -4
- {aiogram_webhook-3.0.1 → aiogram_webhook-3.1.0}/src/aiogram_webhook/__init__.py +0 -0
- {aiogram_webhook-3.0.1 → aiogram_webhook-3.1.0}/src/aiogram_webhook/configs/__init__.py +0 -0
- {aiogram_webhook-3.0.1 → aiogram_webhook-3.1.0}/src/aiogram_webhook/configs/bot.py +0 -0
- {aiogram_webhook-3.0.1 → aiogram_webhook-3.1.0}/src/aiogram_webhook/configs/webhook.py +0 -0
- {aiogram_webhook-3.0.1 → aiogram_webhook-3.1.0}/src/aiogram_webhook/engines/__init__.py +0 -0
- {aiogram_webhook-3.0.1 → aiogram_webhook-3.1.0}/src/aiogram_webhook/engines/errors.py +0 -0
- {aiogram_webhook-3.0.1 → aiogram_webhook-3.1.0}/src/aiogram_webhook/engines/multi.py +0 -0
- {aiogram_webhook-3.0.1 → aiogram_webhook-3.1.0}/src/aiogram_webhook/engines/single.py +0 -0
- {aiogram_webhook-3.0.1 → aiogram_webhook-3.1.0}/src/aiogram_webhook/engines/target.py +0 -0
- {aiogram_webhook-3.0.1 → aiogram_webhook-3.1.0}/src/aiogram_webhook/engines/token.py +0 -0
- {aiogram_webhook-3.0.1 → aiogram_webhook-3.1.0}/src/aiogram_webhook/errors.py +0 -0
- {aiogram_webhook-3.0.1 → aiogram_webhook-3.1.0}/src/aiogram_webhook/logs.py +0 -0
- {aiogram_webhook-3.0.1 → aiogram_webhook-3.1.0}/src/aiogram_webhook/py.typed +0 -0
- {aiogram_webhook-3.0.1 → aiogram_webhook-3.1.0}/src/aiogram_webhook/route/__init__.py +0 -0
- {aiogram_webhook-3.0.1 → aiogram_webhook-3.1.0}/src/aiogram_webhook/route/config.py +0 -0
- {aiogram_webhook-3.0.1 → aiogram_webhook-3.1.0}/src/aiogram_webhook/route/errors.py +0 -0
- {aiogram_webhook-3.0.1 → aiogram_webhook-3.1.0}/src/aiogram_webhook/route/params.py +0 -0
- {aiogram_webhook-3.0.1 → aiogram_webhook-3.1.0}/src/aiogram_webhook/route/path.py +0 -0
- {aiogram_webhook-3.0.1 → aiogram_webhook-3.1.0}/src/aiogram_webhook/route/query.py +0 -0
- {aiogram_webhook-3.0.1 → aiogram_webhook-3.1.0}/src/aiogram_webhook/route/route.py +0 -0
- {aiogram_webhook-3.0.1 → aiogram_webhook-3.1.0}/src/aiogram_webhook/route/url.py +0 -0
- {aiogram_webhook-3.0.1 → aiogram_webhook-3.1.0}/src/aiogram_webhook/security/__init__.py +0 -0
- {aiogram_webhook-3.0.1 → aiogram_webhook-3.1.0}/src/aiogram_webhook/security/checks/__init__.py +0 -0
- {aiogram_webhook-3.0.1 → aiogram_webhook-3.1.0}/src/aiogram_webhook/security/checks/check.py +0 -0
- {aiogram_webhook-3.0.1 → aiogram_webhook-3.1.0}/src/aiogram_webhook/security/checks/ip.py +0 -0
- {aiogram_webhook-3.0.1 → aiogram_webhook-3.1.0}/src/aiogram_webhook/security/errors.py +0 -0
- {aiogram_webhook-3.0.1 → aiogram_webhook-3.1.0}/src/aiogram_webhook/security/secret_token.py +0 -0
- {aiogram_webhook-3.0.1 → aiogram_webhook-3.1.0}/src/aiogram_webhook/security/security.py +0 -0
- {aiogram_webhook-3.0.1 → aiogram_webhook-3.1.0}/src/aiogram_webhook/tasks.py +0 -0
- {aiogram_webhook-3.0.1 → aiogram_webhook-3.1.0}/src/aiogram_webhook/utils/__init__.py +0 -0
- {aiogram_webhook-3.0.1 → aiogram_webhook-3.1.0}/src/aiogram_webhook/utils/_payload.py +0 -0
- {aiogram_webhook-3.0.1 → aiogram_webhook-3.1.0}/src/aiogram_webhook/utils/config.py +0 -0
- {aiogram_webhook-3.0.1 → aiogram_webhook-3.1.0}/src/aiogram_webhook/web/__init__.py +0 -0
- {aiogram_webhook-3.0.1 → aiogram_webhook-3.1.0}/src/aiogram_webhook/web/_starlette.py +0 -0
- {aiogram_webhook-3.0.1 → aiogram_webhook-3.1.0}/src/aiogram_webhook/web/aiohttp.py +0 -0
- {aiogram_webhook-3.0.1 → aiogram_webhook-3.1.0}/src/aiogram_webhook/web/base.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: aiogram-webhook
|
|
3
|
-
Version: 3.0
|
|
3
|
+
Version: 3.1.0
|
|
4
4
|
Summary: A python library for integrating webhook support with multiple web frameworks in aiogram. Organizes bot operation via webhooks for both single and multi-bot setups.
|
|
5
5
|
Keywords: aiogram,multibot,telegram,webhook,fastapi,aiohttp
|
|
6
6
|
Author: m-xim
|
|
@@ -37,7 +37,7 @@ Provides-Extra: dev
|
|
|
37
37
|
Provides-Extra: fastapi
|
|
38
38
|
Description-Content-Type: text/markdown
|
|
39
39
|
|
|
40
|
-

|
|
41
41
|
|
|
42
42
|
# aiogram-webhook
|
|
43
43
|
[](https://pypi.org/project/aiogram-webhook)
|
|
@@ -45,11 +45,10 @@ Description-Content-Type: text/markdown
|
|
|
45
45
|
[](https://github.com/m-xim/aiogram-webhook/actions)
|
|
46
46
|
[](/LICENSE)
|
|
47
47
|
[](https://deepwiki.com/m-xim/aiogram-webhook)
|
|
48
|
-
[](https://github.com/astral-sh/ruff)
|
|
49
49
|
[](https://github.com/astral-sh/ty)
|
|
50
50
|
|
|
51
|
-
|
|
52
|
-
It supports single-bot and token-based multi-bot setups, with route building, optional request checks, and adapters for FastAPI and aiohttp.
|
|
51
|
+
Handles the webhook layer for aiogram bots. Registers the endpoint, calls Telegram `setWebhook`, verifies incoming requests, and manages engine lifecycle. Works with FastAPI and aiohttp.
|
|
53
52
|
|
|
54
53
|
## Install
|
|
55
54
|
|
|
@@ -59,35 +58,9 @@ pip install "aiogram-webhook[fastapi]"
|
|
|
59
58
|
pip install "aiogram-webhook[aiohttp]"
|
|
60
59
|
```
|
|
61
60
|
|
|
62
|
-
## Quick Start
|
|
63
|
-
|
|
64
|
-
```python
|
|
65
|
-
from aiogram import Bot, Dispatcher
|
|
66
|
-
from fastapi import FastAPI
|
|
67
|
-
|
|
68
|
-
from aiogram_webhook import FastAPIAdapter, SingleBotEngine
|
|
69
|
-
from aiogram_webhook.route import Route
|
|
70
|
-
|
|
71
|
-
dispatcher = Dispatcher()
|
|
72
|
-
bot = Bot("BOT_TOKEN")
|
|
73
|
-
|
|
74
|
-
engine = SingleBotEngine(
|
|
75
|
-
dispatcher,
|
|
76
|
-
bot,
|
|
77
|
-
web=FastAPIAdapter(),
|
|
78
|
-
route=Route(base_url="https://example.com", path="/webhook"),
|
|
79
|
-
)
|
|
80
|
-
|
|
81
|
-
app = FastAPI()
|
|
82
|
-
engine.register(app)
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
Call `await engine.set_webhook()` during your application startup to register the public webhook URL in Telegram.
|
|
86
|
-
For production, pass `security=Security(...)` to verify Telegram requests.
|
|
87
|
-
|
|
88
61
|
## Documentation
|
|
89
62
|
|
|
90
|
-
The full documentation is
|
|
63
|
+
The full documentation is at [aiogram-webhook.m-xim.ru](https://aiogram-webhook.m-xim.ru). It covers installation, setup, routing, security, lifecycle behavior, and the public API.
|
|
91
64
|
|
|
92
65
|
## Contributing
|
|
93
66
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-

|
|
2
2
|
|
|
3
3
|
# aiogram-webhook
|
|
4
4
|
[](https://pypi.org/project/aiogram-webhook)
|
|
@@ -6,11 +6,10 @@
|
|
|
6
6
|
[](https://github.com/m-xim/aiogram-webhook/actions)
|
|
7
7
|
[](/LICENSE)
|
|
8
8
|
[](https://deepwiki.com/m-xim/aiogram-webhook)
|
|
9
|
-
[](https://github.com/astral-sh/ruff)
|
|
10
10
|
[](https://github.com/astral-sh/ty)
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
It supports single-bot and token-based multi-bot setups, with route building, optional request checks, and adapters for FastAPI and aiohttp.
|
|
12
|
+
Handles the webhook layer for aiogram bots. Registers the endpoint, calls Telegram `setWebhook`, verifies incoming requests, and manages engine lifecycle. Works with FastAPI and aiohttp.
|
|
14
13
|
|
|
15
14
|
## Install
|
|
16
15
|
|
|
@@ -20,35 +19,9 @@ pip install "aiogram-webhook[fastapi]"
|
|
|
20
19
|
pip install "aiogram-webhook[aiohttp]"
|
|
21
20
|
```
|
|
22
21
|
|
|
23
|
-
## Quick Start
|
|
24
|
-
|
|
25
|
-
```python
|
|
26
|
-
from aiogram import Bot, Dispatcher
|
|
27
|
-
from fastapi import FastAPI
|
|
28
|
-
|
|
29
|
-
from aiogram_webhook import FastAPIAdapter, SingleBotEngine
|
|
30
|
-
from aiogram_webhook.route import Route
|
|
31
|
-
|
|
32
|
-
dispatcher = Dispatcher()
|
|
33
|
-
bot = Bot("BOT_TOKEN")
|
|
34
|
-
|
|
35
|
-
engine = SingleBotEngine(
|
|
36
|
-
dispatcher,
|
|
37
|
-
bot,
|
|
38
|
-
web=FastAPIAdapter(),
|
|
39
|
-
route=Route(base_url="https://example.com", path="/webhook"),
|
|
40
|
-
)
|
|
41
|
-
|
|
42
|
-
app = FastAPI()
|
|
43
|
-
engine.register(app)
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
Call `await engine.set_webhook()` during your application startup to register the public webhook URL in Telegram.
|
|
47
|
-
For production, pass `security=Security(...)` to verify Telegram requests.
|
|
48
|
-
|
|
49
22
|
## Documentation
|
|
50
23
|
|
|
51
|
-
The full documentation is
|
|
24
|
+
The full documentation is at [aiogram-webhook.m-xim.ru](https://aiogram-webhook.m-xim.ru). It covers installation, setup, routing, security, lifecycle behavior, and the public API.
|
|
52
25
|
|
|
53
26
|
## Contributing
|
|
54
27
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "aiogram-webhook"
|
|
3
|
-
version = "3.0
|
|
3
|
+
version = "3.1.0"
|
|
4
4
|
description = "A python library for integrating webhook support with multiple web frameworks in aiogram. Organizes bot operation via webhooks for both single and multi-bot setups."
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
license = { text = "MIT" }
|
|
@@ -59,6 +59,11 @@ dev = [
|
|
|
59
59
|
requires = ["uv_build<0.12"]
|
|
60
60
|
build-backend = "uv_build"
|
|
61
61
|
|
|
62
|
+
[tool.pytest.ini_options]
|
|
63
|
+
filterwarnings = [
|
|
64
|
+
"ignore:Security is not configured:UserWarning",
|
|
65
|
+
]
|
|
66
|
+
|
|
62
67
|
[tool.uv]
|
|
63
68
|
package = true
|
|
64
69
|
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import warnings
|
|
2
2
|
from abc import ABC, abstractmethod
|
|
3
|
-
from collections.abc import AsyncGenerator
|
|
4
|
-
from contextlib import asynccontextmanager
|
|
5
3
|
from typing import Any, Generic, TypeVar
|
|
6
4
|
|
|
7
5
|
from aiogram import Bot, Dispatcher
|
|
@@ -111,14 +109,6 @@ class BaseWebhookEngine(ABC, Generic[AppT, RawRequestT, FrameworkResponseT]):
|
|
|
111
109
|
self._is_shutting_down = True
|
|
112
110
|
await self._on_shutdown(app, *args, **kwargs)
|
|
113
111
|
|
|
114
|
-
@asynccontextmanager
|
|
115
|
-
async def lifespan(self, app: AppT) -> AsyncGenerator[None, Any]:
|
|
116
|
-
try:
|
|
117
|
-
await self.on_startup(app=app)
|
|
118
|
-
yield
|
|
119
|
-
finally:
|
|
120
|
-
await self.on_shutdown(app=app)
|
|
121
|
-
|
|
122
112
|
@abstractmethod
|
|
123
113
|
async def _on_startup(self, app: AppT, *args: Any, **kwargs: Any) -> None:
|
|
124
114
|
raise NotImplementedError
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
from collections.abc import Mapping
|
|
2
|
+
from contextlib import asynccontextmanager
|
|
2
3
|
from typing import Any
|
|
3
4
|
|
|
4
5
|
from aiohttp import Payload
|
|
5
|
-
from fastapi import FastAPI, Request, Response
|
|
6
|
+
from fastapi import APIRouter, FastAPI, Request, Response
|
|
6
7
|
from fastapi.responses import JSONResponse
|
|
7
8
|
from multidict import CIMultiDict, CIMultiDictProxy, MultiDict, MultiDictProxy
|
|
8
9
|
|
|
@@ -64,13 +65,23 @@ class FastAPIAdapter(WebAdapter[FastAPI, Request, Response]):
|
|
|
64
65
|
path: str,
|
|
65
66
|
handler: WebHandler[Request, Response],
|
|
66
67
|
*,
|
|
67
|
-
on_startup: LifecycleCallback,
|
|
68
|
-
on_shutdown: LifecycleCallback,
|
|
68
|
+
on_startup: LifecycleCallback,
|
|
69
|
+
on_shutdown: LifecycleCallback,
|
|
69
70
|
) -> None:
|
|
70
71
|
async def endpoint(request: Request) -> Response:
|
|
71
72
|
return await handler(self.bind_request(request))
|
|
72
73
|
|
|
73
|
-
|
|
74
|
+
@asynccontextmanager
|
|
75
|
+
async def lifespan(_router: APIRouter):
|
|
76
|
+
try:
|
|
77
|
+
await on_startup(app)
|
|
78
|
+
yield
|
|
79
|
+
finally:
|
|
80
|
+
await on_shutdown(app)
|
|
81
|
+
|
|
82
|
+
router = APIRouter(lifespan=lifespan)
|
|
83
|
+
router.add_api_route(path=path, endpoint=endpoint, methods=["POST"])
|
|
84
|
+
app.include_router(router)
|
|
74
85
|
|
|
75
86
|
def json_response(
|
|
76
87
|
self, status_code: int, data: dict[str, str] | None = None, headers: Mapping[str, str] | None = None
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{aiogram_webhook-3.0.1 → aiogram_webhook-3.1.0}/src/aiogram_webhook/security/checks/__init__.py
RENAMED
|
File without changes
|
{aiogram_webhook-3.0.1 → aiogram_webhook-3.1.0}/src/aiogram_webhook/security/checks/check.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{aiogram_webhook-3.0.1 → aiogram_webhook-3.1.0}/src/aiogram_webhook/security/secret_token.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|