pyrokit
Usecase
API_ID = 123456 # Replace with your API_ID
API_HASH = "your_api_hash" # Replace with your API_HASH
TOKEN = "my_bot_session"
app = Client(TOKEN, API_ID, API_HASH)
kit = PyroKit()
@app.on_message(filters.command("clean"))
@kit.ensure_admin(permissions=["can_delete_messages"])
@auto_flood
@rate_limit(5, 60)
async def clean_command(client: Client, message: Message):
"""Delete multiple messages with progress"""
progress_msg = await message.reply("🧹 Cleaning...")
async def progress(current, total):
bar, perc = await kit.create_progress_bar(current, total)
await kit.edit_or_resend(progress_msg, f"Cleaning: {bar} {perc}%")
await client.delete_messages(
chat_id=message.chat.id,
message_ids=range(message.message_id-10, message.message_id),
progress=progress
)
await kit.safe_delete(progress_msg)
@app.on_callback_query(filters.regex(r"^page_\d+"))
@kit.async_retry(max_retries=3)
async def handle_pagination(client: Client, query: CallbackQuery):
"""Handle inline keyboard pagination"""
page = int(query.data.split("_")[1])
content = f"Page {page} content"
buttons = kit.inline_keyboard([
[("Previous", f"page_{page-1}"), ("Next", f"page_{page+1}")]
])
await kit.answer_query(query, f"Switched to page {page}")
await kit.edit_or_resend(query.message, content, reply_markup=buttons)
# ==================== MAIN EXECUTION ====================
if __name__ == "__main__":
logging.basicConfig(level=logging.INFO)
app.run()
PyroKit Documentation
A comprehensive utility toolkit for Pyrogram bot development
1. Core Features:
-----------------
- Automated flood control
- Rate limiting with multiple strategies
- Admin permission verification
- Async error retry mechanism
- Smart message management
2. Advanced Features:
---------------------
- Database integration with connection pooling
- Multi-language localization support
- Error reporting to webhooks
- File validation and temp file management
- Inline query pagination
- Middleware processing pipeline
- Stateful conversation handlers
3. Usage Examples:
------------------
3.1 Database Integration:
@app.on_message(filters.command("stats"))
@kit.with_db
async def show_stats(client, message, db):
count = await db.fetchval("SELECT COUNT(*) FROM users")
await message.reply(f"Total users: {count}")
3.2 Localization:
@app.on_message(filters.command("help"))
@kit.localized(fallback_lang='en')
async def help_command(client, message, lang):
await message.reply(lang['help_text'])
3.3 Error Reporting:
@app.on_message(filters.command("danger"))
@kit.error_webhook("https://errors.example.com")
async def risky_command(client, message):
# Potentially error-prone code
...
4. Configuration:
-----------------
Initialize with custom config:
config = {
'temp_dir': 'my_temp_files',
'max_file_size': 5_000_000_000,
'db_dsn': 'postgres://user:pass@localhost/db'
}
kit = PyroKit(config)
5. Best Practices:
------------------
- Use @safe_delete for message cleanup
- Always validate downloaded files
- Use middleware for analytics tracking
- Implement rate limiting on public endpoints
- Store user-specific data in conversation states
Metadata
Release files for pyrokit 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pyrokit-0.0.1.tar.gz | 8.5 kB | Without provenance | Details for pyrokit-0.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pyrokit-0.0.1-py3-none-any.whl | Python 3 | none | any | Details for pyrokit-0.0.1-py3-none-any.whl |
Total release size: 17.2 kB
Release files / pyrokit-0.0.1.tar.gz
| Download URL | pyrokit-0.0.1.tar.gz |
|---|---|
| Size | 8.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d12a4ff22d7cc03263ec99fbfe885d6ef2ace76fac80fea0d76e797d87c5d0c2
|
|
BLAKE2b-256 checksum How to use checksums |
3aee15aa7a02069547afd449e3dd3da065c62cb658774faeead042edfc55f20c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.21
|
Release files / pyrokit-0.0.1-py3-none-any.whl
| Download URL | pyrokit-0.0.1-py3-none-any.whl |
|---|---|
| Size | 8.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
38aa973a0c240b25dd55354921640e441e555742b8c5092eb24c3e5e0640b3d3
|
|
BLAKE2b-256 checksum How to use checksums |
701181ffbf7a0a742df8eb9ea968b1219a7adde0a0a217e650be210b28211884
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.21
|
Security for pyrokit 0.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.