Skip to main content

The fastest library for writing Telegram messenger bots both synchronously and asynchronously ⚡

Project description

Fast Rub - فست روب

This is where FastRub combines speed, power, and efficiency, allowing you to write the best Rubika bots. 🔥 اینجاست که فست روب سرعت، قدرت و بهینه بودن رو با هم ترکیب کرده تا بهترین ربات های روبیکا رو بنویسی 🔥

Fast Rub - فست روب

  • 1 The fastest Rubika robots library for Python - سریع ترین کتابخانه ربات های روبیکا پایتون
  • 2 power - قدرت
  • 3 efficiency - بهینه بودن

install - نصب :

pip install --upgrade fastrub

نحوه نصب در صورت ملی بودن اینترنت از میرور رانفلر :

pip install -i https://mirror-pypi.runflare.com/simple fastrub

Documents - مستندات کامل

GitHub - گیت هاب

PyPI - پای پی آی

نکته در مورد قسمت یوزر بات کتابخانه : قسمت PyRubi این کتابخانه فورک کتابخانه پایروبی است

توضیحات کوتاه(توضیحات کامل در مستندات)

گرفتن آپدیت پیام ها - پولینگ

from fast_rub import Client
from fast_rub.type import Update
import asyncio

async def robot():
  bot = Client("name_session", run_start=False)

  await bot.start()

  @bot.on_message()
  async def getting(message:Update):
      await message.reply("__Hello__ *from* **FastRub** !")

  await bot.run()

asyncio.run(robot())

گرفتن کلیک های دکمه های اینلاین(شیشه ای)

from fast_rub import Client
from fast_rub.type import UpdateButton
import asyncio

async def robot():
  bot = Client("name_session", run_start=False)
  # در صورتی که میخواید از endpoint خودتون استفاده کنید » 
  # url_webhook_on_button = "https://..."
  # bot = Client("name_session", use_to_fastrub_webhook_on_button = url_webhook_on_button)

  await bot.start()

  @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}

