The fastest library for writing Rubika messenger bots both synchronously and asynchronously ⚡
Project description
Fast Rub - فست روب
Fast Rub means the fastest library for Rubika bots. If you want your Rubika bot to be fast and the library syntax you want to work with, it is definitely the best library for Python, Fast Rub! فست روب یعنی سریع ترین کتابخانه برای ربات های روبیکا . اگر میخواهید ربات روبیکاتون سریع باشه و سینتکست کتابخانه ای که میخواید باهاش کار کنید قطعا برای پایتون بهترین کتابخانه فست روبه !
Fast Rub - فست روب
- 1 The fastest Rubika robots library for Python - سریع ترین کتابخانه ربات های روبیکا پایتون
- 2 simple syntax - سینتکست ساده
- 3 Small size of the library - حجم پایین نصبت به بقیه کتابخانه ها
install - نصب :
pip install --upgrade fastrub
قسمت PyRubi این کتابخانه فورک کتابخانه پایروبی است
دکوراتور ها
گرفتن آپدیت پیام ها - پولینگ
from fast_rub import Client
from fast_rub.type import Update
bot = Client("name_session")
@bot.on_message()
async def getting(message:Update):
await message.reply("__Hello__ *from* **FastRub** !")
bot.run()
گرفتن آپدیت پیام ها - وبهوک
from fast_rub import Client
from fast_rub.type import Update
bot = Client("name_session")
# در صورتی که میخواید از endpoint خودتون استفاده کنید »
# url_webhook_on_message = "https://..."
# bot = Client("name_session", use_to_fastrub_webhook_on_message = url_webhook_on_message)
@bot.on_message_updates()
async def getting(message:Update):
await message.reply("__Hello__ *from* **FastRub** !")
bot.run()
گرفتن کلیک های دکمه های اینلاین
from fast_rub import Client
from fast_rub.type import UpdateButton
bot = Client("name_session")
# در صورتی که میخواید از endpoint خودتون استفاده کنید »
# url_webhook_on_button = "https://..."
# bot = Client("name_session", use_to_fastrub_webhook_on_button = url_webhook_on_button)
@bot.on_button()
async def getting(message: UpdateButton):
print(f"""button id » {message.button_id}
text » {message.text}
chat id » {message.chat_id}
message id » {message.message_id}
sender_id » {message.sender_id}
====================""")
bot.run()
توقف گرفتن آپدیت ها
from fast_rub import Client
from fast_rub.type import Update
bot = Client("name_session")
@bot.on_message()
async def getting(message:Update):
if message.text == "/off":
await message.reply("**OK**")
bot.stop()
bot.run()
دستورات
نحوه تنظیم دستورات ربات
from fast_rub import Client
import asyncio
bot = Client("test")
async def setting():
await bot.add_commands("/start","َشروع")
await bot.add_commands("/help","راهنما")
await bot.set_commands()
asyncio.run(setting())
نحوه حذف دستورات ربات
from fast_rub import Client
import asyncio
bot = Client("test")
async def setting():
await bot.delete_commands()
asyncio.run(setting())
ارسال KeyPad
from fast_rub import Client
from fast_rub.button import KeyPad
import asyncio
bot = Client("test")
async def setting():
button = KeyPad()
button.append(
button.simple("button id 1", "text 1")
)
button.append(
button.simple("button id 2", "text 2"),
button.simple("button id 3", "text 3")
)
await bot.send_text("test KeyPad",keypad=button.get())
asyncio.run(setting())
ارسال KeyPad Inline
from fast_rub import Client
from fast_rub.button import KeyPad
import asyncio
bot = Client("test")
async def setting():
button = KeyPad()
button.append(
button.simple("button id 1", "text 1")
)
button.append(
button.simple("button id 2", "text 2"),
button.simple("button id 3", "text 3")
)
await bot.send_text("test KeyPad Inline",inline_keypad=button.get())
asyncio.run(setting())
ارسال فایل
ارسال فایل
from fast_rub import Client
import asyncio
bot = Client("test")
chat_id = "b..."
file = "..."
text = None
async def send_file():
await bot.send_file(chat_id,file,text=text)
asyncio.run(send_file())
ارسال بقیه رسانه ها
from fast_rub import Client
import asyncio
bot = Client("test")
chat_id = "b..."
image = "..."
video = "..."
voice = "..."
text = None
async def send_medias():
await bot.send_image(chat_id,image,text=text)
await bot.send_video(chat_id,video,text=text)
await bot.send_voice(chat_id,video,text=text)
asyncio.run(send_medias())
ارسال استیکر
from fast_rub import Client
import asyncio
bot = Client("test")
chat_id = "b..."
id_sticker = "..."
async def send_sticker():
await bot.send_sticker(chat_id,id_sticker)
asyncio.run(send_sticker())
دانلود
گرفتن لینک دانلود فایل
from fast_rub import Client
import asyncio
bot = Client("test")
id_file = "..."
async def get_download_file_url():
link_download = await bot.get_download_file_url(id_file)
print(f"the link download of file » {id_file} is » {link_download}")
asyncio.run(get_download_file_url())
دانلود فایل
from fast_rub import Client
import asyncio
bot = Client("test")
id_file = "..."
path_save = "test.bin"
async def download_file():
await bot.download_file(id_file,path_save)
asyncio.run(download_file())
تنظیم EndPoint
تنظیم EndPoint
from fast_rub import Client
import asyncio
bot = Client("test")
url_endpoint = "https://..."
type_endpoint = "ReceiveUpdate"
async def set_endpoint():
await bot.set_endpoint(url_endpoint,type_endpoint)
asyncio.run(set_endpoint())
سایر متود ها
حذف خودکار پیام بعد از x ثانیه
auto_delete(chat_id:str,message_id:str,time_sleep:float)
گرفتن اطلاعات ربات
get_me()
تنظیم پارس مود اصلی همه متن ها
set_main_parse_mode(parse_mode: Literal['Markdown', 'HTML', 'Unknown', None])
ارسال متن
send_text(text: str, chat_id: str, inline_keypad: Optional[list] = None, keypad: Optional[list] = None, disable_notification: Optional[bool] = False, reply_to_message_id: Optional[str] = None, auto_delete: Optional[int] = None, parse_mode: Literal["Markdown","HTML",None] = "Markdown")
ارسال نظرسنجی
send_poll(chat_id: str, question: str, options: list, type_poll: Literal["Regular", "Quiz"] = "Regular", is_anonymous: bool = True, correct_option_index: Optional[int] = None, allows_multiple_answers: bool = False, hint: Optional[str] = None, disable_notification: bool = False, reply_to_message_id: Optional[str] = None, auto_delete: Optional[int] = None)
ارسال موقعیت مکانی(لوکیشن)
send_location(chat_id: str, latitude: str, longitude: str, chat_keypad : Optional[str] = None, disable_notification: Optional[bool] = False, reply_to_message_id: Optional[str] = None, chat_keypad_type: Optional[str] = None, auto_delete: Optional[int] = None)
ارسال مخاطب
send_contact(chat_id: str, first_name: str, last_name: str, phone_number: str, chat_keypad : Optional[str] = None, chat_keypad_type: Optional[str] = None, inline_keypad: Optional[str] = None, reply_to_message_id: Optional[str] = None, disable_notificatio: Optional[bool] = False, auto_delete: Optional[int] = None)
ارسال انواع پیام
send_message(chat_id: str, text: Optional[str], inline_keypad: Optional[list] = None, keypad: Optional[list] = None, resize_keyboard: Optional[bool] = True, on_time_keyboard: Optional[bool] = False, disable_notification: bool = False, reply_to_message_id: Optional[str] = None, auto_delete: Optional[int] = None, parse_mode: Literal["Markdown","HTML",None] = "Markdown", # file file: Union[str , Path , bytes , None] = None, name_file: Optional[str] = None, type_file: Literal["File", "Image", "Voice", "Music", "Gif" , "Video"] = "File", file_id: Optional[str] = None, # poll question: Optional[str] = None, options: Optional[list] = None, type_poll: Literal["Regular", "Quiz"] = "Regular", is_anonymous: bool = True, correct_option_index: Optional[int] = None, allows_multiple_answers: bool = False, hint: Optional[str] = None, # location latitude: Optional[str] = None, longitude: Optional[str] = None, # contact first_name: Optional[str] = None, last_name: Optional[str] = None, phone_number: Optional[str] = None)
گرفتن اطلاعات چت
get_chat(chat_id: str)
گرفتن آپدیت ها(از بالا)
get_updates(limit : Optional[int] = None, offset_id : Optional[str] = None)
گرفتن پیام با آیدی پیام
get_message(chat_id: str,message_id: str,limit_search: int = 100)
گرفتن پیام های قبل یک پیام با آیدی پیام
get_messages(chat_id: str,message_id: str,limit_search: int = 100,get_befor: int = 10)
فوروارد پیام
forward_message(from_chat_id: str, message_id: str, to_chat_id: str, disable_notification : Optional[bool] = False, auto_delete: Optional[int] = None)
فوروارد چند پیام
forward_messages(from_chat_id: str, message_ids: list, to_chat_id: str, disable_notification : Optional[bool] = False, auto_delete: Optional[int] = None)
ویرایش متن پیام
edit_message_text(chat_id: str, message_id: str, text: str, inline_keypad: Optional[list] = None, parse_mode: Literal["Markdown","HTML",None] = "Markdown")
حذف پیام
delete_message(chat_id: str, message_id: str)
آپلود فایل در سرور روبیکا
upload_file(url: str, file_name: str, file: Union[str , Path , bytes])
ارسال فایل با آیدی
send_file_by_file_id(chat_id: str, file_id: str, text: Optional[str] = None, reply_to_message_id: Optional[str] = None, disable_notification: Optional[bool] = None, auto_delete: Optional[int] = None, parse_mode: Literal["Markdown","HTML",None] = "Markdown")
کلاس های Update و UpdateButton
کلاس Update
پراپرتی ها
فایل
کی پد
متا دیتا
فوروارد
مخاطب
استیکر
متود ها
گرفتن اطلاعات چت آیدی
get_chat_id_info()
ریپلای متن
reply(text: str,keypad_inline: Optional[list] = None, keypad: Optional[list] = None, resize_keyboard: bool | None = True, on_time_keyboard: bool | None = False,,auto_delete: Optional[int] = None,parse_mode: Literal['Markdown', 'HTML', None] = "Markdown")
ریپلای نظرسنجی
reply_poll( question: str, options: list, type_poll: Literal["Regular", "Quiz"] = "Regular", is_anonymous: bool = True, correct_option_index: Optional[int] = None, allows_multiple_answers: bool = False, hint: Optional[str] = None, auto_delete: Optional[int] = None )
ریپلای مخاطب
reply_contact(first_name: str, phone_number: str, last_name: Union[str,str] = "",auto_delete: Optional[int] = None)
ریپلای موقعیت مکانی(لوکیشن)
reply_location(latitude: str, longitude: str,auto_delete: Optional[int] = None)
ریپلای فایل
reply_file( file: Union[str , Path , bytes], name_file: Optional[str] = None, text: Optional[str] = None, type_file: Literal["File", "Image", "Voice", "Music", "Gif","Video"] = "File", disable_notification: Optional[bool] = False, auto_delete: Optional[int] = None, parse_mode: Literal['Markdown', 'HTML', None] = "Markdown" ) # فایل
reply_image( image: Union[str , Path , bytes], name_file: Optional[str] = None, text: Optional[str] = None, disable_notification: Optional[bool] = False, auto_delete: Optional[int] = None, parse_mode: Literal['Markdown', 'HTML', None] = "Markdown" ) # تصویر
reply_voice(...) # ویس
reply_music(...) # موزیک
reply_gif(...) # گیف
reply_video(...) # ویدیو
فوروارد پیام
forward(to_chat_id:str,auto_delete: Optional[int] = None)
دانلود پیام
download(path : Union[str,str] = "file")
حذف پیام
delete()
کلاس UpdateButton
پراپرتی ها
متود ها
ارسال متن
send_text(text:str,keypad:dict:Optional[list] = None,keypad: Optional[list] = None, resize_keyboard: Optional[bool] = True, on_time_keyboard: Optional[bool] = False,auto_delete: Optional[int] = None,reply_to_message_id: Optional[str] = None,parse_mode: Literal['Markdown', 'HTML'] = "Markdown")
ارسال نظرسنجی
send_pool( question: str, options : list, type_poll: Literal['Regular', 'Quiz'] = "Regular", is_anonymous: bool = True, correct_option_index: int | None = None, allows_multiple_answers: bool = False, hint: str | None = None, auto_delete: Optional[int] = None )
ارسال مخاطب
send_contact(first_name: str, last_name: str, phone_number: str, auto_delete: Optional[int] = None, reply_to_message_id: Optional[str] = None)
ارسال موقعیت مکانی(لوکیشن)
send_location(latitude: str, longitude: str, auto_delete: Optional[int] = None, reply_to_message_id: Optional[str] = None)
ارسال فایل
send_file(file: Union[str , Path , bytes], name_file: Optional[str] = None, text: Optional[str] = None, type_file: Literal['File', 'Image', 'Voice', 'Music', 'Gif', 'Video'] = "File", auto_delete: Optional[int] = None, reply_to_message_id: Optional[str] = None) # فایل
send_image(image: Union[str , Path , bytes], name_file: Optional[str] = None, text: Optional[str] = None, auto_delete: Optional[int] = None, reply_to_message_id: Optional[str] = None) # تصویر
send_video(...) # ویدیو
send_voice(...) # ویدیو
send_music(...) # موزیک
send_gif(...) # گیف
فیلتر های دکوراتور on_message و on_message_updates
نحوه استفاده »
from fast_rub import Client,filters
from fast_rub.type import Update
bot = Client("test")
@bot.on_message(filters.text("تست"))
async def test_filters(msg:Update):
await msg.reply("__hello__ *from* **fast_rub**")
bot.run()
فیلتر ها
متن
text(pattern: str)
ارسال کننده
sender_id(user_id: str)
کاربر بودن
is_user()
گروه بودن
is_group()
کانال بودن
is_channel()
فایل بودن
is_file()
اسم فایل
file_name(name_file: str)
اندازه فایل
size_file(size: int)
ویدیو بودن
is_video()
عکس بودن
is_image()
آودیو بودن
is_audio()
ویس بودن
is_voice()
داکیومنت بودن
is_document()
فایل وب بودن
is_web()
فایل کد بودن
is_code()
آرشیو بودن
is_archive()
فایل نصبی بودن
is_executable()
متن بودن
is_text()
الگو ریجکس
regex(pattern: str, flags=0)
زمان
time(from_time:float=0,end_time=float("inf"))
دستورات
commands(coms: list)
سند آیدی ها
author_guids(guids: list)
چت آیدی ها
chat_ids(ids: list)
داشتن متا دیتا
is_metadata_type()
داشتن بولد
has_bold()
داشتن ایتالیک
has_italic()
داشتن آندرلاین
has_underline()
داشتن متن خط خورده
has_strike()
داشتن متن کپی
has_mono()
داشتن متن اسپویل شده
has_spoiler()
داشتن متن هایپر لینک
has_link()
بودن متن بولد شده
is_bold()
بودن متن ایتالیک
is_italic()
بودن متن زیر خط
is_underline()
بودن متن خط خورده
is_strike()
بودن متن کپی
is_mono()
بودن متن اسپویل شده
is_spoiler()
بودن متن هایپر لینک
is_link()
بودن در متن
in_text(text: str)
فورواردن بودن
is_forward()
ریپلای بودن
is_reply()
طول متن
text_length(min_len: int = 0, max_len: float = float('inf'))
شروع با
starts_with(prefix: str)
یایان با
ends_with(suffix: str)
استیکر بودن
is_sticker()
مخاطب بودن
is_contact()
برقراری تمامی فیلتر ها
and_filter(*filters)
برقراری یکی از فیلتر ها
or_filter(*filters)
برقرار نبودن فیلتر
not_filter(filter)
Seyyed Mohamad Hosein Moosavi (01)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fastrub-2.5.9.tar.gz.
File metadata
- Download URL: fastrub-2.5.9.tar.gz
- Upload date:
- Size: 75.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ceb4962ec1d68aca23b9c1af8f9402e3f46985fa5274e65e54a5288ece4f8c37
|
|
| MD5 |
3b545b3e1b0f2be382a7189126717945
|
|
| BLAKE2b-256 |
82517a91e4c8674974c561fe4d0452e21ca7aefe8f530b3b224002bd06b362f2
|
File details
Details for the file fastrub-2.5.9-py3-none-any.whl.
File metadata
- Download URL: fastrub-2.5.9-py3-none-any.whl
- Upload date:
- Size: 80.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9eeb2bdb95226ca5a1c8150560de9a3bc0f8c96d967df1eb191e2014b5ed6682
|
|
| MD5 |
714def8e5a9d2a005573a42282ade1bf
|
|
| BLAKE2b-256 |
5f6464c881844e84f79ecf122930ea388df7ae350e843108d45e82996d745b4b
|