Skip to main content

ribithon created by milad heidary

Project description

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 rubika 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 rubika import Client, methods

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

Example to get the list of methods of a group

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

from rubika 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 rubika 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)
    

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

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

rubithon-1.0.0.tar.gz (23.5 kB view details)

Uploaded Source

Built Distribution

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

rubithon-1.0.0-py3-none-any.whl (26.5 kB view details)

Uploaded Python 3

File details

Details for the file rubithon-1.0.0.tar.gz.

File metadata

  • Download URL: rubithon-1.0.0.tar.gz
  • Upload date:
  • Size: 23.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for rubithon-1.0.0.tar.gz
Algorithm Hash digest
SHA256 0ed584b4ad925083e7f5505be6bbe4bb9d6a619162490b9a131459811b7636f9
MD5 acbbfbf0166329eb4b363699ad929b67
BLAKE2b-256 278031fa69e8d76e2a4d2d385e291cc3c87c36faec43c9c826619823ea5a0c44

See more details on using hashes here.

File details

Details for the file rubithon-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: rubithon-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 26.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for rubithon-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d8b615868deea22a3df01b1e05139aacd324b2836c4ea36fb30f1bd5d3ef5bad
MD5 8e6036507b12529361f6e05cafe2ba38
BLAKE2b-256 f9dbd7b8bd5e9a9358438b99e1798150584eaa6b63cd477e70b39a1d8ccb3215

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