mirror of
https://github.com/hansjone/dsh-im-ops.git
synced 2026-10-12 21:40:50 +08:00
dingtalk add @person function
This commit is contained in:
parent
d251bc280d
commit
7d5bc94f64
2 changed files with 33 additions and 20 deletions
|
|
@ -1008,13 +1008,18 @@ export function createDingtalkApi({
|
|||
|
||||
failAiCard: failCard,
|
||||
|
||||
async sendText({ clientId, clientSecret, sessionWebhook, text, signal }) {
|
||||
async sendText({ clientId, clientSecret, sessionWebhook, text, at, signal }) {
|
||||
const content = nonEmptyString(text);
|
||||
if (!content) throw new TypeError('text is required');
|
||||
const webhook = normalizeDingtalkSessionWebhook(sessionWebhook);
|
||||
const token = await accessToken({ clientId, clientSecret, signal });
|
||||
const replyAt = at && typeof at === 'object'
|
||||
&& ((Array.isArray(at.atUserIds) && at.atUserIds.length > 0)
|
||||
|| (Array.isArray(at.atMobiles) && at.atMobiles.length > 0)
|
||||
|| at.isAtAll === true)
|
||||
? { at } : {};
|
||||
const response = await requestJson(fetchImpl, webhook, {
|
||||
body: { msgtype: 'text', text: { content } },
|
||||
body: { msgtype: 'text', text: { content }, ...replyAt },
|
||||
headers: { 'x-acs-dingtalk-access-token': token },
|
||||
signal,
|
||||
action: '消息回复',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue