Async framework for VK Teams bots (aiogram-style)
Project description
solobot-vkteams
Асинхронный Python-фреймворк для создания ботов VK Teams (Mail.ru / ICQ), вдохновлённый aiogram.
Возможности
- API в стиле aiogram — Bot → Dispatcher → Router → Handlers
- Фильтры —
Command,Regexp,ChatTypeFilter,CallbackData,HasFile,HasImage,IsReply,IsForwardи другие - Magic Filter — цепочки атрибутов вида
F.text.startswith("привет") - FSM — конечный автомат с
State/StatesGroupи подключаемым хранилищем (MemoryStorage) - Треды (Threads) — создание и работа с обсуждениями в чатах
- Middleware — внешние и внутренние middleware для каждого роутера
- Inline-клавиатуры — удобный API для построения кнопок
- Полностью асинхронный — построен на
aiohttp - Типизированный — включает
py.typed, совместим с mypy / pyright
Установка
pip install solobot-vkteams
Быстрый старт
import asyncio
from solobot_vkteams import Bot, Dispatcher, Router, Message, Command, F
TOKEN = "YOUR_TOKEN_HERE"
API_URL = "https://myteam.mail.ru/bot/v1"
bot = Bot(token=TOKEN, api_url_base=API_URL)
dp = Dispatcher()
router = Router()
@router.message(Command("start"))
async def on_start(event: Message, bot: Bot):
await event.answer("Привет!")
@router.message(F.text)
async def on_text(event: Message, bot: Bot):
await event.reply(f"Вы написали: {event.text}")
dp.include_router(router)
asyncio.run(dp.run_polling(bot))
Inline-клавиатуры
from solobot_vkteams import InlineKeyboardMarkup, InlineKeyboardButton
kb = InlineKeyboardMarkup()
kb.row(
InlineKeyboardButton(text="Да", callback_data="yes"),
InlineKeyboardButton(text="Нет", callback_data="no"),
)
await bot.send_text(chat_id=chat_id, text="Выберите:", inline_keyboard_markup=kb)
FSM (конечный автомат)
from solobot_vkteams import State, StatesGroup, FSMContext
class Form(StatesGroup):
name = State()
age = State()
@router.message(Command("form"))
async def start_form(event: Message, bot: Bot, state: FSMContext):
await state.set_state(Form.name)
await event.answer("Как вас зовут?")
@router.message(Form.name)
async def process_name(event: Message, bot: Bot, state: FSMContext):
await state.update_data(name=event.text)
await state.set_state(Form.age)
await event.answer("Сколько вам лет?")
Треды (Threads)
from solobot_vkteams import Thread
# Создание треда
@router.message(Command("createthread"))
async def cmd_create_thread(event: Message, bot: Bot):
thread = await event.add_thread()
await thread.send_text("👋 Обсуждение начато!")
# Отправка сообщения в тред
await bot.send_text(
chat_id=chat_id,
text="Сообщение в треде",
thread_id=thread_id,
)
Требования
- Python 3.12+
- aiohttp >= 3.9
Лицензия
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
solobot_vkteams-0.2.0.tar.gz
(30.5 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file solobot_vkteams-0.2.0.tar.gz.
File metadata
- Download URL: solobot_vkteams-0.2.0.tar.gz
- Upload date:
- Size: 30.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d2a65ca2248c2f47aa45f677026258382d85f3e598e1eb7d6a848438843046b9
|
|
| MD5 |
46003276642f9aae9e8200c74d44e736
|
|
| BLAKE2b-256 |
a61bd37c32d8abacc321c5c72b1009f984135f34bc141ed1061c98073f31fff6
|
File details
Details for the file solobot_vkteams-0.2.0-py3-none-any.whl.
File metadata
- Download URL: solobot_vkteams-0.2.0-py3-none-any.whl
- Upload date:
- Size: 21.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
211878f9f93555b811113d47726cf759998d7c2bf7de92f691e3aab1b5fe872a
|
|
| MD5 |
8c534632dc809d633eca8e52d2145388
|
|
| BLAKE2b-256 |
226c1873f059518e352f4c1d0adcd18b77f1bf798702ab4e5906debab07c210c
|