Skip to content

دکوراتورها


@app.on_message(*filters)

دریافت تمام رویدادهای پیام (جدید، ویرایش، حذف، ری‌اکشن). این دکوراتور جامع‌ترین است و تمام انواع پیام را پوشش می‌دهد.

مثال:

Python
from maxrubika import Messenger

with Messenger("mySession") as app:
    @app.on_message()
    async def handler(event):
        print(f"پیام: {event.text}")

    app.run()

@app.on_new_message(*filters)

فقط پیام‌های جدید را دریافت می‌کند.

مثال:

Python
from maxrubika import Messenger

with Messenger("mySession") as app:
    @app.on_new_message()
    async def handler(event):
        print(f"پیام جدید: {event.text}")

    app.run()

@app.on_edit_message(*filters)

فقط پیام‌های ویرایش شده را دریافت می‌کند.

مثال:

Python
from maxrubika import Messenger

with Messenger("mySession") as app:
    @app.on_edit_message()
    async def handler(event):
        print(f"پیام ویرایش شد: {event.text}")

    app.run()

@app.on_delete_message(*filters)

فقط پیام‌های حذف شده را دریافت می‌کند.

مثال:

Python
from maxrubika import Messenger

with Messenger("mySession") as app:
    @app.on_delete_message()
    async def handler(event):
        print(f"پیام حذف شد: {event.message_id}")

    app.run()

@app.on_add_reaction(*filters)

فقط افزودن ری‌اکشن به پیام‌ها را دریافت می‌کند.

مثال:

Python
from maxrubika import Messenger

with Messenger("mySession") as app:
    @app.on_add_reaction()
    async def handler(event):
        print(f"ری‌اکشن اضافه شد: {event.reactions}")

    app.run()

@app.on_remove_reaction(*filters)

فقط حذف ری‌اکشن از پیام‌ها را دریافت می‌کند.

مثال:

Python
from maxrubika import Messenger

with Messenger("mySession") as app:
    @app.on_remove_reaction()
    async def handler(event):
        print(f"ری‌اکشن حذف شد")

    app.run()

@app.on_chat_updates(*filters)

دریافت به‌روزرسانی‌های چت (تغییرات در گروه‌ها، کانال‌ها و...).

مثال:

Python
from maxrubika import Messenger

with Messenger("mySession") as app:
    @app.on_chat_updates()
    async def handler(event):
        print(f"بروزرسانی چت")

    app.run()

@app.on_show_activities(*filters)

دریافت فعالیت‌های در حال انجام (تایپ کردن، آپلود، ضبط صدا).

مثال:

Python
from maxrubika import Messenger

with Messenger("mySession") as app:
    @app.on_show_activities()
    async def handler(event):
        print(f"فعالیت: {event.activity}")

    app.run()

@app.on_show_notifications(*filters)

دریافت اعلان‌های نمایش داده شده.

مثال:

Python
from maxrubika import Messenger

with Messenger("mySession") as app:
    @app.on_show_notifications()
    async def handler(event):
        print(f"اعلان جدید")

    app.run()

@app.on_remove_notifications()

دریافت حذف اعلان‌ها.

مثال:

Python
from maxrubika import Messenger

with Messenger("mySession") as app:
    @app.on_remove_notifications()
    async def handler(event):
        print(f"اعلان حذف شد")

    app.run()

@app.on_voice_chat_update(*filters)

دریافت به‌روزرسانی‌های ویس چت.

مثال:

Python
from maxrubika import Messenger

with Messenger("mySession") as app:
    @app.on_voice_chat_update()
    async def handler(event):
        print(f"بروزرسانی ویس چت")

    app.run()

@app.on_voice_chat_participant(*filters)

دریافت تغییرات شرکت‌کنندگان ویس چت.

مثال:

Python
from maxrubika import Messenger

with Messenger("mySession") as app:
    @app.on_voice_chat_participant()
    async def handler(event):
        print(f"تغییر شرکت‌کننده ویس چت")

    app.run()

@app.on_call_update(*filters)

دریافت به‌روزرسانی‌های تماس صوتی/تصویری.

مثال:

Python
from maxrubika import Messenger

with Messenger("mySession") as app:
    @app.on_call_update()
    async def handler(event):
        print(f"بروزرسانی تماس")

    app.run()

@app.on_call_signal(*filters)

دریافت سیگنال‌های تماس (داده‌های فنی ارتباط).

مثال:

Python
from maxrubika import Messenger

with Messenger("mySession") as app:
    @app.on_call_signal()
    async def handler(event):
        print(f"سیگنال تماس")

    app.run()

@app.on_scheduled_message(*filters)

دریافت به‌روزرسانی‌های پیام‌های زمان‌بندی شده.

مثال:

Python
from maxrubika import Messenger

with Messenger("mySession") as app:
    @app.on_scheduled_message()
    async def handler(event):
        print(f"پیام زمان‌بندی شده")

    app.run()

@app.on_draft_message(*filters)

دریافت به‌روزرسانی‌های پیش‌نویس پیام‌ها.

مثال:

Python
from maxrubika import Messenger

with Messenger("mySession") as app:
    @app.on_draft_message()
    async def handler(event):
        print(f"پیش‌نویس پیام")

    app.run()

@app.on_unconfirmed_session(*filters)

دریافت نشست‌های تأیید نشده (ضد ورود غیرمجاز).

مثال:

Python
from maxrubika import Messenger

with Messenger("mySession") as app:
    @app.on_unconfirmed_session()
    async def handler(event):
        print(f"نشست تأیید نشده")

    app.run()