import type { ResolvedDingTalkAccount, WebhookResponse } from "./types.js"; /** * 获取钉钉 access_token */ export declare function getAccessToken(account: ResolvedDingTalkAccount): Promise; export interface SendMessageOptions { account: ResolvedDingTalkAccount; verbose?: boolean; } export interface SendMessageResult { messageId: string; chatId: string; } /** * 通过 sessionWebhook 回复消息(markdown 格式) */ export declare function replyViaWebhook(webhook: string, content: string, options?: { atUserIds?: string[]; isAtAll?: boolean; }): Promise; /** * 钉钉机器人消息类型(msgKey) * @see https://open.dingtalk.com/document/orgapp/types-of-messages-sent-by-enterprise-robots */ export type DingTalkMsgKey = "sampleText" | "sampleMarkdown" | "sampleImageMsg" | "sampleLink" | "sampleAudio" | "sampleVideo" | "sampleFile" | "sampleActionCard" | "sampleActionCard2" | "sampleActionCard3" | "sampleActionCard4" | "sampleActionCard5" | "sampleActionCard6"; /** * 判断目标是否为群聊 * 群聊目标格式:chat: * 单聊目标格式:user: 或直接 */ export declare function isGroupTarget(to: string): boolean; /** 从 to 中提取实际 ID(去除 chat: / user: 前缀) */ export declare function extractTargetId(to: string): string; /** * 发送文本消息(markdown 格式,自动路由群聊/单聊) */ export declare function sendTextMessage(to: string, content: string, options: SendMessageOptions): Promise; /** * 发送图片消息(自动路由群聊/单聊) * @param photoURL - 图片的公网可访问 URL */ export declare function sendImageMessage(to: string, photoURL: string, options: SendMessageOptions): Promise; /** * 发送语音消息(自动路由群聊/单聊) * @param mediaId - 语音文件的 mediaId(通过 uploadMedia 获取) * @param duration - 语音时长(毫秒),可选 */ export declare function sendAudioMessage(to: string, mediaId: string, options: SendMessageOptions & { duration?: string; }): Promise; /** * 发送视频消息(自动路由群聊/单聊) * @param duration - 视频时长(秒),可选 */ export declare function sendVideoMessage(to: string, videoMediaId: string, options: SendMessageOptions & { duration?: string; picMediaId?: string; width?: string; height?: string; }): Promise; /** * 发送文件消息(自动路由群聊/单聊) * @param mediaId - 文件的 mediaId(通过 uploadMedia 获取) * @param fileName - 文件名 * @param fileType - 文件扩展名(如 pdf、doc 等) */ export declare function sendFileMessage(to: string, mediaId: string, fileName: string, fileType: string, options: SendMessageOptions): Promise; /** * 发送链接消息(自动路由群聊/单聊) */ export declare function sendLinkMessage(to: string, options: SendMessageOptions & { title: string; text: string; messageUrl: string; picUrl?: string; }): Promise; export interface DingTalkProbeResult { ok: boolean; bot?: { name?: string; robotCode?: string; }; error?: string; } /** * 探测钉钉机器人状态 */ export declare function probeDingTalkBot(account: ResolvedDingTalkAccount, _timeoutMs?: number): Promise; /** * 获取钉钉文件下载链接 * @param downloadCode - 文件下载码 * @param account - 钉钉账户配置 * @returns 下载链接 */ export declare function getFileDownloadUrl(downloadCode: string, account: ResolvedDingTalkAccount): Promise; /** * 从 URL 下载文件 * @param url - 下载链接 * @returns 文件内容 Buffer */ export declare function downloadFromUrl(url: string): Promise; /** * 钉钉支持的媒体类型(media/upload 接口) * - image: 图片,最大 20MB,支持 jpg/gif/png/bmp * - voice: 语音,最大 2MB,支持 amr/mp3/wav * - video: 视频,最大 20MB,支持 mp4 * - file: 普通文件,最大 20MB,支持 doc/docx/xls/xlsx/ppt/pptx/zip/pdf/rar */ export type DingTalkMediaType = "image" | "voice" | "video" | "file"; export interface UploadMediaResult { mediaId: string; /** 图片类型返回公网可访问 URL,其他类型返回空字符串 */ url: string; /** 媒体类型 */ type: DingTalkMediaType; } /** * 根据 MIME 类型推断钉钉媒体类型 */ export declare function inferMediaType(mimeType: string): DingTalkMediaType; /** * 上传媒体文件到钉钉(使用旧版 oapi 接口) * @param fileBuffer - 文件 Buffer * @param fileName - 文件名 * @param account - 钉钉账户配置 * @param options - 上传选项 * @returns 包含 media_id 和公网可访问 URL 的对象 */ export declare function uploadMedia(fileBuffer: Buffer, fileName: string, account: ResolvedDingTalkAccount, options?: { /** 媒体类型,不传则根据 mimeType 自动推断 */ type?: DingTalkMediaType; /** MIME 类型,用于推断媒体类型和设置 Content-Type */ mimeType?: string; }): Promise; //# sourceMappingURL=client.d.ts.map