No project description provided
Project description
# Rubkey - Rubika Bot API Library
> Official Rubika Channel: [@library_rubkey](https://rubika.ir/library_rubkey)
Rubika Bot API library - Simple and powerful bot framework for Rubika messenger
## Features
Send text messages with Chat Keypad and Inline Keypad
Send polls
Send files (image, video, file, voice, music, gif)
Send contacts from bot
Send locations from bot
Chat Keypad with button types: Simple, AskMyPhoneNumber, Textbox, File, GalleryImage, GalleryVideo, CameraImage, CameraVideo, Audio, RecordAudio, Barcode
SendCodeButton: Textbox button for sending verification code via Rubika API
Inline Keypad with auto-updating data (counter, stats, etc.)
Inline Keypad with advanced buttons: Selection, NumberPicker, StringPicker, Link, Barcode, Textbox, Calendar
Calendar button with Persian and Gregorian support
Textbox button with SingleLine/MultiLine and String/Number keypad
Markdown parse mode: Bold, Italic, Underline, Strike, Spoiler, Quote, Link, Mono, Pre
Metadata system for text formatting (Bold, Italic, Underline, Strike, Spoiler, Mono, Pre, Link, Mention, Quote)
Admin system with ADMIN_ID and ADMIN_PASSWORD
Admin-specific commands, buttons, and keypads
Ban system with ban/unban users
Group ban/unban with reply (message_map)
Edit and delete messages
Edit message with Inline Keypad update
Edit and remove Chat Keypad
Forward messages and files
Message handlers for commands, buttons, and all messages
Command and message filters with regex
Rate limiting to prevent spam
Cache system for faster responses
Error handling with automatic retry (exponential backoff)
Analytics for tracking user behavior
Auto-delete messages with rules and filter words
Filter words with add/remove
Session management with auto offset saving
SQLite offset storage (automatic rebuild)
Smart skip old messages
User session storage (JSON)
SQLite database for messages and users
Full async bot support with asyncio + aiohttp
AsyncBot: all sync features in async
AsyncGroupBot: all group features in async
AsyncChannelBot: all channel features in async
AsyncSendFile: file upload/download in async
AsyncWebhookServer: webhook in async
Webhook support (aiohttp async server)
Webhook auto-start with set_webhook
Webhook with middleware and router
SelfBot: self-bot with phone number login
SelfBot commands (with slash / without slash)
SelfBot message edit and reply
SelfBot session save/load
Contact and file receiving from users
Built-in user counter (total_users, user_ids)
Group support with GroupBot and GroupHandlers
Group admin system (set/remove/is/get admins)
Admin only ban mode
Group auto-delete with admin bypass
Group-specific commands, messages, and buttons
Group data storage
Get group info (title, chat_id, type)
Channel support with ChannelBot and ChannelHandlers
Channel commands, messages, and data storage
Get channel info (title, chat_id, type, username)
Plugin system with auto-loading and reloading
QR/Barcode scanning
## Sync Methods
send_message(chat_id, text, keypad=None, inline_keypad=None, reply_to=None, metadata=None, parse_mode=None) — Send text message
edit_message(chat_id, message_id, text, inline_keypad=None, metadata=None, parse_mode=None) — Edit message
delete_message(chat_id, message_id) — Delete message
send_poll(chat_id, question, options) — Send poll
send_file(chat_id, file_id, text=””, keypad=None, inline_keypad=None, reply_to=None) — Send file
send_contact(chat_id, first_name, phone_number, last_name=””) — Send contact
send_location(chat_id, latitude, longitude) — Send location
forward_message(from_chat_id, to_chat_id, message_id) — Forward message
get_chat(chat_id) — Get chat information
get_me() — Get bot information
remove_keypad(chat_id) — Remove Chat Keypad
edit_chat_keypad(chat_id, keypad) — Edit Chat Keypad
set_commands(commands) — Set bot commands
delete_commands() — Delete all commands
ban_chat_member(chat_id, user_id) — Ban member in group
unban_chat_member(chat_id, user_id) — Unban member in group
set_webhook(url, host=”0.0.0.0”, port=5000) — Set webhook and auto-start server
delete_webhook() — Delete webhook and stop server
get_webhook_info() — Get webhook status
get_updates(limit=10) — Get updates
poll_updates(limit=10, sleep=1) — Continuous updates generator
run() — Start bot polling
## SendCodeButton
SendCodeButton(button_id, text, type_line=”SingleLine”, type_keypad=”Number”, place_holder=””, title=””) — Create send code button
send_code_btn.handle(bot, chat_id, text) — Send verification code
Auto-reply: Code sent… or Error sending code…
## Async Methods
### AsyncBot - await bot.send_message(chat_id, text, …) — Send message - await bot.edit_message(chat_id, message_id, text, …) — Edit message - await bot.delete_message(chat_id, message_id) — Delete message - await bot.send_poll(chat_id, question, options) — Send poll - await bot.send_file(chat_id, file_id, text, …) — Send file - await bot.send_contact(chat_id, first_name, phone_number, last_name=””) — Send contact - await bot.send_location(chat_id, latitude, longitude) — Send location - await bot.forward_message(from_chat_id, to_chat_id, message_id) — Forward message - await bot.get_chat(chat_id) — Get chat info - await bot.get_me() — Get bot info - await bot.remove_keypad(chat_id) — Remove keypad - await bot.edit_chat_keypad(chat_id, keypad) — Edit keypad - await bot.set_commands(commands) — Set commands - await bot.delete_commands() — Delete commands - await bot.ban_chat_member(chat_id, user_id) — Ban member - await bot.unban_chat_member(chat_id, user_id) — Unban member
### AsyncGroupBot - await bot.get_group_info(chat_id) — Get group info - bot.set_group_admin(group_id, user_id) — Set admin - bot.is_group_admin(group_id, user_id) — Check admin - bot.get_group_admins(group_id) — List admins - All GroupBot features in async
### AsyncChannelBot - await bot.get_channel_info(chat_id) — Get channel info - await bot.send_to_channel(channel_id, text) — Send to channel - await bot.edit_in_channel(channel_id, message_id, text) — Edit in channel - await bot.delete_in_channel(channel_id, message_id) — Delete in channel - await bot.forward_to_channel(from_chat_id, channel_id, message_id) — Forward to channel - await bot.send_poll_to_channel(channel_id, question, options) — Poll in channel - All ChannelBot features in async
### AsyncSendFile - await sendfile.request_send_file(file_type) — Request upload URL - await sendfile.upload_file(upload_url, file_path) — Upload file - await sendfile.send_file(chat_id, file_id, text) — Send file
### AsyncWebhookServer - server.run() — Start server - server.run_in_thread() — Start in background - server.stop() — Stop server
## SelfBot
bot = SelfBot() — Create self-bot
bot.run() — Start self-bot (auto login)
bot.send_message(chat_id, text) — Send message
bot.edit_message(chat_id, message_id, text) — Edit message
@bot.on_command(“text”, slash=True) — Command with slash
@bot.on_command(“text”, slash=False) — Command without slash
@bot.on_message() — Message handler
msg.reply(text) — Reply to message
msg.edit(text) — Edit message
## Markdown Parse Mode
**text** — Bold
*text* — Italic
__text__ — Underline
~~text~~ — Strike
||text|| — Spoiler
`` text `` — Mono
`text` — Pre
> text — Quote
[text](url) — Link
## Metadata System
Metadata() — Create metadata object
metadata.add_part(MetadataPart(type, from_index, length, **kwargs)) — Add metadata part
Types: Bold, Italic, Underline, Strike, Spoiler, Mono, Pre, Link, Mention, Quote
## Auto-Delete System
set_auto_delete(rules) — Set auto-delete rules
add_filter_word(word) — Add filter word
remove_filter_word(word) — Remove filter word
admins_can_bypass_delete — Admins bypass auto-delete
## Ban System
ban_user(user_id) — Ban a user
unban_user(user_id) — Unban a user
admin_ban(msg, user_id) — Ban by admin only
ban_chat_member(chat_id, user_id) — Ban in group
unban_chat_member(chat_id, user_id) — Unban in group
banned_users — Set of banned users
## Webhook
set_webhook(url, host=”0.0.0.0”, port=5000) — Set webhook and auto-start server
delete_webhook() — Delete webhook and stop server
get_webhook_info() — Get webhook status
WebhookServer(bot, host, port) — Sync webhook server
AsyncWebhookServer(bot, host, port) — Async webhook server
server.run() / server.run_in_thread() / server.stop()
## Analytics
get_analytics(user_id=None) — Get analytics
set_rate_limit(max_per_second=5, window=1) — Rate limit
set_cache_ttl(ttl) — Cache TTL
## File Methods (SendFile / AsyncSendFile)
SendFile(bot) — Sync file sender
AsyncSendFile(bot) — Async file sender
sendfile.request_send_file(file_type=”Image”) — Request upload URL
sendfile.upload_file(upload_url, file_path) — Upload file
sendfile.send_file(chat_id, file_id, text) — Send file
## Handlers
@bot.command(“name”, pattern=None) — Handle command with optional regex
@bot.on_message(pattern=None) — Handle messages with optional regex
@bot.on_button(“button_id”) — Handle button clicks
## Filters
Filters.command(“name”) — Filter by command
Filters.text(“text”) — Filter by text
Filters.regex(pattern) — Regex filter
Filters.chat_type(“private/group/channel”) — Chat type filter
Filters.has_file() / Filters.has_contact() / Filters.has_button(“id”) — Content filters
Filters.is_admin() — Admin filter
Filters.and/or/not_filter(…) — Combine filters
## Middleware & Router
bot.add_middleware(func) — Add middleware
Router() — Create router
router.command(“name”, filters=…) — Router command
router.on_message(filters=…) — Router message
router.on_button(“id”, filters=…) — Router button
bot.include_router(router) — Include router
## Admin System
bot.ADMIN_ID / bot.ADMIN_PASSWORD — Admin settings
@bot.admin_command(“name”) — Admin command
@bot.admin_on_message() — Admin messages
@bot.admin_on_button(“button_id”) — Admin buttons
## Group System
GroupBot(token) / AsyncGroupBot(token) — Group bot
bot.set_group_handlers(handlers) — Set handlers
bot.get_group_info(chat_id) — Group info (title, chat_id, type)
bot.set_group_admin(id, user_id) — Set admin
bot.remove_group_admin(id, user_id) — Remove admin
bot.is_group_admin(id, user_id) — Check admin
bot.get_group_admins(id) — List admins
bot.first_admin_on_start / bot.first_n_admins / bot.no_admin_mode / bot.admin_only_ban
GroupHandlers() — Group handlers
handlers.command(“name”, group_only=True) — Group command
handlers.on_message(group_only=True) — Group message
handlers.on_button(“id”, group_only=True) — Group button
handlers.set_data/get_data — Group data storage
## Channel System
ChannelBot(token) / AsyncChannelBot(token) — Channel bot
bot.set_channel_handlers(handlers) — Set handlers
bot.get_channel_info(chat_id) — Channel info (title, chat_id, type, username)
bot.send_to_channel/edit_in_channel/delete_in_channel — Channel management
bot.forward_to_channel/send_poll_to_channel — Channel actions
ChannelHandlers() — Channel handlers
handlers.command(“name”) / handlers.on_message() / handlers.set_data/get_data
## Session & Database
Session(session_file=”session.json”) — JSON session
session.set/get/delete/clear — Session methods
Database(db_path=”rubkey.db”) — SQLite database
database.init/save_message/save_user/get_messages/get_user
## Plugin System
PluginLoader(bot, plugin_dir=”plugins”) — Plugin loader
loader.load_all() / loader.reload_all()
Plugin(info) — Plugin object
PluginInfo(name, version, author, description) — Plugin info
@plugin.command/on_message/on_button/admin_command/admin_on_message/admin_on_button
## Keypad Classes
Keypad(resize=True, one_time=False) — Chat Keypad
KeyButton(button_id, text, button_type=”Simple”) — Chat button
TextboxButton(…) — Textbox button
FileButton(…) — File picker button
BarcodeButton(…) — Barcode scanner (Chat Keypad)
SendCodeButton(…) — Send verification code button
InlineKeypad() — Inline Keypad
InlineButton(button_id, text, button_type=”Simple”) — Inline button
## Advanced Inline Buttons
SelectionButton(…) — Selection list
NumberPickerButton(…) — Number picker
StringPickerButton(…) — String picker
LinkButton(…) — Link button
BarcodeInlineButton(…) — Barcode scanner
TextboxInlineButton(…) — Textbox
CalendarButton(…) — Calendar (Persian/Gregorian)
## Message Object
msg.text — Message text
msg.chat_id — Chat ID
msg.message_id — Message ID
msg.sender_id — Sender ID
msg.time — Message time
msg.is_edited — Edit status
msg.button_id — Clicked button ID
msg.contact — Contact info
msg.file — File info (file_id, file_name, size)
msg.poll — Poll info
msg.aux_data — Auxiliary data
msg.reply_to_message_id — Reply ID
msg.reply(text, …) — Reply
msg.edit(text, …) — Edit
msg.delete() — Delete
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
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 rubkey-2.0.7.tar.gz.
File metadata
- Download URL: rubkey-2.0.7.tar.gz
- Upload date:
- Size: 22.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.34.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
04d0b67fcfabe20cc949ae22da26a72b2c303f34d71bf382b63845e02429aa79
|
|
| MD5 |
07defbb47fd0019094cd6a2cc4a2d82a
|
|
| BLAKE2b-256 |
080ebe2caff0c135005c58fa6c9895a4727ed796bc215839cc78a1807ed5f2a2
|
File details
Details for the file rubkey-2.0.7-py3-none-any.whl.
File metadata
- Download URL: rubkey-2.0.7-py3-none-any.whl
- Upload date:
- Size: 34.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.34.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8d9116ea96fc397a32874ea0a32636bba20d03f78d33277c39d25cf26a3d2a7e
|
|
| MD5 |
0b39ecc4edf536257861ff6e69d88575
|
|
| BLAKE2b-256 |
a2be6fd8804c398a59b097345dfbc4571e7cc93625336cbd013935815a230e1a
|