====================""")

  await bot.run()

asyncio.run(robot())

سایر دستورات

ارسال KeyPad

from fast_rub import Client
from fast_rub.button import KeyPad
import asyncio

async def setting():
    bot = Client("test", run_start=False)

    await bot.start()

    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

async def setting():
    bot = Client("test", run_start=False)

    await bot.start()

    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_keypad=button.get())

asyncio.run(setting())

ارسال فایل

ارسال فایل

from fast_rub import Client
import asyncio

async def send_file():
    chat_id = "b..."
    file = "..."
    text = None

    bot = Client("test", run_start=False)

    await bot.start()

    await bot.send_file(chat_id,file,text=text)

asyncio.run(send_file())

ارسال بقیه رسانه ها

from fast_rub import Client
import asyncio

bot = Client("test")

async def send_medias():
    chat_id = "b..."
    image = "..."
    video = "..."
    voice = "..."
    text = None

    bot = Client("test", run_start=False)

    await bot.start()

    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():
    chat_id = "b..."
    id_sticker = "..."

    bot = Client("test", run_start=False)

    await bot.start()
    
    await bot.send_sticker(chat_id,id_sticker)

asyncio.run(send_sticker())

دانلود

دانلود فایل

from fast_rub import Client
import asyncio

async def download_file():
    id_file = "..."
    path_save = "test.bin"

    bot = Client("test", run_start=False)

    await bot.start()

    await bot.download_file(id_file,path_save)

asyncio.run(download_file())

کلاس های Update و UpdateButton

کلاس Update

پراپرتی ها

  • text - متن پیام
  • message_id - آیدی پیام
  • chat_id - چت آیدی
  • time - زمان ارسال پیام
  • sender_type - نوع ارسال کننده پیام
  • sender_id - ارسال کننده پیام
  • is_edited - وضعیت ویرایش شدن پیام
  • متود ها

    ریپلای پیام

    reply( text: Optional[str] = None, keypad_inline: Optional[list] = None, inline_keypad: 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", meta_data: Optional[list] = None, 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, show_progress: bool = True, 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, latitude: Optional[str] = None, longitude: Optional[str] = None, first_name: Optional[str] = None, last_name: Optional[str] = None, phone_number: Optional[str] = None, chat_id: Optional[str] = None, reply_to_message_id: Optional[str] = None )

    کلاس UpdateButton

    پراپرتی ها

  • button_id - آیدی دکمه کلیک شده
  • chat_id - چت آیدی
  • message_id - آیدی پیام
  • sender_id - ارسال کننده
  • text - متن دکمه
  • متود ها

    ارسال متن

    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")

    فیلتر های دکوراتور on_message و on_message_updates

    نحوه استفاده »

    from fast_rub import Client, filters
    from fast_rub.type import Update
    import asyncio
    
    async def robot():
        bot = Client("test", run_start=False)
    
        await bot.start()
    
        @bot.on_message(filters.text("تست"))
        async def test_filters(msg: Update):
            await msg.reply("__hello__ *from* **fast_rub**")
        
        await bot.run()
    
    asyncio.run(robot())
    

    فیلتر ها

    متن

    text(pattern: str)

    ارسال کننده

    sender_id(user_id: str)

    کاربر بودن

    is_user()

    گروه بودن

    is_group()

    کانال بودن

    is_channel()

    برقراری تمامی فیلتر ها

    and_filter(*filters)

    برقراری یکی از فیلتر ها

    or_filter(*filters)

    برقرار نبودن فیلتر

    not_filter(filter)

    ساخت فیلتر سفارشی

    from fast_rub import Client, filters
    from fast_rub.type import Update
    import asyncio
    
    # Sync
    class sticker_emoji_filter(filters.Filter):
        """فیلتر تشخیص ایموجی استیکر"""
        def __init__(self, sticker_emoji_character: str):
            self.sticker_emoji_character = sticker_emoji_character
        def __call__(self, update: Update) -> bool:
            return str(update.sticker_emoji_character) == self.sticker_emoji_character
    
    # Async
    import database as db # مثال
    class is_admin_filter(filters.AsyncFilter):
        """فیلتر ادمین بودن کاربر"""
        async def __acall__(self, update: Update) -> bool:
            return bool(
                await db.exists(
                    "admins",
                    {
                        "chat_id": update.chat_id
                    }
                )
            )
    
    async def robot():
        bot = Client("test", run_start=False)
    
        await bot.start()
    
        @bot.on_message(sticker_emoji_filter("😂"))
        async def test_filter1(msg: Update):
            await msg.reply("خخخ")
        
        @bot.on_message(is_admin_filter())
        async def test_filter2(msg: Update):
            await msg.reply("شما ادمین میباشید")
        
        await bot.run()
    
    asyncio.run(robot())
    

    Seyyed Mohamad Hosein Moosavi (01)

    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

    fast_tel-0.0.1.tar.gz (5.5 kB view details)

    Uploaded Source

    Built Distribution

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

    fast_tel-0.0.1-py3-none-any.whl (5.5 kB view details)

    Uploaded Python 3

    File details

    Details for the file fast_tel-0.0.1.tar.gz.

    File metadata

    • Download URL: fast_tel-0.0.1.tar.gz
    • Upload date:
    • Size: 5.5 kB
    • Tags: Source
    • Uploaded using Trusted Publishing? No
    • Uploaded via: twine/6.0.1 CPython/3.11.9

    File hashes

    Hashes for fast_tel-0.0.1.tar.gz
    Algorithm Hash digest
    SHA256 f993af7a2563b1981cc7a758b8976392715b6b274f5be0f06b23222efd6e61c1
    MD5 27674536e12613e64b0c360f412e1213
    BLAKE2b-256 cb7f2c4bb914a928354d5f80041ede14862945aa630934704e07af1628be405b

    See more details on using hashes here.

    File details

    Details for the file fast_tel-0.0.1-py3-none-any.whl.

    File metadata

    • Download URL: fast_tel-0.0.1-py3-none-any.whl
    • Upload date:
    • Size: 5.5 kB
    • Tags: Python 3
    • Uploaded using Trusted Publishing? No
    • Uploaded via: twine/6.0.1 CPython/3.11.9

    File hashes

    Hashes for fast_tel-0.0.1-py3-none-any.whl
    Algorithm Hash digest
    SHA256 b0a8dbf5c184c46b6af1594016683082a6f84761d739ffc51482c94bfefb2f87
    MD5 ba4c3986ef9936a404512edc8d1605b5
    BLAKE2b-256 edb1f5ddb9c476e2f8a796a8e7f0b0453e06ccae9f945da12d903289429583f9

    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