Skip to main content

home
rubithon for rubika client, python 3 | milad heidari
document • github

Rubika Client for python 3

issues forks version stars license icon

install

pip install rubithon

exmaple

import asyncio
from rubithon import Client, models, handlers


async def main():
    async with Client(session='rubika') as client:
        @client.on(handlers.MessageUpdates(models.author_guid() == client._guid))
        async def updates(update):
            await update.reply('`hello` __from__ **rubika**')
        await client.run_until_disconnected()

asyncio.run(main())

methods class

  • You can find the list of methods in the methods.json

  • The list of methods is divided into 9 groups, which are: users, chats, extras, groups, messages, channels, conracts, settings, stickers, authorisations

The output of all methods is a dictionary that you must give to the call method

  • Example

from rubithon import Client, methods

client = Client(...)
result = await Client(methods.users.GetUserInfo(user_guid='...'))

Example to get the list of methods of a group

from rubithon import methods
print(dir(methods.users))
  • Example of getting the list of arguments of a method

from rubithon import methods
print(methods.users.SetBlockUser)

Raises

  • TypeError: if the data type is inconsistent with the allowed values types
  • ValueError: if the value does not exist in the allowed list

handlers class

  • Including 5 classes (may be increased) which are: ChatUpdates, MessageUpdates, ShowActivities, ShowNotifications, RemoveNotifications

  • These are used to filter updates, whose names indicate what type of update they receive.

The inputs of these classes are models, If __any is true, OR operator is placed between the filters, otherwise AND

Filters can be functions Example

from rubithon import handlers


async def custom_filter(update, result):
    return update.raw_text

handlers.MessageUpdates(custom_filter)

Tips

  • Filters can be functions
  • Between the filters you can use the operators |, &, !=, ==, >, >=, <, <= use
  • To use the operators, the filter (model) must be called

models class

  • Including 3 classes, which are: Operator, BaseModels, RegexModel

You can use all the attributes of the update, the most important of which have already been written

Examples

async def custom_filter(update, result):
    return result


handlers.MessageUpdates('hi' != models.raw_text())
handlers.MessageUpdates(custom_filter != models.raw_text())


handlers.MessageUpdates(custom_filter == models.time(func=int))


handlers.MessageUpdates(models.RegexModel(pattern=r'hi'))

Multiple Filters (AND)

handlers.MessageUpdates(
    (15 < models.time(func=int) > 10)
    &
    models.RegexModel(pattern=r'hi')
    &
    models.is_private
)

# or


handlers.MessageUpdates(
    15 < models.time(func=int) > 10,
    models.RegexModel(pattern=r'hi'),
    models.is_private
)

Multiple Filters (OR)

handlers.MessageUpdates(
    models.is_private
    |
    (models.author_guid() == 'GUID')
)

# or 

handlers.MessageUpdates(
    models.is_private,
    models.author_guid() == 'GUID',
    __any=True
)

Get updates (add handler)

async with Client(session='rubika') as client:
    @client.on(handler)
    async def updates(update):
        pass


# or

async with Client(session='rubika') as client:
    async def updates(update):
        pass
    
    client.add_handler(updates, handler)
    

✌ در آرزوی جهانی ...

Metadata

Release files for rubithon 1.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rubithon 1.1.1
File Size Uploaded
rubithon-1.1.1.tar.gz 23.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for rubithon 1.1.1
File Interpreter ABI Platform
rubithon-1.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 50.1 kB

Release files / rubithon-1.1.1.tar.gz

Download URL rubithon-1.1.1.tar.gz
Size 23.5 kB
Tags Source
SHA-256 checksum
How to use checksums
17a830a390f2f0dd5c36306a43db9e216fd57e24dc8e7535f7f413a93dfbbeb2
BLAKE2b-256 checksum
How to use checksums
acb49b4e2fbf3410875634cce5471fd72e47f89565490016b24780bd92e0897a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.13

Release files / rubithon-1.1.1-py3-none-any.whl

Download URL rubithon-1.1.1-py3-none-any.whl
Size 26.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
df477a56169f1860da1f7c831e114d5cbdf4ce4eb91a47f0895da630fed743e1
BLAKE2b-256 checksum
How to use checksums
293084818b5921e29e111188b5e37d4e95e7deee2033bb1e96624dac31d52f52
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.13

Release history Release notifications | RSS feed

This release

1.1.1 This release

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page