English فارسی

تایپ‌ها و مدل‌ها

پوشش‌های نازک و خوانا روی dictهای رمزگشایی‌شده پروتکل. هر کدام بار خام را در .raw نگه می‌دارد، پس هیچ چیزی از دست نمی‌رود.

Message

۵۷ عضو عمومی. آن‌هایی که واقعاً استفاده می‌کنید:

عضوبرمی‌گرداند
id / message_idشناسه پیام
textمتن ساده یا ""
contentبدنه ساخت‌یافته به شکل dict
chat / chat_idگفتگو
from_user / sender / sender_idنویسنده
is_outgoing / is_incomingجهت
is_reply / reply_to_messageنقل‌قول
photo, document, video, voice, audio, sticker, location, contact, pollدسترسی‌دهنده‌های تایپ‌دار رسانه یا None
mediaهر رسانه‌ای که پیام همراه دارد
buttonsردیف‌های کیبورد درون‌خطی
command / command_args"/start", "foo bar"
matchesگروه‌های regex وقتی فیلتر الگو تطبیق داده باشد
reply_to_message_idint
print(message.text)
print(message.is_outgoing)
print(message.command, message.command_args)
print(message.photo.width if message.photo else None)

اکشن‌ها

متدکار
answer(text) / reply(text)پاسخ در همان گفتگو
reply_photo, reply_document, reply_voice, reply_video, reply_audio, reply_stickerپاسخ با رسانه
edit_text(text)ویرایش در جای خود
delete()حذف برای همه
forward(to_peer) / copy(to_peer)هدایت با یا بدون سرصفحه ارجاع
react(emoji) / remove_reaction()واکنش‌ها
pin() / unpin() / unpin_all()سنجاق کردن
seen()علامت‌گذاری به عنوان خوانده‌شده
download(path=None)ذخیره فایل پیوست
click(button)فعال‌سازی یک دکمه درون‌خطی
load_history, clear_chat, delete_chatعملیات سطح گفتگو
report(reason) / get_fsm_context()گزارش دادن، دسترسی به FSM

User

user.full_name
user.first_name / user.last_name
user.phone
user.mention()          # "@username" یا یک نام نمایشی
user.is_self
await user.send_message("hi")
await user.block()
await user.unblock()

Chat

chat.id                  # رشته کامل peer
chat.title / chat.full_name
chat.is_private / is_group / is_channel
chat.mention()
await chat.send("hi")
await chat.send_photo(...)
await chat.send_action("typing")
await chat.load_history(limit=50)
await chat.leave()

Dialog و DialogsList

dialogs = await client.get_dialogs()
item = dialogs.find_by_id("987654321|2")
item = dialogs.find_by_username("bale_team")
print(item.title)

Media

if message.photo:
    print(message.photo.width, message.photo.height)
    await message.photo.download("/tmp/out.jpg")

Peer

from balexyz import Peer

peer = Peer.parse("987654321|2")
peer.kind          # "group"
peer.is_group      # True
peer.to_dict()     # {"id": 987654321, "type": 2}

کیبوردها

from balexyz.keyboards import InlineKeyboardMarkup, InlineKeyboardButton

keyboard = InlineKeyboardMarkup()
keyboard.add(InlineKeyboardButton("تأیید", callback_data="ok"))
keyboard.add(InlineKeyboardButton("مستندات", url="https://example.com"))
keyboard.row(
    InlineKeyboardButton("1", callback_data="1"),
    InlineKeyboardButton("2", callback_data="2"),
)

doc = keyboard.to_dict()

سریال‌سازی

همه مدل‌ها از Serializable ارث می‌برند:

message.to_dict()
message.as_dict()      # معادل
message.to_json()
message.as_json()
bale xyz 1.0.0 · MIT licensed · unofficial client © 2026 bale xyz contributors