A Telegram bot wrapper for K-Defender security
Project description
K-Defender-wrapper
🛡️ K-Defender-wrapper protects Telegram bot handlers with K-Defender verdict checks. Works with both async and sync bot libraries.
Features
- Async + sync support in one API
- Compatible with aiogram, python-telegram-bot, TeleBot and similar frameworks
- Decorator-based protection (
@kdefender_check) - Automatic message/callback text detection
- Safe-by-default blocking on failed verdict/network errors
Installation
pip install kdefender-wrapper
Quick Start (aiogram / PTB async)
from kdefender_wrapper import setup, close, kdefender_check
await setup(
bot=bot,
url=URL,
chat_token=CHAT_TOKEN, # token from K-Defender
lang="en"
)
@kdefender_check()
async def handler(message):
await message.answer("Message accepted")
@kdefender_check(param="message")
async def strict_handler(message):
await message.answer("Message accepted")
await close()
Quick Start (TeleBot sync)
from kdefender_wrapper import setup, close, kdefender_check
setup(
bot=bot,
url=URL,
chat_token=CHAT_TOKEN,
lang="en"
)
@kdefender_check()
def handler(message):
bot.reply_to(message, "Message accepted")
close()
How It Works
- User message is intercepted
- Text is sent to K-Defender
/check/ - JSON verdict is parsed
- Handler executes only for
{"result":"ok"} - Otherwise message is blocked and user gets a safe notice
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
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 kdefender_wrapper-0.4.0-py3-none-any.whl.
File metadata
- Download URL: kdefender_wrapper-0.4.0-py3-none-any.whl
- Upload date:
- Size: 7.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6e02569d5a7ab065c51f0eb4732c617c8e70c24ca0b8bd5233522fb9bdd74661
|
|
| MD5 |
40b9b33aff5a633653d66c06764b3c3e
|
|
| BLAKE2b-256 |
b227f80c13681e1b4a70e045d0ef8bc373931d53d1168dcb47893bf89216105b
|