@secret-momo/notifier 1.0.9 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.js +2 -1
- package/lib/lark/helper.d.ts +2 -0
- package/lib/lark/helper.d.ts.map +1 -1
- package/lib/lark/helper.js +45 -1
- package/lib/lark/index.d.ts +41 -6
- package/lib/lark/index.d.ts.map +1 -1
- package/lib/lark/index.js +12 -64
- package/lib/lark/webhook.d.ts +5 -0
- package/lib/lark/webhook.d.ts.map +1 -0
- package/lib/lark/webhook.js +23 -0
- package/package.json +7 -7
package/lib/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
export { replyCardMessage, replyTextMessage, sendCardMessage, sendErrorCardMessage, sendPostMessage, sendTextMessage, startWsClient, updateCardMessage, uploadImage
|
|
1
|
+
export { replyCardMessage, replyTextMessage, sendCardMessage, sendErrorCardMessage, sendPostMessage, sendTextMessage, startWsClient, updateCardMessage, uploadImage } from './lark/index.js';
|
|
2
2
|
export { e, sendMessage } from './telegram/index.js';
|
|
3
3
|
export { getTextMessageContent } from './lark/helper.js';
|
|
4
|
+
export { webhookSendCardMessage, webhookSendErrorCardMessage, webhookSendTextMessage } from './lark/webhook.js';
|
package/lib/lark/helper.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { InteractiveCard } from './types/card.type';
|
|
1
2
|
import type { LarkIMMessageReceiveV1Event } from './types/receive.type';
|
|
2
3
|
export declare function getTextMessageContent(e: LarkIMMessageReceiveV1Event): string;
|
|
4
|
+
export declare function buildErrorCard(message: string): InteractiveCard;
|
|
3
5
|
//# sourceMappingURL=helper.d.ts.map
|
package/lib/lark/helper.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helper.d.ts","sourceRoot":"","sources":["../../src/lark/helper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAC;AAExE,wBAAgB,qBAAqB,CAAC,CAAC,EAAE,2BAA2B,GAAG,MAAM,CAM5E"}
|
|
1
|
+
{"version":3,"file":"helper.d.ts","sourceRoot":"","sources":["../../src/lark/helper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAC;AAExE,wBAAgB,qBAAqB,CAAC,CAAC,EAAE,2BAA2B,GAAG,MAAM,CAM5E;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,mBA6C7C"}
|
package/lib/lark/helper.js
CHANGED
|
@@ -4,5 +4,49 @@ function getTextMessageContent(e) {
|
|
|
4
4
|
}
|
|
5
5
|
return "";
|
|
6
6
|
}
|
|
7
|
+
function buildErrorCard(message) {
|
|
8
|
+
const card = {
|
|
9
|
+
schema: "2.0",
|
|
10
|
+
config: { update_multi: true },
|
|
11
|
+
header: {
|
|
12
|
+
template: "red",
|
|
13
|
+
padding: "8px 8px 8px 8px",
|
|
14
|
+
icon: { tag: "standard_icon", token: "buzz_outlined" },
|
|
15
|
+
title: { content: "\u9519\u8BEF\u63D0\u793A", tag: "plain_text" }
|
|
16
|
+
},
|
|
17
|
+
body: {
|
|
18
|
+
direction: "vertical",
|
|
19
|
+
elements: [
|
|
20
|
+
{
|
|
21
|
+
tag: "markdown",
|
|
22
|
+
content: `<font color="red">${message}</font>`,
|
|
23
|
+
text_size: "normal_v2",
|
|
24
|
+
text_align: "left",
|
|
25
|
+
margin: "0px 0px 0px 0px"
|
|
26
|
+
}
|
|
27
|
+
]
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
if (process.env.RUN_URL) {
|
|
31
|
+
card.body.elements.push({
|
|
32
|
+
tag: "button",
|
|
33
|
+
type: "danger_filled",
|
|
34
|
+
width: "default",
|
|
35
|
+
size: "tiny",
|
|
36
|
+
margin: "0px 0px 0px 0px",
|
|
37
|
+
behaviors: [
|
|
38
|
+
{
|
|
39
|
+
type: "open_url",
|
|
40
|
+
default_url: process.env.RUN_URL
|
|
41
|
+
}
|
|
42
|
+
],
|
|
43
|
+
text: {
|
|
44
|
+
tag: "plain_text",
|
|
45
|
+
content: "\u67E5\u770B\u8BE6\u60C5"
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
return card;
|
|
50
|
+
}
|
|
7
51
|
|
|
8
|
-
export { getTextMessageContent };
|
|
52
|
+
export { buildErrorCard, getTextMessageContent };
|
package/lib/lark/index.d.ts
CHANGED
|
@@ -2,12 +2,13 @@ import type { Post } from './types/post.type';
|
|
|
2
2
|
import type { InteractiveCard, InteractiveCardHeader, InteractiveCardBody, InteractiveCardElement, InteractiveCardMarkdownElement, InteractiveCardButtonElement } from './types/card.type';
|
|
3
3
|
import type { LarkIMMessageReceiveV1Event } from './types/receive.type';
|
|
4
4
|
export { getTextMessageContent } from './helper';
|
|
5
|
+
export { webhookSendTextMessage, webhookSendCardMessage, webhookSendErrorCardMessage, } from './webhook';
|
|
5
6
|
export type { Post, InteractiveCard, InteractiveCardHeader, InteractiveCardBody, InteractiveCardElement, InteractiveCardMarkdownElement, InteractiveCardButtonElement, LarkIMMessageReceiveV1Event, };
|
|
6
7
|
/**
|
|
7
8
|
* 发送普通文本消息,文档地址:
|
|
8
9
|
* https://open.feishu.cn/document/server-docs/im-v1/message-content-description/create_json#c9e08671
|
|
9
10
|
*/
|
|
10
|
-
export declare function sendTextMessage(message: string): Promise<{
|
|
11
|
+
export declare function sendTextMessage(message: string, chatId?: string): Promise<{
|
|
11
12
|
code?: number | undefined;
|
|
12
13
|
msg?: string | undefined;
|
|
13
14
|
data?: {
|
|
@@ -27,6 +28,12 @@ export declare function sendTextMessage(message: string): Promise<{
|
|
|
27
28
|
sender_type: string;
|
|
28
29
|
tenant_key?: string | undefined;
|
|
29
30
|
sender_name?: string | undefined;
|
|
31
|
+
open_bot_id?: string | undefined;
|
|
32
|
+
sender_i18n_names?: {
|
|
33
|
+
zh_cn?: string | undefined;
|
|
34
|
+
en_us?: string | undefined;
|
|
35
|
+
ja_jp?: string | undefined;
|
|
36
|
+
} | undefined;
|
|
30
37
|
} | undefined;
|
|
31
38
|
body?: {
|
|
32
39
|
content: string;
|
|
@@ -44,13 +51,11 @@ export declare function sendTextMessage(message: string): Promise<{
|
|
|
44
51
|
thread_message_position?: string | undefined;
|
|
45
52
|
} | undefined;
|
|
46
53
|
}>;
|
|
47
|
-
export declare function webhookSendTextMessage(text: string): Promise<unknown>;
|
|
48
|
-
export declare function webhookSendCardMessage(card: InteractiveCard): Promise<unknown>;
|
|
49
54
|
/**
|
|
50
55
|
* 发送富文本消息,文档地址:
|
|
51
56
|
* https://open.feishu.cn/document/server-docs/im-v1/message-content-description/create_json#45e0953e
|
|
52
57
|
*/
|
|
53
|
-
export declare function sendPostMessage(post: Post): Promise<{
|
|
58
|
+
export declare function sendPostMessage(post: Post, chatId?: string): Promise<{
|
|
54
59
|
code?: number | undefined;
|
|
55
60
|
msg?: string | undefined;
|
|
56
61
|
data?: {
|
|
@@ -70,6 +75,12 @@ export declare function sendPostMessage(post: Post): Promise<{
|
|
|
70
75
|
sender_type: string;
|
|
71
76
|
tenant_key?: string | undefined;
|
|
72
77
|
sender_name?: string | undefined;
|
|
78
|
+
open_bot_id?: string | undefined;
|
|
79
|
+
sender_i18n_names?: {
|
|
80
|
+
zh_cn?: string | undefined;
|
|
81
|
+
en_us?: string | undefined;
|
|
82
|
+
ja_jp?: string | undefined;
|
|
83
|
+
} | undefined;
|
|
73
84
|
} | undefined;
|
|
74
85
|
body?: {
|
|
75
86
|
content: string;
|
|
@@ -91,7 +102,7 @@ export declare function sendPostMessage(post: Post): Promise<{
|
|
|
91
102
|
* 发送卡片消息,文档地址:
|
|
92
103
|
* https://open.feishu.cn/document/server-docs/im-v1/message-content-description/create_json#3ea4c2d5
|
|
93
104
|
*/
|
|
94
|
-
export declare function sendCardMessage(card: InteractiveCard): Promise<{
|
|
105
|
+
export declare function sendCardMessage(card: InteractiveCard, chatId?: string): Promise<{
|
|
95
106
|
code?: number | undefined;
|
|
96
107
|
msg?: string | undefined;
|
|
97
108
|
data?: {
|
|
@@ -111,6 +122,12 @@ export declare function sendCardMessage(card: InteractiveCard): Promise<{
|
|
|
111
122
|
sender_type: string;
|
|
112
123
|
tenant_key?: string | undefined;
|
|
113
124
|
sender_name?: string | undefined;
|
|
125
|
+
open_bot_id?: string | undefined;
|
|
126
|
+
sender_i18n_names?: {
|
|
127
|
+
zh_cn?: string | undefined;
|
|
128
|
+
en_us?: string | undefined;
|
|
129
|
+
ja_jp?: string | undefined;
|
|
130
|
+
} | undefined;
|
|
114
131
|
} | undefined;
|
|
115
132
|
body?: {
|
|
116
133
|
content: string;
|
|
@@ -131,7 +148,7 @@ export declare function sendCardMessage(card: InteractiveCard): Promise<{
|
|
|
131
148
|
/**
|
|
132
149
|
* 发送通用的错误卡片消息
|
|
133
150
|
*/
|
|
134
|
-
export declare function sendErrorCardMessage(message: string): Promise<{
|
|
151
|
+
export declare function sendErrorCardMessage(message: string, chatId?: string): Promise<{
|
|
135
152
|
code?: number | undefined;
|
|
136
153
|
msg?: string | undefined;
|
|
137
154
|
data?: {
|
|
@@ -151,6 +168,12 @@ export declare function sendErrorCardMessage(message: string): Promise<{
|
|
|
151
168
|
sender_type: string;
|
|
152
169
|
tenant_key?: string | undefined;
|
|
153
170
|
sender_name?: string | undefined;
|
|
171
|
+
open_bot_id?: string | undefined;
|
|
172
|
+
sender_i18n_names?: {
|
|
173
|
+
zh_cn?: string | undefined;
|
|
174
|
+
en_us?: string | undefined;
|
|
175
|
+
ja_jp?: string | undefined;
|
|
176
|
+
} | undefined;
|
|
154
177
|
} | undefined;
|
|
155
178
|
body?: {
|
|
156
179
|
content: string;
|
|
@@ -191,6 +214,12 @@ export declare function replyTextMessage(message_id: string, message: string): P
|
|
|
191
214
|
sender_type: string;
|
|
192
215
|
tenant_key?: string | undefined;
|
|
193
216
|
sender_name?: string | undefined;
|
|
217
|
+
open_bot_id?: string | undefined;
|
|
218
|
+
sender_i18n_names?: {
|
|
219
|
+
zh_cn?: string | undefined;
|
|
220
|
+
en_us?: string | undefined;
|
|
221
|
+
ja_jp?: string | undefined;
|
|
222
|
+
} | undefined;
|
|
194
223
|
} | undefined;
|
|
195
224
|
body?: {
|
|
196
225
|
content: string;
|
|
@@ -228,6 +257,12 @@ export declare function replyCardMessage(message_id: string, card: InteractiveCa
|
|
|
228
257
|
sender_type: string;
|
|
229
258
|
tenant_key?: string | undefined;
|
|
230
259
|
sender_name?: string | undefined;
|
|
260
|
+
open_bot_id?: string | undefined;
|
|
261
|
+
sender_i18n_names?: {
|
|
262
|
+
zh_cn?: string | undefined;
|
|
263
|
+
en_us?: string | undefined;
|
|
264
|
+
ja_jp?: string | undefined;
|
|
265
|
+
} | undefined;
|
|
231
266
|
} | undefined;
|
|
232
267
|
body?: {
|
|
233
268
|
content: string;
|
package/lib/lark/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lark/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lark/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,KAAK,EACV,eAAe,EACf,qBAAqB,EACrB,mBAAmB,EACnB,sBAAsB,EACtB,8BAA8B,EAC9B,4BAA4B,EAC7B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAC;AAGxE,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,EACL,sBAAsB,EACtB,sBAAsB,EACtB,2BAA2B,GAC5B,MAAM,WAAW,CAAC;AACnB,YAAY,EACV,IAAI,EACJ,eAAe,EACf,qBAAqB,E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sB,gBAAgB,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,eAAe;;;;kBAkDy0l3b,CAAC;eAAqD,CAAC;iBAAuD,CAAC;iBAAuD,CAAC;gBAAsD,CAAC;mBAAyD,CAAC;mBAAyD,CAAC;eAAqD,CAAC;eAAsD,CAAC;eAAsD,CAAC;cAAoD,CAAC;;;;sBAAgL,CAAC;uBAA6D,CAAC;uBAA6D,CAAC;6BAAmE,CAAC;qBAAyC,CAAC;qBAA2D,CAAC;qBAA2D,CAAC;;;YAAoI,CAAC;;;gBAAwH,CAAC;;;;;sBAAkN,CAAC;;wBAAuG,CAAC;wBAA8D,CAAC;wBAA8D,CAAC;+BAAqE,CAAC;;GAzCntp3b;AAED;;;GAGG;AACH,wBAAsB,iBAAiB,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,eAAe;;;;GAOhF;AAED,wBAAsB,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CASnE;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,2BAA2B,KAAK,IAAI,iBASnF"}
|
package/lib/lark/index.js
CHANGED
|
@@ -1,100 +1,48 @@
|
|
|
1
1
|
import { readFile } from 'node:fs/promises';
|
|
2
2
|
import * as lark from '@larksuiteoapi/node-sdk';
|
|
3
|
-
import {
|
|
3
|
+
import { buildErrorCard } from './helper.js';
|
|
4
4
|
export { getTextMessageContent } from './helper.js';
|
|
5
|
+
export { webhookSendCardMessage, webhookSendErrorCardMessage, webhookSendTextMessage } from './webhook.js';
|
|
5
6
|
|
|
6
7
|
const client = new lark.Client({
|
|
7
8
|
appId: process.env.LARK_APP_ID ?? "",
|
|
8
9
|
appSecret: process.env.LARK_APP_SECRET ?? ""
|
|
9
10
|
});
|
|
10
|
-
const
|
|
11
|
-
async function sendTextMessage(message) {
|
|
11
|
+
const defaultChatId = process.env.LARK_CHAT_ID ?? "";
|
|
12
|
+
async function sendTextMessage(message, chatId) {
|
|
12
13
|
return client.im.v1.message.create({
|
|
13
14
|
params: {
|
|
14
15
|
receive_id_type: "chat_id"
|
|
15
16
|
},
|
|
16
17
|
data: {
|
|
17
|
-
receive_id: chatId,
|
|
18
|
+
receive_id: chatId ?? defaultChatId,
|
|
18
19
|
msg_type: "text",
|
|
19
20
|
content: JSON.stringify({ text: message })
|
|
20
21
|
}
|
|
21
22
|
});
|
|
22
23
|
}
|
|
23
|
-
async function
|
|
24
|
-
return await fetchJson(process.env.LARK_WEBHOOK_URL ?? "", {
|
|
25
|
-
method: "POST",
|
|
26
|
-
body: JSON.stringify({ msg_type: "text", content: { text } })
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
async function webhookSendCardMessage(card) {
|
|
30
|
-
return await fetchJson(process.env.LARK_WEBHOOK_URL ?? "", {
|
|
31
|
-
method: "POST",
|
|
32
|
-
body: JSON.stringify({ msg_type: "interactive", card })
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
async function sendPostMessage(post) {
|
|
24
|
+
async function sendPostMessage(post, chatId) {
|
|
36
25
|
return await client.im.v1.message.create({
|
|
37
26
|
params: { receive_id_type: "chat_id" },
|
|
38
27
|
data: {
|
|
39
|
-
receive_id: chatId,
|
|
28
|
+
receive_id: chatId ?? defaultChatId,
|
|
40
29
|
msg_type: "post",
|
|
41
30
|
content: JSON.stringify(post)
|
|
42
31
|
}
|
|
43
32
|
});
|
|
44
33
|
}
|
|
45
|
-
async function sendCardMessage(card) {
|
|
34
|
+
async function sendCardMessage(card, chatId) {
|
|
46
35
|
return await client.im.v1.message.create({
|
|
47
36
|
params: { receive_id_type: "chat_id" },
|
|
48
37
|
data: {
|
|
49
|
-
receive_id: chatId,
|
|
38
|
+
receive_id: chatId ?? defaultChatId,
|
|
50
39
|
msg_type: "interactive",
|
|
51
40
|
content: JSON.stringify(card)
|
|
52
41
|
}
|
|
53
42
|
});
|
|
54
43
|
}
|
|
55
|
-
async function sendErrorCardMessage(message) {
|
|
56
|
-
|
|
57
|
-
schema: "2.0",
|
|
58
|
-
config: { update_multi: true },
|
|
59
|
-
header: {
|
|
60
|
-
template: "red",
|
|
61
|
-
padding: "8px 8px 8px 8px",
|
|
62
|
-
icon: { tag: "standard_icon", token: "buzz_outlined" },
|
|
63
|
-
title: { content: "\u9519\u8BEF\u63D0\u793A", tag: "plain_text" }
|
|
64
|
-
},
|
|
65
|
-
body: {
|
|
66
|
-
direction: "vertical",
|
|
67
|
-
elements: [
|
|
68
|
-
{
|
|
69
|
-
tag: "markdown",
|
|
70
|
-
content: `<font color="red">${message}</font>`,
|
|
71
|
-
text_size: "normal_v2",
|
|
72
|
-
text_align: "left",
|
|
73
|
-
margin: "0px 0px 0px 0px"
|
|
74
|
-
}
|
|
75
|
-
]
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
if (process.env.RUN_URL) {
|
|
79
|
-
card.body.elements.push({
|
|
80
|
-
tag: "button",
|
|
81
|
-
type: "danger_filled",
|
|
82
|
-
width: "default",
|
|
83
|
-
size: "tiny",
|
|
84
|
-
margin: "0px 0px 0px 0px",
|
|
85
|
-
behaviors: [
|
|
86
|
-
{
|
|
87
|
-
type: "open_url",
|
|
88
|
-
default_url: process.env.RUN_URL
|
|
89
|
-
}
|
|
90
|
-
],
|
|
91
|
-
text: {
|
|
92
|
-
tag: "plain_text",
|
|
93
|
-
content: "\u67E5\u770B\u8BE6\u60C5"
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
return await sendCardMessage(card);
|
|
44
|
+
async function sendErrorCardMessage(message, chatId) {
|
|
45
|
+
return await sendCardMessage(buildErrorCard(message), chatId);
|
|
98
46
|
}
|
|
99
47
|
async function replyTextMessage(message_id, message) {
|
|
100
48
|
return await client.im.v1.message.reply({
|
|
@@ -143,4 +91,4 @@ function startWsClient(callback) {
|
|
|
143
91
|
});
|
|
144
92
|
}
|
|
145
93
|
|
|
146
|
-
export { replyCardMessage, replyTextMessage, sendCardMessage, sendErrorCardMessage, sendPostMessage, sendTextMessage, startWsClient, updateCardMessage, uploadImage
|
|
94
|
+
export { replyCardMessage, replyTextMessage, sendCardMessage, sendErrorCardMessage, sendPostMessage, sendTextMessage, startWsClient, updateCardMessage, uploadImage };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { InteractiveCard } from './types/card.type';
|
|
2
|
+
export declare function webhookSendTextMessage(text: string, webhookUrl?: string): Promise<unknown>;
|
|
3
|
+
export declare function webhookSendCardMessage(card: InteractiveCard, webhookUrl?: string): Promise<unknown>;
|
|
4
|
+
export declare function webhookSendErrorCardMessage(message: string, webhookUrl?: string): Promise<unknown>;
|
|
5
|
+
//# sourceMappingURL=webhook.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webhook.d.ts","sourceRoot":"","sources":["../../src/lark/webhook.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGzD,wBAAsB,sBAAsB,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,oBAK7E;AAED,wBAAsB,sBAAsB,CAAC,IAAI,EAAE,eAAe,EAAE,UAAU,CAAC,EAAE,MAAM,oBAKtF;AAED,wBAAsB,2BAA2B,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,oBAKrF"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { fetchJson } from '@secret-momo/utils';
|
|
2
|
+
import { buildErrorCard } from './helper.js';
|
|
3
|
+
|
|
4
|
+
async function webhookSendTextMessage(text, webhookUrl) {
|
|
5
|
+
return await fetchJson(webhookUrl ?? process.env.LARK_WEBHOOK_URL ?? "", {
|
|
6
|
+
method: "POST",
|
|
7
|
+
body: JSON.stringify({ msg_type: "text", content: { text } })
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
async function webhookSendCardMessage(card, webhookUrl) {
|
|
11
|
+
return await fetchJson(webhookUrl ?? process.env.LARK_WEBHOOK_URL ?? "", {
|
|
12
|
+
method: "POST",
|
|
13
|
+
body: JSON.stringify({ msg_type: "interactive", card })
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
async function webhookSendErrorCardMessage(message, webhookUrl) {
|
|
17
|
+
return await fetchJson(webhookUrl ?? process.env.LARK_WEBHOOK_URL ?? "", {
|
|
18
|
+
method: "POST",
|
|
19
|
+
body: JSON.stringify({ msg_type: "interactive", card: buildErrorCard(message) })
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export { webhookSendCardMessage, webhookSendErrorCardMessage, webhookSendTextMessage };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@secret-momo/notifier",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"module": "src/index.ts",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"publishConfig": {
|
|
@@ -43,22 +43,22 @@
|
|
|
43
43
|
"@eslint/config-helpers": "0.6.0",
|
|
44
44
|
"@eslint/js": "10.0.1",
|
|
45
45
|
"@types/bun": "1.3.14",
|
|
46
|
-
"eslint": "10.
|
|
47
|
-
"eslint-plugin-import-x": "4.17.
|
|
46
|
+
"eslint": "10.7.0",
|
|
47
|
+
"eslint-plugin-import-x": "4.17.1",
|
|
48
48
|
"eslint-plugin-react": "7.37.5",
|
|
49
49
|
"eslint-plugin-react-hooks": "7.1.1",
|
|
50
50
|
"eslint-plugin-unused-imports": "4.4.1",
|
|
51
51
|
"husky": "9.1.7",
|
|
52
52
|
"jiti": "2.7.0",
|
|
53
53
|
"lint-staged": "17.0.8",
|
|
54
|
-
"prettier": "3.9.
|
|
54
|
+
"prettier": "3.9.5",
|
|
55
55
|
"rollup": "4.62.2",
|
|
56
56
|
"rollup-plugin-esbuild": "6.2.1",
|
|
57
57
|
"typescript": "6.0.3",
|
|
58
|
-
"typescript-eslint": "8.
|
|
58
|
+
"typescript-eslint": "8.64.0"
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@larksuiteoapi/node-sdk": "1.
|
|
62
|
-
"@secret-momo/utils": "1.
|
|
61
|
+
"@larksuiteoapi/node-sdk": "1.71.1",
|
|
62
|
+
"@secret-momo/utils": "1.2.0"
|
|
63
63
|
}
|
|
64
64
|
}
|