Rubika
rubika client for python 3
Install / Use
/learn @mivmi/RubikaREADME
Rubika Client for python 3
<div align="center">
![]()
install
pip install https://github.com/IRMilad/rubika/archive/refs/heads/main.zip
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)
✌ در آرزوی جهانی ...
Related Skills
node-connect
347.6kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
108.4kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
347.6kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
347.6kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
