aiogram-webhook 3.0.0__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.0 → aiogram_webhook-3.1.0}/PKG-INFO +5 -32
- {aiogram_webhook-3.0.0 → aiogram_webhook-3.1.0}/README.md +4 -31
- {aiogram_webhook-3.0.0 → aiogram_webhook-3.1.0}/pyproject.toml +6 -1
- {aiogram_webhook-3.0.0 → aiogram_webhook-3.1.0}/src/aiogram_webhook/engines/base.py +2 -4
- {aiogram_webhook-3.0.0 → aiogram_webhook-3.1.0}/src/aiogram_webhook/engines/multi.py +1 -3
- {aiogram_webhook-3.0.0 → aiogram_webhook-3.1.0}/src/aiogram_webhook/engines/single.py +1 -3
- {aiogram_webhook-3.0.0 → aiogram_webhook-3.1.0}/src/aiogram_webhook/engines/token.py +1 -3
- {aiogram_webhook-3.0.0 → aiogram_webhook-3.1.0}/src/aiogram_webhook/web/fastapi.py +10 -15
- {aiogram_webhook-3.0.0 → aiogram_webhook-3.1.0}/src/aiogram_webhook/__init__.py +0 -0
- {aiogram_webhook-3.0.0 → aiogram_webhook-3.1.0}/src/aiogram_webhook/configs/__init__.py +0 -0
- {aiogram_webhook-3.0.0 → aiogram_webhook-3.1.0}/src/aiogram_webhook/configs/bot.py +0 -0
- {aiogram_webhook-3.0.0 → aiogram_webhook-3.1.0}/src/aiogram_webhook/configs/webhook.py +0 -0
- {aiogram_webhook-3.0.0 → aiogram_webhook-3.1.0}/src/aiogram_webhook/engines/__init__.py +0 -0
- {aiogram_webhook-3.0.0 → aiogram_webhook-3.1.0}/src/aiogram_webhook/engines/errors.py +0 -0
- {aiogram_webhook-3.0.0 → aiogram_webhook-3.1.0}/src/aiogram_webhook/engines/target.py +0 -0
- {aiogram_webhook-3.0.0 → aiogram_webhook-3.1.0}/src/aiogram_webhook/errors.py +0 -0
- {aiogram_webhook-3.0.0 → aiogram_webhook-3.1.0}/src/aiogram_webhook/logs.py +0 -0
- {aiogram_webhook-3.0.0 → aiogram_webhook-3.1.0}/src/aiogram_webhook/py.typed +0 -0
- {aiogram_webhook-3.0.0 → aiogram_webhook-3.1.0}/src/aiogram_webhook/route/__init__.py +0 -0
- {aiogram_webhook-3.0.0 → aiogram_webhook-3.1.0}/src/aiogram_webhook/route/config.py +0 -0
- {aiogram_webhook-3.0.0 → aiogram_webhook-3.1.0}/src/aiogram_webhook/route/errors.py +0 -0
- {aiogram_webhook-3.0.0 → aiogram_webhook-3.1.0}/src/aiogram_webhook/route/params.py +0 -0
- {aiogram_webhook-3.0.0 → aiogram_webhook-3.1.0}/src/aiogram_webhook/route/path.py +0 -0
- {aiogram_webhook-3.0.0 → aiogram_webhook-3.1.0}/src/aiogram_webhook/route/query.py +0 -0
- {aiogram_webhook-3.0.0 → aiogram_webhook-3.1.0}/src/aiogram_webhook/route/route.py +0 -0
- {aiogram_webhook-3.0.0 → aiogram_webhook-3.1.0}/src/aiogram_webhook/route/url.py +0 -0
- {aiogram_webhook-3.0.0 → aiogram_webhook-3.1.0}/src/aiogram_webhook/security/__init__.py +0 -0
- {aiogram_webhook-3.0.0 → aiogram_webhook-3.1.0}/src/aiogram_webhook/security/checks/__init__.py +0 -0
- {aiogram_webhook-3.0.0 → aiogram_webhook-3.1.0}/src/aiogram_webhook/security/checks/check.py +0 -0
- {aiogram_webhook-3.0.0 → aiogram_webhook-3.1.0}/src/aiogram_webhook/security/checks/ip.py +0 -0
- {aiogram_webhook-3.0.0 → aiogram_webhook-3.1.0}/src/aiogram_webhook/security/errors.py +0 -0
- {aiogram_webhook-3.0.0 → aiogram_webhook-3.1.0}/src/aiogram_webhook/security/secret_token.py +0 -0
- {aiogram_webhook-3.0.0 → aiogram_webhook-3.1.0}/src/aiogram_webhook/security/security.py +0 -0
- {aiogram_webhook-3.0.0 → aiogram_webhook-3.1.0}/src/aiogram_webhook/tasks.py +0 -0
- {aiogram_webhook-3.0.0 → aiogram_webhook-3.1.0}/src/aiogram_webhook/utils/__init__.py +0 -0
- {aiogram_webhook-3.0.0 → aiogram_webhook-3.1.0}/src/aiogram_webhook/utils/_payload.py +0 -0
- {aiogram_webhook-3.0.0 → aiogram_webhook-3.1.0}/src/aiogram_webhook/utils/config.py +0 -0
- {aiogram_webhook-3.0.0 → aiogram_webhook-3.1.0}/src/aiogram_webhook/web/__init__.py +0 -0
- {aiogram_webhook-3.0.0 → aiogram_webhook-3.1.0}/src/aiogram_webhook/web/_starlette.py +0 -0
- {aiogram_webhook-3.0.0 → aiogram_webhook-3.1.0}/src/aiogram_webhook/web/aiohttp.py +0 -0
- {aiogram_webhook-3.0.0 → 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.
|
|
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.
|
|
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
|
|
|
@@ -2,7 +2,7 @@ import warnings
|
|
|
2
2
|
from abc import ABC, abstractmethod
|
|
3
3
|
from typing import Any, Generic, TypeVar
|
|
4
4
|
|
|
5
|
-
from aiogram import Bot
|
|
5
|
+
from aiogram import Bot, Dispatcher
|
|
6
6
|
from aiogram.methods import TelegramMethod
|
|
7
7
|
|
|
8
8
|
from aiogram_webhook.engines.errors import (
|
|
@@ -31,9 +31,7 @@ FrameworkResponseT = TypeVar("FrameworkResponseT")
|
|
|
31
31
|
class BaseWebhookEngine(ABC, Generic[AppT, RawRequestT, FrameworkResponseT]):
|
|
32
32
|
def __init__(
|
|
33
33
|
self,
|
|
34
|
-
dispatcher,
|
|
35
|
-
/,
|
|
36
|
-
*,
|
|
34
|
+
dispatcher: Dispatcher,
|
|
37
35
|
web: WebAdapter[AppT, RawRequestT, FrameworkResponseT],
|
|
38
36
|
route: Route,
|
|
39
37
|
security: Security | None = None,
|
|
@@ -21,8 +21,6 @@ class BaseMultiBotEngine(
|
|
|
21
21
|
def __init__(
|
|
22
22
|
self,
|
|
23
23
|
dispatcher,
|
|
24
|
-
/,
|
|
25
|
-
*,
|
|
26
24
|
web: WebAdapter[AppT, RawRequestT, FrameworkResponseT],
|
|
27
25
|
route: Route,
|
|
28
26
|
security: Security | None = None,
|
|
@@ -34,7 +32,7 @@ class BaseMultiBotEngine(
|
|
|
34
32
|
self._bots: dict[int, Bot] = {}
|
|
35
33
|
self.webhook_config = webhook_config or WebhookConfig()
|
|
36
34
|
super().__init__(
|
|
37
|
-
dispatcher,
|
|
35
|
+
dispatcher=dispatcher,
|
|
38
36
|
web=web,
|
|
39
37
|
route=route,
|
|
40
38
|
security=security,
|
|
@@ -19,8 +19,6 @@ class SingleBotEngine(
|
|
|
19
19
|
self,
|
|
20
20
|
dispatcher,
|
|
21
21
|
bot: Bot,
|
|
22
|
-
/,
|
|
23
|
-
*,
|
|
24
22
|
web: WebAdapter[AppT, RawRequestT, FrameworkResponseT],
|
|
25
23
|
route: Route,
|
|
26
24
|
security=None,
|
|
@@ -31,7 +29,7 @@ class SingleBotEngine(
|
|
|
31
29
|
self._task_tracker = TaskTracker()
|
|
32
30
|
|
|
33
31
|
super().__init__(
|
|
34
|
-
dispatcher,
|
|
32
|
+
dispatcher=dispatcher,
|
|
35
33
|
web=web,
|
|
36
34
|
route=route,
|
|
37
35
|
security=security,
|
|
@@ -24,8 +24,6 @@ class TokenEngine(
|
|
|
24
24
|
def __init__(
|
|
25
25
|
self,
|
|
26
26
|
dispatcher,
|
|
27
|
-
/,
|
|
28
|
-
*,
|
|
29
27
|
web: WebAdapter[AppT, RawRequestT, FrameworkResponseT],
|
|
30
28
|
route: Route,
|
|
31
29
|
security=None,
|
|
@@ -35,7 +33,7 @@ class TokenEngine(
|
|
|
35
33
|
shutdown_timeout: float = 10.0,
|
|
36
34
|
) -> None:
|
|
37
35
|
super().__init__(
|
|
38
|
-
dispatcher,
|
|
36
|
+
dispatcher=dispatcher,
|
|
39
37
|
web=web,
|
|
40
38
|
route=route,
|
|
41
39
|
security=security,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from collections.abc import
|
|
1
|
+
from collections.abc import Mapping
|
|
2
2
|
from contextlib import asynccontextmanager
|
|
3
3
|
from typing import Any
|
|
4
4
|
|
|
@@ -6,7 +6,6 @@ from aiohttp import Payload
|
|
|
6
6
|
from fastapi import APIRouter, FastAPI, Request, Response
|
|
7
7
|
from fastapi.responses import JSONResponse
|
|
8
8
|
from multidict import CIMultiDict, CIMultiDictProxy, MultiDict, MultiDictProxy
|
|
9
|
-
from starlette.types import Lifespan
|
|
10
9
|
|
|
11
10
|
from aiogram_webhook.web._starlette import AiohttpPayloadResponse
|
|
12
11
|
from aiogram_webhook.web.base import (
|
|
@@ -60,18 +59,6 @@ class FastAPIAdapter(WebAdapter[FastAPI, Request, Response]):
|
|
|
60
59
|
def bind_request(self, request: Request) -> WebRequest[Request]:
|
|
61
60
|
return FastAPIWebRequest(request)
|
|
62
61
|
|
|
63
|
-
@staticmethod
|
|
64
|
-
def _build_lifespan(on_startup: LifecycleCallback, on_shutdown: LifecycleCallback) -> Lifespan[FastAPI]:
|
|
65
|
-
@asynccontextmanager
|
|
66
|
-
async def lifespan(app: FastAPI) -> AsyncIterator[None]:
|
|
67
|
-
await on_startup(app)
|
|
68
|
-
try:
|
|
69
|
-
yield
|
|
70
|
-
finally:
|
|
71
|
-
await on_shutdown(app)
|
|
72
|
-
|
|
73
|
-
return lifespan
|
|
74
|
-
|
|
75
62
|
def register(
|
|
76
63
|
self,
|
|
77
64
|
app: FastAPI,
|
|
@@ -84,7 +71,15 @@ class FastAPIAdapter(WebAdapter[FastAPI, Request, Response]):
|
|
|
84
71
|
async def endpoint(request: Request) -> Response:
|
|
85
72
|
return await handler(self.bind_request(request))
|
|
86
73
|
|
|
87
|
-
|
|
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)
|
|
88
83
|
router.add_api_route(path=path, endpoint=endpoint, methods=["POST"])
|
|
89
84
|
app.include_router(router)
|
|
90
85
|
|
|
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.0 → aiogram_webhook-3.1.0}/src/aiogram_webhook/security/checks/__init__.py
RENAMED
|
File without changes
|
{aiogram_webhook-3.0.0 → 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.0 → 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
|