import type { DingTalkConfig, DingTalkInboundMessage } from './types.js'; type MessageHandler = (msg: DingTalkInboundMessage) => Promise; export declare class DingTalkClient { private dw; private messageHandler?; /** Cached robotCode from the most recent inbound (== clientId for * stream-mode internal apps, but we read it from messages so we're * tolerant of multi-bot setups in one app). */ private lastSeenRobotCode; constructor(config: DingTalkConfig); onMessage(handler: MessageHandler): void; start(): Promise; stop(): Promise; /** Send a plain-text message to a thread we previously received from * (encoded as `user:` for 1:1, `group:` for groups). * Uses OpenAPI under the bot's access token. */ sendMessage(threadId: string, text: string): Promise; /** Send a markdown-formatted message. DingTalk's `sampleMarkdown` only * takes `title` + `text`; we derive title from the first line so the * user sees something meaningful in the notification preview. */ sendMarkdown(threadId: string, text: string, title?: string): Promise; /** Download an inbound image / voice / file message's binary payload. * * DingTalk hands the bot a short-lived `downloadCode` in each media * inbound; we trade it (plus our robotCode) for a presigned downloadUrl * on alibaba CDN, then GET that URL and return the bytes. * * Returns null on any error (caller surfaces a "[download failed:...]" * marker instead of silently dropping the user's message). MAX cap is * enforced; oversize payloads throw before allocating the buffer. * * Reference: POST /v1.0/robot/messageFiles/download * { downloadCode, robotCode } * header: x-acs-dingtalk-access-token * response: { downloadUrl } (sometimes nested under .data) */ downloadMessageFile(downloadCode: string): Promise<{ buffer: Buffer; contentType: string; } | null>; /** Shared POST path. msgKey + msgParam (stringified inner object) is * DingTalk's "templated message" convention — covers text, markdown, * cards via the same endpoint. */ private sendTemplated; } export {}; //# sourceMappingURL=dingtalk-client.d.ts.map