fastvk 0.0.1__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.
fastvk-0.0.1/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 安𝐍ᴇғᴏʀ | ᵈᵉᵛ
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
fastvk-0.0.1/PKG-INFO ADDED
@@ -0,0 +1,403 @@
1
+ Metadata-Version: 2.4
2
+ Name: fastvk
3
+ Version: 0.0.1
4
+ Summary: Async VK bot framework with FastAPI-style decorators and aiogram-style FSM
5
+ Author-email: White NEFOR <n7for8572@gmail.com>
6
+ Maintainer-email: White NEFOR <n7for8572@gmail.com>
7
+ License: MIT
8
+ Project-URL: Homepage, https://github.com/ndugram/fastvk
9
+ Project-URL: Documentation, https://github.com/ndugram/fastvk
10
+ Project-URL: Repository, https://github.com/ndugram/fastvk
11
+ Project-URL: Issues, https://github.com/ndugram/fastvk/issues
12
+ Keywords: vk,vkontakte,bot,async,fsm,longpoll,framework,python
13
+ Classifier: Development Status :: 3 - Alpha
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Topic :: Communications :: Chat
23
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
24
+ Classifier: Typing :: Typed
25
+ Requires-Python: >=3.10
26
+ Description-Content-Type: text/markdown
27
+ License-File: LICENSE
28
+ Requires-Dist: aiohttp>=3.9.0
29
+ Requires-Dist: annotated-doc>=0.0.4
30
+ Provides-Extra: dev
31
+ Requires-Dist: pytest>=8.0.0; extra == "dev"
32
+ Requires-Dist: pytest-asyncio>=0.24.0; extra == "dev"
33
+ Requires-Dist: pytest-cov>=6.0.0; extra == "dev"
34
+ Requires-Dist: ruff>=0.15.0; extra == "dev"
35
+ Dynamic: license-file
36
+
37
+ <p align="center">
38
+ <img src="docs/logo.svg" width="480">
39
+ </p>
40
+ <p align="center">
41
+ <em>Async VK bot framework with FastAPI-style decorators and aiogram-style FSM.</em>
42
+ </p>
43
+ <p align="center">
44
+ <a href="https://pypi.org/project/fastvk" target="_blank">
45
+ <img src="https://img.shields.io/pypi/v/fastvk?color=%234C75A3&label=pypi%20package" alt="Package version">
46
+ </a>
47
+ <a href="https://pypi.org/project/fastvk" target="_blank">
48
+ <img src="https://img.shields.io/pypi/pyversions/fastvk.svg?color=%234C75A3" alt="Supported Python versions">
49
+ </a>
50
+ <a href="https://github.com/ndugram/fastvk" target="_blank">
51
+ <img src="https://img.shields.io/github/stars/ndugram/fastvk?style=social" alt="GitHub Stars">
52
+ </a>
53
+ <a href="https://github.com/ndugram/fastvk/blob/master/LICENSE" target="_blank">
54
+ <img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="License">
55
+ </a>
56
+ </p>
57
+
58
+ ---
59
+
60
+ **Source Code**: <a href="https://github.com/ndugram/fastvk" target="_blank">https://github.com/ndugram/fastvk</a>
61
+
62
+ ---
63
+
64
+ FastVK is a modern **async VK bot framework** for Python. It brings a decorator-based handler API — similar to FastAPI and aiogram, but for VK — with FSM, middleware, filters, and clean dependency injection out of the box.
65
+
66
+ Key features:
67
+
68
+ - **Familiar** — if you know FastAPI or aiogram, you already know FastVK. Same patterns, same ergonomics.
69
+ - **Async** — built on <a href="https://docs.aiohttp.org/" target="_blank">aiohttp</a> with full async/await support from top to bottom.
70
+ - **FSM** — built-in Finite State Machine with `State`, `StatesGroup`, and pluggable storage backends.
71
+ - **Filters** — `Command`, `Text`, `StateFilter`, `FromUser`, `IsChat` and custom filters via any callable.
72
+ - **Injection** — handler parameters injected by name: `message`, `state`, `api`, `update` — no manual wiring.
73
+ - **Routers** — split handlers across multiple `Router` instances, include them into the main bot.
74
+ - **Middleware** — intercept every update before and after handlers with `BaseMiddleware`.
75
+ - **Typed** — full type annotations throughout; works great with mypy and pyright.
76
+
77
+ ## Requirements
78
+
79
+ Python 3.10+
80
+
81
+ FastVK depends on:
82
+
83
+ - <a href="https://docs.aiohttp.org/" target="_blank"><code>aiohttp</code></a> — async HTTP transport for Long Poll and VK API calls.
84
+ - <a href="https://github.com/annotated-doc/annotated-doc" target="_blank"><code>annotated-doc</code></a> — `Doc()` annotations for rich parameter documentation.
85
+
86
+ ## Installation
87
+
88
+ ```console
89
+ $ pip install fastvk
90
+
91
+ ---> 100%
92
+ ```
93
+
94
+ ## Example
95
+
96
+ ### Create it
97
+
98
+ Create a file `main.py`:
99
+
100
+ ```python
101
+ from fastvk import FastVK
102
+ from fastvk.filters import Command
103
+ from fastvk.types import Message
104
+
105
+ bot = FastVK(token="vk1.a.YOUR_TOKEN", group_id=123456789)
106
+
107
+
108
+ @bot.message(Command("start"))
109
+ async def start(message: Message) -> None:
110
+ await message.answer("Привет! Я FastVK бот 🤖")
111
+
112
+
113
+ if __name__ == "__main__":
114
+ bot.run_polling()
115
+ ```
116
+
117
+ ### Run it
118
+
119
+ ```console
120
+ $ python main.py
121
+ ```
122
+
123
+ ### Check it
124
+
125
+ You will see output like:
126
+
127
+ ```
128
+ INFO fastvk FastVK started (group_id=123456789)
129
+ INFO fastvk Polling started
130
+ ```
131
+
132
+ Send `/start` to your bot — it replies instantly.
133
+
134
+ ### Upgrade the example
135
+
136
+ <details markdown="1">
137
+ <summary>With FSM (multi-step forms)...</summary>
138
+
139
+ Use `StatesGroup` and `State` to collect data across multiple messages:
140
+
141
+ ```python
142
+ from fastvk import FastVK
143
+ from fastvk.filters import Command, StateFilter
144
+ from fastvk.fsm import FSMContext, State, StatesGroup
145
+ from fastvk.types import Message
146
+
147
+ bot = FastVK(token="vk1.a.YOUR_TOKEN", group_id=123456789)
148
+
149
+
150
+ class RegistrationForm(StatesGroup):
151
+ waiting_name = State()
152
+ waiting_age = State()
153
+
154
+
155
+ @bot.message(Command("start"))
156
+ async def cmd_start(message: Message, state: FSMContext) -> None:
157
+ await state.set_state(RegistrationForm.waiting_name)
158
+ await message.answer("Как тебя зовут?")
159
+
160
+
161
+ @bot.message(StateFilter(RegistrationForm.waiting_name))
162
+ async def got_name(message: Message, state: FSMContext) -> None:
163
+ await state.update_data(name=message.text)
164
+ await state.set_state(RegistrationForm.waiting_age)
165
+ await message.answer(f"Отлично, {message.text}! Сколько тебе лет?")
166
+
167
+
168
+ @bot.message(StateFilter(RegistrationForm.waiting_age))
169
+ async def got_age(message: Message, state: FSMContext) -> None:
170
+ data = await state.update_data(age=message.text)
171
+ await state.clear()
172
+ await message.answer(
173
+ f"Готово!\nИмя: {data['name']}\nВозраст: {data['age']}"
174
+ )
175
+
176
+
177
+ if __name__ == "__main__":
178
+ bot.run_polling()
179
+ ```
180
+
181
+ </details>
182
+
183
+ <details markdown="1">
184
+ <summary>With routers...</summary>
185
+
186
+ Split handlers into separate modules and include them into the bot:
187
+
188
+ ```python
189
+ from fastvk import FastVK, Router
190
+ from fastvk.filters import Command, Text
191
+ from fastvk.types import Message
192
+
193
+ shop_router = Router()
194
+
195
+
196
+ @shop_router.message(Command("catalog"))
197
+ async def catalog(message: Message) -> None:
198
+ await message.answer("📦 Наш каталог: ...")
199
+
200
+
201
+ @shop_router.message(Text("цена", contains=True, ignore_case=True))
202
+ async def price_mention(message: Message) -> None:
203
+ await message.answer("Цены начинаются от 99₽")
204
+
205
+
206
+ bot = FastVK(token="vk1.a.YOUR_TOKEN", group_id=123456789)
207
+ bot.include_router(shop_router)
208
+
209
+ if __name__ == "__main__":
210
+ bot.run_polling()
211
+ ```
212
+
213
+ </details>
214
+
215
+ <details markdown="1">
216
+ <summary>With middleware...</summary>
217
+
218
+ Intercept every incoming update to add logging, rate limiting, or custom data:
219
+
220
+ ```python
221
+ from collections.abc import Awaitable, Callable
222
+ from typing import Any
223
+
224
+ from fastvk import FastVK
225
+ from fastvk.middleware import BaseMiddleware
226
+ from fastvk.filters import Command
227
+ from fastvk.types import Message
228
+
229
+
230
+ class LoggingMiddleware(BaseMiddleware):
231
+ async def __call__(
232
+ self,
233
+ handler: Callable[[Any, dict], Awaitable[Any]],
234
+ event: Any,
235
+ data: dict,
236
+ ) -> Any:
237
+ print(f"→ incoming: {type(event).__name__}")
238
+ result = await handler(event, data)
239
+ print(f"← handled")
240
+ return result
241
+
242
+
243
+ bot = FastVK(
244
+ token="vk1.a.YOUR_TOKEN",
245
+ group_id=123456789,
246
+ middleware=[LoggingMiddleware()],
247
+ )
248
+
249
+
250
+ @bot.message(Command("ping"))
251
+ async def ping(message: Message) -> None:
252
+ await message.answer("pong")
253
+
254
+
255
+ if __name__ == "__main__":
256
+ bot.run_polling()
257
+ ```
258
+
259
+ </details>
260
+
261
+ <details markdown="1">
262
+ <summary>With filters...</summary>
263
+
264
+ Combine built-in and custom filters on any handler:
265
+
266
+ ```python
267
+ from fastvk import FastVK
268
+ from fastvk.filters import Command, FromUser, IsChat, Text
269
+ from fastvk.types import Message
270
+
271
+ ADMIN_ID = 123456789
272
+
273
+ bot = FastVK(token="vk1.a.YOUR_TOKEN", group_id=987654321)
274
+
275
+
276
+ @bot.message(Command("ban"), FromUser(ADMIN_ID))
277
+ async def admin_ban(message: Message) -> None:
278
+ await message.answer("Пользователь заблокирован.")
279
+
280
+
281
+ @bot.message(IsChat("private"), Text("помощь", contains=True, ignore_case=True))
282
+ async def help_in_pm(message: Message) -> None:
283
+ await message.answer("Список команд: /start, /help")
284
+
285
+
286
+ def is_long_message(message: Message, data: dict) -> bool:
287
+ return len(message.text or "") > 200
288
+
289
+
290
+ @bot.message(is_long_message)
291
+ async def long_message(message: Message) -> None:
292
+ await message.answer("Это очень длинное сообщение!")
293
+
294
+
295
+ if __name__ == "__main__":
296
+ bot.run_polling()
297
+ ```
298
+
299
+ </details>
300
+
301
+ <details markdown="1">
302
+ <summary>With raw VK API calls...</summary>
303
+
304
+ Access the full VK API via the injected `api` parameter:
305
+
306
+ ```python
307
+ from fastvk import FastVK
308
+ from fastvk.api import APIClient
309
+ from fastvk.filters import Command
310
+ from fastvk.types import Message
311
+
312
+ bot = FastVK(token="vk1.a.YOUR_TOKEN", group_id=123456789)
313
+
314
+
315
+ @bot.message(Command("me"))
316
+ async def cmd_me(message: Message, api: APIClient) -> None:
317
+ users = await api.users.get(user_ids=message.from_id, fields="photo_200")
318
+ user = users[0]
319
+ await message.answer(f"Ты: {user['first_name']} {user['last_name']}")
320
+
321
+
322
+ @bot.message(Command("members"))
323
+ async def cmd_members(message: Message, api: APIClient) -> None:
324
+ data = await api.groups.getMembers(group_id=bot.group_id, count=1)
325
+ await message.answer(f"Участников в группе: {data['count']}")
326
+
327
+
328
+ if __name__ == "__main__":
329
+ bot.run_polling()
330
+ ```
331
+
332
+ </details>
333
+
334
+ <details markdown="1">
335
+ <summary>With event handlers...</summary>
336
+
337
+ Handle any VK event type — not just messages:
338
+
339
+ ```python
340
+ from fastvk import FastVK
341
+ from fastvk.api import APIClient
342
+ from fastvk.types import Update
343
+
344
+ bot = FastVK(token="vk1.a.YOUR_TOKEN", group_id=123456789)
345
+
346
+
347
+ @bot.group_join()
348
+ async def on_join(event: dict, api: APIClient) -> None:
349
+ user_id = event.get("user_id")
350
+ await api.messages.send(
351
+ peer_id=user_id,
352
+ message="Добро пожаловать в группу!",
353
+ random_id=0,
354
+ )
355
+
356
+
357
+ @bot.wall_post_new()
358
+ async def on_new_post(event: dict) -> None:
359
+ print(f"Новый пост: {event.get('id')}")
360
+
361
+
362
+ @bot.on("photo_new")
363
+ async def on_photo(update: Update) -> None:
364
+ print(f"Новое фото: {update.object}")
365
+
366
+
367
+ if __name__ == "__main__":
368
+ bot.run_polling()
369
+ ```
370
+
371
+ </details>
372
+
373
+ ## Dependency injection
374
+
375
+ Handler parameters are resolved automatically by **name** (with type-based fallback). No manual wiring needed:
376
+
377
+ | Parameter | Type | Description |
378
+ |---|---|---|
379
+ | `message` | `Message` | Parsed message object (for `message_new` events) |
380
+ | `state` | `FSMContext` | FSM context for current user |
381
+ | `api` | `APIClient` | VK API client |
382
+ | `event` | `dict` | Raw event payload |
383
+ | `update` | `Update` | Full update object |
384
+
385
+ ```python
386
+ @router.message()
387
+ async def handler(
388
+ message: Message,
389
+ state: FSMContext,
390
+ api: APIClient,
391
+ ) -> None:
392
+ ...
393
+ ```
394
+
395
+ ## Contributing
396
+
397
+ Contributions are welcome! Please open an issue before submitting a pull request.
398
+
399
+ Found a bug? Open an issue on <a href="https://github.com/ndugram/fastvk/issues" target="_blank">GitHub</a>.
400
+
401
+ ## License
402
+
403
+ This project is licensed under the terms of the <a href="https://github.com/ndugram/fastvk/blob/master/LICENSE" target="_blank">MIT license</a>.