Skip to content

Commit

Permalink
feat(wxrobot): 增加tsdoc
Browse files Browse the repository at this point in the history
  • Loading branch information
novlan1 committed Apr 7, 2022
1 parent 5f667fa commit 476a61e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/wecom-robot/helper.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
const axios = require('axios')

/**
* 给机器人发消息的基本方法
*
* @param config - 包含webhookUrl, params
* @returns
*/
export function sendToRobot({ webhookUrl, params }): any {
return new Promise((resolve, reject) => {
if (!webhookUrl) {
Expand Down
15 changes: 15 additions & 0 deletions src/wecom-robot/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import { sendToRobot } from './helper'

/**
* 给机器人发送普通消息
* @param config - { webhookUrl, chatId, alias, content }
* @returns
*/
export function sendWxRobotMsg({ webhookUrl, chatId, alias, content }) {
return new Promise((resolve, reject) => {
sendToRobot({
Expand All @@ -22,6 +27,11 @@ export function sendWxRobotMsg({ webhookUrl, chatId, alias, content }) {
})
}

/**
* 给机器人发送Markdown消息
* @param config - { webhookUrl, chatId, content, attachments }
* @returns
*/
export function sendWxRobotMarkdown({
webhookUrl,
chatId,
Expand Down Expand Up @@ -50,6 +60,11 @@ export function sendWxRobotMarkdown({
})
}

/**
* 给机器人发送图片
* @param config - { webhookUrl, chatId, content, md5Val }
* @returns
*/
export async function sendWxRobotImg({ webhookUrl, chatId, content, md5Val }) {
return new Promise((resolve, reject) => {
sendToRobot({
Expand Down

0 comments on commit 476a61e

Please sign in to comment.