python-vk-bot 0.3.0__tar.gz → 0.5.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.
Files changed (34) hide show
  1. {python_vk_bot-0.3.0 → python_vk_bot-0.5.0}/CHANGELOG.md +36 -0
  2. {python_vk_bot-0.3.0 → python_vk_bot-0.5.0}/PKG-INFO +26 -1
  3. {python_vk_bot-0.3.0 → python_vk_bot-0.5.0}/README.md +25 -0
  4. {python_vk_bot-0.3.0 → python_vk_bot-0.5.0}/examples/README.md +37 -0
  5. {python_vk_bot-0.3.0 → python_vk_bot-0.5.0}/pyproject.toml +1 -1
  6. {python_vk_bot-0.3.0 → python_vk_bot-0.5.0}/python_vk_bot/__init__.py +18 -1
  7. python_vk_bot-0.5.0/python_vk_bot/application.py +501 -0
  8. {python_vk_bot-0.3.0 → python_vk_bot-0.5.0}/python_vk_bot/context.py +1 -0
  9. {python_vk_bot-0.3.0 → python_vk_bot-0.5.0}/python_vk_bot/errors.py +4 -0
  10. {python_vk_bot-0.3.0 → python_vk_bot-0.5.0}/python_vk_bot/filters.py +18 -1
  11. python_vk_bot-0.5.0/python_vk_bot/handlers.py +131 -0
  12. {python_vk_bot-0.3.0 → python_vk_bot-0.5.0}/python_vk_bot/models/__init__.py +3 -0
  13. python_vk_bot-0.5.0/python_vk_bot/models/donut.py +34 -0
  14. {python_vk_bot-0.3.0 → python_vk_bot-0.5.0}/python_vk_bot/models/events.py +11 -0
  15. python_vk_bot-0.5.0/python_vk_bot/queues.py +86 -0
  16. python_vk_bot-0.3.0/python_vk_bot/application.py +0 -221
  17. python_vk_bot-0.3.0/python_vk_bot/handlers.py +0 -60
  18. {python_vk_bot-0.3.0 → python_vk_bot-0.5.0}/.gitignore +0 -0
  19. {python_vk_bot-0.3.0 → python_vk_bot-0.5.0}/LICENSE +0 -0
  20. {python_vk_bot-0.3.0 → python_vk_bot-0.5.0}/docs/decisions/README.md +0 -0
  21. {python_vk_bot-0.3.0 → python_vk_bot-0.5.0}/python_vk_bot/.agents/skills/telegram-to-vk/SKILL.md +0 -0
  22. {python_vk_bot-0.3.0 → python_vk_bot-0.5.0}/python_vk_bot/.agents/skills/telegram-to-vk/references/migration-mapping.md +0 -0
  23. {python_vk_bot-0.3.0 → python_vk_bot-0.5.0}/python_vk_bot/_config.py +0 -0
  24. {python_vk_bot-0.3.0 → python_vk_bot-0.5.0}/python_vk_bot/bot.py +0 -0
  25. {python_vk_bot-0.3.0 → python_vk_bot-0.5.0}/python_vk_bot/callback.py +0 -0
  26. {python_vk_bot-0.3.0 → python_vk_bot-0.5.0}/python_vk_bot/long_poll.py +0 -0
  27. {python_vk_bot-0.3.0 → python_vk_bot-0.5.0}/python_vk_bot/models/api.py +0 -0
  28. {python_vk_bot-0.3.0 → python_vk_bot-0.5.0}/python_vk_bot/models/attachments.py +0 -0
  29. {python_vk_bot-0.3.0 → python_vk_bot-0.5.0}/python_vk_bot/models/base.py +0 -0
  30. {python_vk_bot-0.3.0 → python_vk_bot-0.5.0}/python_vk_bot/models/keyboards.py +0 -0
  31. {python_vk_bot-0.3.0 → python_vk_bot-0.5.0}/python_vk_bot/models/messages.py +0 -0
  32. {python_vk_bot-0.3.0 → python_vk_bot-0.5.0}/python_vk_bot/py.typed +0 -0
  33. {python_vk_bot-0.3.0 → python_vk_bot-0.5.0}/python_vk_bot/settings.py +0 -0
  34. {python_vk_bot-0.3.0 → python_vk_bot-0.5.0}/python_vk_bot/transport.py +0 -0
