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

A lightweight Python library to build Rubika bots easily.

Rubigram Logo

Installation

pip install RubigramClient

Quick Example

from rubigram import Client
from rubigram.types import Update

client = Client(token="...")

@client.on_message()
async def start(client: Client, update: Update):
    await update.reply(text="Hi, rubigram user!")

client.run()

Reply and Edit message

from rubigram import Client
from rubigram.types import Update

client = Client(token="...")

@client.on_message()
async def echo(client: Client, update: Update):
    message = await update.reply(text=f"Hi, {update.new_message.text}")
    await message.edit_text(text="message was edited")

client.run()

Send Message & Get receiveInlineMessage

from rubigram import Client, filters
from rubigram.types import Update, Button, Keypad, KeypadRow, InlineMessage


client = Client(token="...", webhook_url="...")


@client.on_message(filters.command("start"))
async def start(client: Client, update: Update):
    inline = Keypad(
        rows=[
            KeypadRow(
                buttons=[
                    Button(id="1", button_text="Button 1"),
                    Button(id="2", button_text="Button 2")
                ]
            )
        ]
    )
    await update.reply("The inline message", inline_keypad=inline)


@client.on_inline_message(filters.button(["1", "2"]))
async def button(client: Client, update: InlineMessage):
    if update.aux_data.button_id == "1":
        await client.send_message(chat_id=update.chat_id, text="You Click Button 1")
    elif update.aux_data.button_id == "2":
        await client.send_message(chat_id=update.chat_id, text="You Click Button 2")
        
client.run()

Filters

from rubigram import Client, filters
from rubigram.types import Update

client = Client(token="...")


@client.on_message(filters.text)
async def text(client: Client, update: Update):
    await update.reply(text="message is text")


@client.on_message(filters.contact)
async def contact(client: Client, update: Update):
    await update.reply(text="message is contact")


@client.on_message(filters.edited)
async def edited(client: Client, update: Update):
    await update.reply(text="message is edited")


@client.on_message(filters.file)
async def file(client: Client, update: Update):
    await update.reply(text="message is efiledited")

client.run()

Handlers

from rubigram import Client

client = Client(token="...")

@client.on_message()
async def new_message():
    ...
    
@client.on_inline_message()
async def inline_message():
    ...
    
@client.on_update_message()
async def update_message():
    ...
    
@client.on_remove_message()
async def remove_message():
    ...
    
@client.on_started_bot()
async def start_bot():
    ...
    
@client.on_stopped_bot()
async def stop_bot():
    ...
    
@client.on_start()
async def start():
    ...

@client.on_stop()
async def stop():
    ...

Contex Manager

from rubigram import Client
import asyncio


async def main():
    async with Client(token="...") as client:
        data = await client.get_me()
        print(data.bot_id)

asyncio.run(main())

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=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="...") 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.5.tar.gz (50.6 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.5-py3-none-any.whl (89.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: rubigramclient-1.7.5.tar.gz
  • Upload date:
  • Size: 50.6 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.5.tar.gz
Algorithm Hash digest
SHA256 60e17398eaff4f394799d65a45b59fb10e2e8795718d165c3639aa3a28569dd7
MD5 265f273e0d71ef08d0566cc391c27556
BLAKE2b-256 99a7e9f125ffcdd24395dae403b4e3c68b093f762aa6d08c201b3fd73c5940a0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rubigramclient-1.7.5-py3-none-any.whl
  • Upload date:
  • Size: 89.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for rubigramclient-1.7.5-py3-none-any.whl
Algorithm Hash digest
SHA256 2d25c77f10c817dbeda187717708e6c45225dbca7f564afe3384a3c7dd481995
MD5 a4d13d62e4685f73e26a69c40322484b
BLAKE2b-256 316de667974df0f9312b8c88b01c269a77ffe48aca9fc545461b80891e184df9

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