grammY انضمام (Telegram Bot API)¶
grammY کیوں¶
- TS-first Bot API کلائنٹ جس میں بلٹ اِن long-poll + webhook ہیلپرز، middleware، error handling، اور rate limiter شامل ہیں۔
- fetch + FormData کو دستی طور پر بنانے کے مقابلے میں زیادہ صاف میڈیا ہیلپرز؛ Bot API کے تمام طریقوں کی سپورٹ۔
- قابلِ توسیع: custom fetch کے ذریعے proxy سپورٹ، session middleware (اختیاری)، type-safe context۔
ہم نے کیا بھیجا¶
- واحد کلائنٹ راستہ: fetch پر مبنی نفاذ ہٹا دیا گیا؛ grammY اب واحد Telegram کلائنٹ ہے (send + gateway) اور grammY throttler بطورِ طے شدہ فعال ہے۔
- Gateway:
monitorTelegramProviderbuilds a grammYBot, wires mention/allowlist gating, media download viagetFile/download, and delivers replies withsendMessage/sendPhoto/sendVideo/sendAudio/sendDocument. Supports long-poll or webhook viawebhookCallback. - Proxy: اختیاری
channels.telegram.proxygrammY کےclient.baseFetchکے ذریعےundici.ProxyAgentاستعمال کرتا ہے۔ - Webhook support:
webhook-set.tswrapssetWebhook/deleteWebhook;webhook.tshosts the callback with health + graceful shutdown. Gateway enables webhook mode whenchannels.telegram.webhookUrl+channels.telegram.webhookSecretare set (otherwise it long-polls). - Sessions: براہِ راست چیٹس ایجنٹ کے مرکزی سیشن (
agent:<agentId>:<mainKey>) میں ضم ہو جاتی ہیں؛ گروپسagent:<agentId>:telegram:group:<chatId>استعمال کرتے ہیں؛ جوابات اسی چینل پر واپس جاتے ہیں۔ - Config knobs:
channels.telegram.botToken,channels.telegram.dmPolicy,channels.telegram.groups(allowlist + mention ڈیفالٹس),channels.telegram.allowFrom,channels.telegram.groupAllowFrom,channels.telegram.groupPolicy,channels.telegram.mediaMaxMb,channels.telegram.linkPreview,channels.telegram.proxy,channels.telegram.webhookSecret,channels.telegram.webhookUrl۔ - Draft streaming: optional
channels.telegram.streamModeusessendMessageDraftin private topic chats (Bot API 9.3+). This is separate from channel block streaming. - Tests: grammY mocks DM + گروپ mention gating اور outbound send کو کور کرتے ہیں؛ مزید میڈیا/webhook fixtures خوش آئند ہیں۔
کھلے سوالات
- اگر Bot API 429s آئیں تو اختیاری grammY plugins (throttler)۔
- مزید ساختہ میڈیا ٹیسٹس شامل کرنا (اسٹیکرز، وائس نوٹس)۔
- webhook کے listen پورٹ کو قابلِ کنفیگریشن بنانا (فی الحال 8787 پر فکس ہے جب تک gateway کے ذریعے وائر نہ کیا جائے)۔