Python library for rubika API
Rubigram
Rubigram is a powerful asynchronous Python framework for building advanced bots on Rubika, offering features like concurrent message handling, advanced filtering, and support for both webhooks and polling.
Features
- Asynchronous and fast: handle multiple messages concurrently.
- Advanced filters for private chats, commands, and text messages.
- Easy message and media sending (text, images, videos, files).
- Support for both webhooks and polling.
- Interactive keyboards and buttons for better user engagement.
- Flexible integration with databases for storing settings and data.
Start
from rubigram import Client, filters
from rubigram.types import Update
client = Client("bot_token")
@client.on_message(filters.command("start"))
async def start(client: Client, update: Update):
await update.reply("||Hello|| __from__ **Rubigram!**")
client.run()
Button and Keypad
from rubigram import Client, filters
from rubigram.enums import ChatKeypadType
from rubigram.types import Update, Keypad, Button, KeypadRow
client = Client("bot_token")
@client.on_message(filters.photo)
async def start(client: Client, update: Update):
button_1 = Button("send", "send Photo")
button_2 = Button("save", "Save Photo")
row = KeypadRow([button_1, button_2])
keypad = Keypad([row])
await update.reply(
"Select your action:",
chat_keypad=keypad,
chat_keypad_type=ChatKeypadType.NEW
)
client.run()
Use webhook and Get inline button data
from rubigram import Client, Server, filters
from rubigram.types import (
Update,
Button,
Keypad,
KeypadRow,
InlineMessage
)
client = Client(token="bot_token")
server = Server(client, "webhook_url")
@client.on_message(filters.photo)
async def start(client: Client, update: Update):
button_1 = Button("send", "send Photo")
button_2 = Button("save", "Save Photo")
row = KeypadRow([button_1, button_2])
keypad = Keypad([row])
await update.reply("Select your action:", inline_keypad=keypad)
@client.on_inline_message(filters.button(["send", "save"]))
async def inline_message(client: Client, message: InlineMessage):
button_id = message.aux_data.button_id
if button_id == "send":
await message.answer("You clicked the send button")
else:
await message.answer("You clicked the save button")
@client.on_start()
async def start(client):
print("Start bot ....")
@client.on_stop()
async def stop(client):
print("Stop bot")
server.run_server()
Auto state and save tmp data in cache
from rubigram import Client, Storage, filters
from rubigram.types import Update
storage = Storage(ttl=120)
client = Client("bot_token", storage=storage) # You can leave the `storage` parametr empty
@client.on_message(filters.command("start") & filters.private)
async def start(client: Client, update: Update):
state = client.state(update.chat_id)
await state.set("name")
await update.reply("Send your name:")
@client.on_message(filters.state("name") & filters.text & filters.private)
async def save_name(client: Client, update: Update):
state = client.state(update.chat_id)
await state.set("email", name=update.text)
await update.reply("Send your Email:")
@client.on_message(filters.state("email") & filters.text & filters.private)
async def save_email(client: Client, update: Update):
state = client.state(update.chat_id)
data = await state.get()
print(data)
await state.delete()
client.run()
Implementation of multiple programs
from rubigram import Client
import asyncio
tokens = ["TOKEN_1", "TOKEN_2"]
async def main():
for token in tokens:
async with Client(token) as client:
info = await client.get_me()
print(info)
asyncio.run(main())
Rubino
from rubigram.rubino import Rubino
import asyncio
async def main():
async with Rubino(auth="auth_account") as client:
info = await client.get_my_profile_info()
print(info)
asyncio.run(main())
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
rubigramclient-1.7.40.tar.gz
(82.3 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 rubigramclient-1.7.40.tar.gz.
File metadata
- Download URL: rubigramclient-1.7.40.tar.gz
- Upload date:
- Size: 82.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d53688f5807df5c712c3a93774d7b0da002d7453e784923bd93cc42ff50465f9
|
|
| MD5 |
4a5dc49a41c98c0a4bc2c2a95584acc5
|
|
| BLAKE2b-256 |
566e4fdc8c887c66a12b4a3bda9e0c759e9bd7bf02f9caf8ad332dbabef8216a
|
File details
Details for the file rubigramclient-1.7.40-py3-none-any.whl.
File metadata
- Download URL: rubigramclient-1.7.40-py3-none-any.whl
- Upload date:
- Size: 183.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5d66eb4e9b842f984c3a4a6895b86b67b5701b4609b2c302e29dba906f184c0c
|
|
| MD5 |
47fa242a360d86f6e68672de42d0c17c
|
|
| BLAKE2b-256 |
3198b8704736c508ba14652bde7fdca52f25b20170dfcd0b5351fcaa17fa508d
|