Skip to main content

A simple and flexible Python library for building advanced Rubika bots with powerful message handling, inline buttons, and custom filters.

Project description

Rubigram

Python library for rubika API

PyPI Documentation

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", webhook="webhook_url")
server = Server(client, host="127.0.0.1", port=8080)


@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 save send button")
    else:
        await message.answer("You clicked the save 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())

Project details


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.19.tar.gz (63.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rubigramclient-1.7.19-py3-none-any.whl (121.8 kB view details)

Uploaded Python 3

File details

Details for the file rubigramclient-1.7.19.tar.gz.

File metadata

  • Download URL: rubigramclient-1.7.19.tar.gz
  • Upload date:
  • Size: 63.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for rubigramclient-1.7.19.tar.gz
Algorithm Hash digest
SHA256 c6940538e9aa2ea1879f8e01ef6ac789dce888946cbc7f7fbd85ae7dc8b9383b
MD5 bdac55a843c16d9687f4093d0ab25cc6
BLAKE2b-256 ad24a330657f78a4b5b696b96603d47de529ab3ff5296c97ece68f8fff923d75

See more details on using hashes here.

File details

Details for the file rubigramclient-1.7.19-py3-none-any.whl.

File metadata

File hashes

Hashes for rubigramclient-1.7.19-py3-none-any.whl
Algorithm Hash digest
SHA256 4b6cac5d962e86d28c5487341e2a95b61d65a63dbca7cf38068b0b4b6b243ddf
MD5 285240836f9013b6fdd311ce4d4c8926
BLAKE2b-256 e97a1b3a93d38d549f976f0a20bbd253ada3ee506dd7082b9b941276a4a8b341

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page