t-comm
Version:
专业、稳定、纯粹的工具库
129 lines (128 loc) • 4 kB
TypeScript
interface ISendReq {
chatId: string | Array<string>;
webhookUrl: string;
}
/**
* 批量发送企业微信机器人base64图片
* - chatId 支持字符串或字符串数组,传 `'ALL'` 或 `['ALL']` 会发送给所有人
* @param {object} config 配置信息
* @param {string} config.img base64图片
* @param {string | Array<string>} config.chatId 会话Id,支持单个字符串、字符串数组、`'ALL'` 或 `['ALL']`(发送给所有人)
* @param {string} config.webhookUrl webhook地址
* @returns {Promise<object>} 请求Promise
* @example
*
* // 发送给单个会话
* batchSendWxRobotBase64Img({
* img: 'xxx',
* chatId: 'xxx',
* webhookUrl: 'xxx',
* });
*
* // 发送给多个会话
* batchSendWxRobotBase64Img({
* img: 'xxx',
* chatId: ['chatId1', 'chatId2'],
* webhookUrl: 'xxx',
* });
*
* // 发送给所有人
* batchSendWxRobotBase64Img({
* img: 'xxx',
* chatId: 'ALL', // 或 ['ALL']
* webhookUrl: 'xxx',
* });
*
*/
export declare function batchSendWxRobotBase64Img({ img, chatId, webhookUrl, }: {
img: string;
} & ISendReq): Promise<any>;
/**
* 批量发送企业微信机器人文本消息
* - chatId 支持字符串或字符串数组,传 `'ALL'` 或 `['ALL']` 会发送给所有人
* @param {object} config 配置信息
* @param {string} config.content 消息内容
* @param {string | Array<string>} config.alias 被@的用户别名,支持单个字符串或字符串数组
* @param {string | Array<string>} config.chatId 会话Id,支持单个字符串、字符串数组、`'ALL'` 或 `['ALL']`(发送给所有人)
* @param {string} config.webhookUrl webhook地址
* @returns {Promise<object>} 请求Promise
* @example
*
* // 发送给单个会话
* batchSendWxRobotMsg({
* content: '消息内容',
* alias: 'user1',
* chatId: 'xxx',
* webhookUrl: 'xxx',
* });
*
* // 发送给多个会话并@多个用户
* batchSendWxRobotMsg({
* content: '消息内容',
* alias: ['user1', 'user2'],
* chatId: ['chatId1', 'chatId2'],
* webhookUrl: 'xxx',
* });
*
* // 发送给所有人
* batchSendWxRobotMsg({
* content: '消息内容',
* alias: 'user1',
* chatId: 'ALL', // 或 ['ALL']
* webhookUrl: 'xxx',
* });
*
*/
export declare function batchSendWxRobotMsg({ content, alias, chatId, webhookUrl, }: {
content: string;
alias: string | Array<string>;
} & ISendReq): Promise<any>;
/**
* 批量发送企业微信机器人Markdown消息(最常用)
* - chatId 支持字符串或字符串数组,传 `'ALL'` 或 `['ALL']` 会发送给所有人
* - 支持 Markdown V2 格式,通过 isV2 参数控制
* @param {object} config 配置信息
* @param {string} config.content Markdown消息内容
* @param {Array<object>} [config.attachments] 附加内容
* @param {string | Array<string>} config.chatId 会话Id,支持单个字符串、字符串数组、`'ALL'` 或 `['ALL']`(发送给所有人)
* @param {string} config.webhookUrl webhook地址
* @param {boolean} [config.isV2=false] 是否使用 Markdown V2 格式
* @returns {Promise<object>} 请求Promise
* @example
*
* // 发送给单个会话
* batchSendWxRobotMarkdown({
* content: '## 标题\n内容',
* chatId: 'xxx',
* webhookUrl: 'xxx',
* });
*
* // 发送给多个会话
* batchSendWxRobotMarkdown({
* content: '## 标题\n内容',
* chatId: ['chatId1', 'chatId2'],
* webhookUrl: 'xxx',
* });
*
* // 发送给所有人
* batchSendWxRobotMarkdown({
* content: '## 标题\n内容',
* chatId: 'ALL', // 或 ['ALL']
* webhookUrl: 'xxx',
* });
*
* // 使用 Markdown V2 格式
* batchSendWxRobotMarkdown({
* content: '## 标题\n内容',
* chatId: 'xxx',
* webhookUrl: 'xxx',
* isV2: true,
* });
*
*/
export declare function batchSendWxRobotMarkdown({ content, attachments, chatId, webhookUrl, isV2, }: {
content: string;
attachments?: Array<object>;
isV2?: boolean;
} & ISendReq): Promise<any>;
export {};