@@ -2,6 +2,42 @@
2
2
 
3
3
  All notable changes will be documented here, following Keep a Changelog.
4
4
 
5
+ ## Unreleased
6
+
7
+ -
8
+
9
+ ## 0.5.0 - 2026-11-05
10
+
11
+ ### Added
12
+
13
+ - Typed support for all five VK Donut subscription Callback events through
14
+ `Update.donut_subscription`, subscriber user context, `DonutSubscriptionHandler`
15
+ and composable filters. See the [Donut guide](docs/development/donut.md) and
16
+ Callback example. These events report changes without synchronizing paid access.
17
+
18
+ ### Fixed
19
+
20
+ - Concurrent graceful stop and polling-runner cancellation wait for Long Poll cleanup
21
+ without interrupting it with a second cancellation request.
22
+
23
+ ## 0.4.0 - 2026-11-03
24
+
25
+ ### Added
26
+
27
+ - `ApplicationHandlerStop` to finish the current event successfully and skip later groups.
28
+ - `TypeHandler` and a bounded `Application.update_queue` for internal Python objects and
29
+ VK updates, with explicit user/peer state scopes and `Context.event`.
30
+ - `Application.create_task` for owned finite tasks and workers cancelled on stop.
31
+ - A once-per-run `post_stop` hook before Bot shutdown, and a local background-result example.
32
+
33
+ ### Changed
34
+
35
+ - Event processing uses a unified serial FIFO. Callback acknowledgement still waits for
36
+ dispatch; request cancellation cancels that event's pending or active execution.
37
+ - **Breaking:** after `stop()`, complete `shutdown()` and `initialize()` before starting
38
+ another run. Registration stays closed until shutdown completes. See the
39
+ [lifecycle and queue contracts](docs/development/event-processing.md#lifecycle-and-cleanup).
40
+
5
41
  ## 0.3.0 - 2026-11-02
6
42
 
7
43
  ### Added
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: python-vk-bot
3
- Version: 0.3.0
3
+ Version: 0.5.0
4
4
  Summary: An asynchronous framework for VK community bots.
5
5
  Project-URL: Homepage, https://github.com/fomenko-ai/python-vk-bot
6
6
  Project-URL: Repository, https://github.com/fomenko-ai/python-vk-bot
@@ -74,6 +74,8 @@ See the [examples guide](examples/README.md) for setup, required events and run
74
74
  | [Keyboards](examples/keyboards.py) | Ordinary text buttons and inline callback buttons with message editing |
75
75
  | [Interactive map](examples/interactive_map.py) | Generate, upload and replace a PNG using navigation buttons |
76
76
  | [Callback receiver](examples/callback.py) | Receive events through an ASGI application |
77
+ | [Background result](examples/background_result.py) | Return a local calculation through the unified event queue |
78
+ | [Donut subscriptions](examples/donut_subscriptions.py) | Receive five typed subscription events and inspect the latest notification |
77
79
 
78
80
  ## Long Poll bot
79
81
 
@@ -287,6 +289,29 @@ The media API has network-free regression tests. Actual replacement of a photo i
287
289
  existing VK message has not yet been verified with a live token; an explicitly enabled
288
290
  [integration test](docs/development/media-api.md#live-integration-test) is provided.
289
291
 
292
+ ## Background tasks and internal events
293
+
294
+ Use `Application.create_task()` for background operations and `update_queue.put()` to
295
+ return Python objects to the shared serial dispatcher. `TypeHandler` routes these results;
296
+ `ApplicationHandlerStop` skips later handler groups for the current event. See the
297
+ [background-result example](examples/background_result.py).
298
+
299
+ The application manages task completion and calls `post_stop` before closing Bot.
300
+ Queue capacity, state scopes, cancellation, workers and shutdown are described in the
301
+ [event processing guide](docs/development/event-processing.md). The queue is in memory
302
+ and does not preserve work across restarts.
303
+
304
+ ## VK Donut events
305
+
306
+ Register `DonutSubscriptionHandler(on_donut)` through `Application.add_handler` to receive
307
+ all five subscription Callback events. Inside the async callback, `update.donut_subscription`
308
+ provides the typed object and `update.user_id` selects the subscriber's `context.user_data`.
309
+ Use `event_types` or composable `filters.DONUT_SUBSCRIPTION_*` predicates to select events.
310
+
311
+ These are subscription-change notifications, not a synchronized subscriber list or a paid
312
+ access check. See the [Donut guide](docs/development/donut.md) for setup, models, filtering,
313
+ delivery limitations and the runnable example.
314
+
290
315
  ## Agent Skills
291
316
 
292
317
  The bundled **telegram-to-vk** Agent Skill helps AI coding agents migrate
@@ -48,6 +48,8 @@ See the [examples guide](examples/README.md) for setup, required events and run
48
48
  | [Keyboards](examples/keyboards.py) | Ordinary text buttons and inline callback buttons with message editing |
49
49
  | [Interactive map](examples/interactive_map.py) | Generate, upload and replace a PNG using navigation buttons |
50
50
  | [Callback receiver](examples/callback.py) | Receive events through an ASGI application |
51
+ | [Background result](examples/background_result.py) | Return a local calculation through the unified event queue |
52
+ | [Donut subscriptions](examples/donut_subscriptions.py) | Receive five typed subscription events and inspect the latest notification |
51
53
 
52
54
  ## Long Poll bot
53
55
 
@@ -261,6 +263,29 @@ The media API has network-free regression tests. Actual replacement of a photo i
261
263
  existing VK message has not yet been verified with a live token; an explicitly enabled
262
264
  [integration test](docs/development/media-api.md#live-integration-test) is provided.
263
265
 
266
+ ## Background tasks and internal events
267
+
268
+ Use `Application.create_task()` for background operations and `update_queue.put()` to
269
+ return Python objects to the shared serial dispatcher. `TypeHandler` routes these results;
270
+ `ApplicationHandlerStop` skips later handler groups for the current event. See the
271
+ [background-result example](examples/background_result.py).
272
+
273
+ The application manages task completion and calls `post_stop` before closing Bot.
274
+ Queue capacity, state scopes, cancellation, workers and shutdown are described in the
275
+ [event processing guide](docs/development/event-processing.md). The queue is in memory
276
+ and does not preserve work across restarts.
277
+
278
+ ## VK Donut events
279
+
280
+ Register `DonutSubscriptionHandler(on_donut)` through `Application.add_handler` to receive
281
+ all five subscription Callback events. Inside the async callback, `update.donut_subscription`
282
+ provides the typed object and `update.user_id` selects the subscriber's `context.user_data`.
283
+ Use `event_types` or composable `filters.DONUT_SUBSCRIPTION_*` predicates to select events.
284
+
285
+ These are subscription-change notifications, not a synchronized subscriber list or a paid
286
+ access check. See the [Donut guide](docs/development/donut.md) for setup, models, filtering,
287
+ delivery limitations and the runnable example.
288
+
264
289
  ## Agent Skills
265
290
 
266
291
  The bundled **telegram-to-vk** Agent Skill helps AI coding agents migrate
@@ -25,6 +25,8 @@ The Callback example uses its own HTTP delivery setup instead.
25
25
  | [keyboards.py](keyboards.py) | Ordinary and inline keyboards, payloads and message editing | `message_new`, `message_event` |
26
26
  | [interactive_map.py](interactive_map.py) | Photo upload and replacement with inline navigation | `message_new`, `message_event` |
27
27
  | [callback.py](callback.py) | A Callback API receiver using an ASGI factory | `message_new` |
28
+ | [donut_subscriptions.py](donut_subscriptions.py) | Typed Donut notifications and a private `/donut` command | Five `donut_subscription_*` events and `message_new` |
29
+ | [background_result.py](background_result.py) | Managed computation, TypeHandler and event dispatch stopping | `message_new` |
28
30
 
29
31
  ## Echo bot
30
32
 
@@ -95,3 +97,38 @@ API settings. The confirmation value must match the code provided by VK.
95
97
  The receiver echoes text messages. `CallbackSettings` extends `BotSettings` with the
96
98
  required secret and confirmation fields, and the ASGI lifespan manages the application's
97
99
  resources. See [Callback API](../README.md#callback-api) for delivery semantics.
100
+
101
+ ## Donut subscription events
102
+
103
+ Use the same environment configuration as the Callback receiver above. Enable VK Donut
104
+ in the community and select `donut_subscription_create`, `donut_subscription_prolonged`,
105
+ `donut_subscription_cancelled`, `donut_subscription_expired`,
106
+ `donut_subscription_price_changed` and `message_new` in Callback API settings.
107
+
108
+ ```bash
109
+ uv run --extra callback uvicorn examples.donut_subscriptions:create_app --factory
110
+ ```
111
+
112
+ Configure the HTTPS `/callback` URL, matching secret and confirmation code. Send `/donut`
113
+ privately to the community to see the latest received event for your user. Event handling
114
+ does not send unsolicited messages. The remembered event is process-local and is not
115
+ evidence of current paid access; no history is recovered after a restart. See the
116
+ [Donut guide](../docs/development/donut.md) for complete setup and the public API.
117
+
118
+ ## Background calculation
119
+
120
+ ```bash
121
+ uv run python examples/background_result.py
122
+ ```
123
+
124
+ Send `/background hello`. The command acknowledges the request, starts an owned finite
125
+ coroutine and raises ApplicationHandlerStop to skip later groups. The local coroutine
126
+ counts characters after a short asynchronous delay, then puts a BackgroundResult in the
127
+ same queue as incoming VK events. Its TypeHandler sends the result and updates peer_data.
128
+ The calculation uses no AI, speech models, database or broker. Running the full example
129
+ uses live VK for polling and messages; configure can also register the handlers on an
130
+ Application with a mocked Bot for offline verification.
131
+
132
+ The background coroutine never changes shared state directly. Queue admission does not
133
+ persist the job; restarts can lose it. Finite tasks are awaited on shutdown with the
134
+ consumer still active. See [queue and lifecycle contracts](../docs/development/event-processing.md).
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "python-vk-bot"
7
- version = "0.3.0"
7
+ version = "0.5.0"
8
8
  description = "An asynchronous framework for VK community bots."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.14"
@@ -5,7 +5,15 @@ from .application import Application
5
5
  from .bot import Bot
6
6
  from .callback import Callback
7
7
  from .context import Context
8
- from .handlers import CommandHandler, Handler, MessageEventHandler, MessageHandler
8
+ from .errors import ApplicationHandlerStop
9
+ from .handlers import (
10
+ CommandHandler,
11
+ DonutSubscriptionHandler,
12
+ Handler,
13
+ MessageEventHandler,
14
+ MessageHandler,
15
+ TypeHandler,
16
+ )
9
17
  from .long_poll import LongPoll
10
18
  from .models import (
11
19
  Attachment,
@@ -14,6 +22,8 @@ from .models import (
14
22
  ButtonType,
15
23
  CallbackButton,
16
24
  DocumentAttachment,
25
+ DonutSubscriptionEvent,
26
+ DonutSubscriptionEventType,
17
27
  Keyboard,
18
28
  Message,
19
29
  MessageEvent,
@@ -23,10 +33,12 @@ from .models import (
23
33
  User,
24
34
  VideoAttachment,
25
35
  )
36
+ from .queues import UpdateQueue
26
37
  from .settings import BotSettings
27
38
 
28
39
  __all__ = [
29
40
  "Application",
41
+ "ApplicationHandlerStop",
30
42
  "Attachment",
31
43
  "AudioMessageAttachment",
32
44
  "Bot",
@@ -38,6 +50,9 @@ __all__ = [
38
50
  "CommandHandler",
39
51
  "Context",
40
52
  "DocumentAttachment",
53
+ "DonutSubscriptionEvent",
54
+ "DonutSubscriptionEventType",
55
+ "DonutSubscriptionHandler",
41
56
  "Handler",
42
57
  "Keyboard",
43
58
  "LongPoll",
@@ -47,7 +62,9 @@ __all__ = [
47
62
  "MessageHandler",
48
63
  "PhotoAttachment",
49
64
  "TextButton",
65
+ "TypeHandler",
50
66
  "Update",
67
+ "UpdateQueue",
51
68
  "User",
52
69
  "VideoAttachment",
53
70
  "filters",