Skip to main content

Kabforge

Kabforge — это лёгкий и удобный фреймворк для создания Telegram-ботов на Python.
Он создан с целью упростить работу с Telegram Bot API и сделать код максимально чистым и читаемым.

Установка

pip install kabforge

Быстрый старт

Пример простого бота:

import asyncio
import logging
import os

from kabforge.client import Bot
from kabforge.dispatcher import Dispatcher
from kabforge.types import Message

logging.basicConfig(level=logging.INFO)

# Токен рекомендуется хранить в переменных окружения
BOT_TOKEN = os.getenv("BOT_TOKEN", "YOUR_BOT_TOKEN_HERE")

bot = Bot(token=BOT_TOKEN)
dp = Dispatcher()


@dp.on_message(command="/start")
async def start_handler(message: Message):
    await bot.send_message(chat_id=message.chat_id, text="Hello!")
    await message.test()


@dp.on_message(command="t")
async def t_handler(message: Message):
    await bot.send_message(chat_id=message.chat_id, text="Text message detected!")


@dp.on_sticker()
async def sticker_handler(message: Message):
    await bot.send_message(chat_id=message.chat_id, text="Sticker detected!")


@dp.on_message(command="huy")
async def huy_handler(message: Message):
    await message.answer(text="blya")


async def main():
    try:
        await dp.start_polling(bot)
    finally:
        await bot.close()


if __name__ == "__main__":
    try:
        asyncio.run(main())
    except KeyboardInterrupt:
        print("Бот экстренно выключен")

Возможности

  • Простая регистрация хендлеров через декораторы
  • Поддержка различных типов апдейтов (сообщения, стикеры и др.)
  • Удобная работа с объектами Telegram API
  • Асинхронность (asyncio)

Лицензия

MIT License

Metadata

Release files for kabforge 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for kabforge 0.1.3
File Size Uploaded
kabforge-0.1.3.tar.gz 8.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for kabforge 0.1.3
File Interpreter ABI Platform
kabforge-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 16.1 kB

Release files / kabforge-0.1.3.tar.gz

Download URL kabforge-0.1.3.tar.gz
Size 8.2 kB
Tags Source
SHA-256 checksum
How to use checksums
1583a509c41fb74b98664ce4a1ef9f9cdd365a4bdb464ce677cf6cd55057f1ae
BLAKE2b-256 checksum
How to use checksums
22d309dad98fa7207a6c9e1a87c2a382f33a4da0269b526d3aa51c2f23182274
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.3

Release files / kabforge-0.1.3-py3-none-any.whl

Download URL kabforge-0.1.3-py3-none-any.whl
Size 7.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7c8b3f3a58ca5b9f4dcaa2dee7a8544735d3be76e4cef38e3e22a3b13a404ca7
BLAKE2b-256 checksum
How to use checksums
0ee3f52d7dd0fe8b993fca96082ed26ad28b73695c4b25bc37ac327483d56c60
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 release files

0.1.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page