@secret-momo/notifier 1.1.0 → 1.3.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 +3 -2
- package/lib/lark/helper.d.ts +3 -0
- package/lib/lark/helper.d.ts.map +1 -1
- package/lib/lark/helper.js +55 -1
- package/lib/lark/index.d.ts +76 -3
- package/lib/lark/index.d.ts.map +1 -1
- package/lib/lark/index.js +16 -57
- package/lib/lark/index.test.d.ts +2 -0
- package/lib/lark/index.test.d.ts.map +1 -0
- package/lib/lark/types/emoji.type.d.ts +5 -0
- package/lib/lark/types/emoji.type.d.ts.map +1 -0
- 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/lib/telegram/index.test.d.ts +2 -0
- package/lib/telegram/index.test.d.ts.map +1 -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 { createReaction, deleteReaction, replyCardMessage, replyTextMessage, sendCardMessage, sendErrorCardMessage, sendPostMessage, sendTextMessage, startWsClient, updateCardMessage, uploadImage } from './lark/index.js';
|
|
2
2
|
export { e, sendMessage } from './telegram/index.js';
|
|
3
|
-
export { getTextMessageContent } from './lark/helper.js';
|
|
3
|
+
export { getLarkErrorMessage, getTextMessageContent } from './lark/helper.js';
|
|
4
|
+
export { webhookSendCardMessage, webhookSendErrorCardMessage, webhookSendTextMessage } from './lark/webhook.js';
|
package/lib/lark/helper.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
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 getLarkErrorMessage(error: unknown): any;
|
|
5
|
+
export declare function buildErrorCard(message: string): InteractiveCard;
|
|
3
6
|
//# 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,mBAAmB,CAAC,KAAK,EAAE,OAAO,OAYjD;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,mBA6C7C"}
|
package/lib/lark/helper.js
CHANGED
|
@@ -4,5 +4,59 @@ function getTextMessageContent(e) {
|
|
|
4
4
|
}
|
|
5
5
|
return "";
|
|
6
6
|
}
|
|
7
|
+
function getLarkErrorMessage(error) {
|
|
8
|
+
const e = error;
|
|
9
|
+
if (e.response?.data) {
|
|
10
|
+
const { code, msg } = e.response.data;
|
|
11
|
+
if (code && msg) {
|
|
12
|
+
return `code=${code}, msg=${msg}`;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return e.message;
|
|
16
|
+
}
|
|
17
|
+
function buildErrorCard(message) {
|
|
18
|
+
const card = {
|
|
19
|
+
schema: "2.0",
|
|
20
|
+
config: { update_multi: true },
|
|
21
|
+
header: {
|
|
22
|
+
template: "red",
|
|
23
|
+
padding: "8px 8px 8px 8px",
|
|
24
|
+
icon: { tag: "standard_icon", token: "buzz_outlined" },
|
|
25
|
+
title: { content: "\u9519\u8BEF\u63D0\u793A", tag: "plain_text" }
|
|
26
|
+
},
|
|
27
|
+
body: {
|
|
28
|
+
direction: "vertical",
|
|
29
|
+
elements: [
|
|
30
|
+
{
|
|
31
|
+
tag: "markdown",
|
|
32
|
+
content: `<font color="red">${message}</font>`,
|
|
33
|
+
text_size: "normal_v2",
|
|
34
|
+
text_align: "left",
|
|
35
|
+
margin: "0px 0px 0px 0px"
|
|
36
|
+
}
|
|
37
|
+
]
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
if (process.env.RUN_URL) {
|
|
41
|
+
card.body.elements.push({
|
|
42
|
+
tag: "button",
|
|
43
|
+
type: "danger_filled",
|
|
44
|
+
width: "default",
|
|
45
|
+
size: "tiny",
|
|
46
|
+
margin: "0px 0px 0px 0px",
|
|
47
|
+
behaviors: [
|
|
48
|
+
{
|
|
49
|
+
type: "open_url",
|
|
50
|
+
default_url: process.env.RUN_URL
|
|
51
|
+
}
|
|
52
|
+
],
|
|
53
|
+
text: {
|
|
54
|
+
tag: "plain_text",
|
|
55
|
+
content: "\u67E5\u770B\u8BE6\u60C5"
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
return card;
|
|
60
|
+
}
|
|
7
61
|
|
|
8
|
-
export { getTextMessageContent };
|
|
62
|
+
export { buildErrorCard, getLarkErrorMessage, getTextMessageContent };
|
package/lib/lark/index.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
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
|
+
import type { EmojiType } from './types/emoji.type';
|
|
5
|
+
export { getTextMessageContent, getLarkErrorMessage } from './helper';
|
|
6
|
+
export { webhookSendTextMessage, webhookSendCardMessage, webhookSendErrorCardMessage, } from './webhook';
|
|
5
7
|
export type { Post, InteractiveCard, InteractiveCardHeader, InteractiveCardBody, InteractiveCardElement, InteractiveCardMarkdownElement, InteractiveCardButtonElement, LarkIMMessageReceiveV1Event, };
|
|
6
8
|
/**
|
|
7
9
|
* 发送普通文本消息,文档地址:
|
|
@@ -27,6 +29,12 @@ export declare function sendTextMessage(message: string, chatId?: string): Promi
|
|
|
27
29
|
sender_type: string;
|
|
28
30
|
tenant_key?: string | undefined;
|
|
29
31
|
sender_name?: string | undefined;
|
|
32
|
+
open_bot_id?: string | undefined;
|
|
33
|
+
sender_i18n_names?: {
|
|
34
|
+
zh_cn?: string | undefined;
|
|
35
|
+
en_us?: string | undefined;
|
|
36
|
+
ja_jp?: string | undefined;
|
|
37
|
+
} | undefined;
|
|
30
38
|
} | undefined;
|
|
31
39
|
body?: {
|
|
32
40
|
content: string;
|
|
@@ -68,6 +76,12 @@ export declare function sendPostMessage(post: Post, chatId?: string): Promise<{
|
|
|
68
76
|
sender_type: string;
|
|
69
77
|
tenant_key?: string | undefined;
|
|
70
78
|
sender_name?: string | undefined;
|
|
79
|
+
open_bot_id?: string | undefined;
|
|
80
|
+
sender_i18n_names?: {
|
|
81
|
+
zh_cn?: string | undefined;
|
|
82
|
+
en_us?: string | undefined;
|
|
83
|
+
ja_jp?: string | undefined;
|
|
84
|
+
} | undefined;
|
|
71
85
|
} | undefined;
|
|
72
86
|
body?: {
|
|
73
87
|
content: string;
|
|
@@ -109,6 +123,12 @@ export declare function sendCardMessage(card: InteractiveCard, chatId?: string):
|
|
|
109
123
|
sender_type: string;
|
|
110
124
|
tenant_key?: string | undefined;
|
|
111
125
|
sender_name?: string | undefined;
|
|
126
|
+
open_bot_id?: string | undefined;
|
|
127
|
+
sender_i18n_names?: {
|
|
128
|
+
zh_cn?: string | undefined;
|
|
129
|
+
en_us?: string | undefined;
|
|
130
|
+
ja_jp?: string | undefined;
|
|
131
|
+
} | undefined;
|
|
112
132
|
} | undefined;
|
|
113
133
|
body?: {
|
|
114
134
|
content: string;
|
|
@@ -149,6 +169,12 @@ export declare function sendErrorCardMessage(message: string, chatId?: string):
|
|
|
149
169
|
sender_type: string;
|
|
150
170
|
tenant_key?: string | undefined;
|
|
151
171
|
sender_name?: string | undefined;
|
|
172
|
+
open_bot_id?: string | undefined;
|
|
173
|
+
sender_i18n_names?: {
|
|
174
|
+
zh_cn?: string | undefined;
|
|
175
|
+
en_us?: string | undefined;
|
|
176
|
+
ja_jp?: string | undefined;
|
|
177
|
+
} | undefined;
|
|
152
178
|
} | undefined;
|
|
153
179
|
body?: {
|
|
154
180
|
content: string;
|
|
@@ -189,6 +215,12 @@ export declare function replyTextMessage(message_id: string, message: string): P
|
|
|
189
215
|
sender_type: string;
|
|
190
216
|
tenant_key?: string | undefined;
|
|
191
217
|
sender_name?: string | undefined;
|
|
218
|
+
open_bot_id?: string | undefined;
|
|
219
|
+
sender_i18n_names?: {
|
|
220
|
+
zh_cn?: string | undefined;
|
|
221
|
+
en_us?: string | undefined;
|
|
222
|
+
ja_jp?: string | undefined;
|
|
223
|
+
} | undefined;
|
|
192
224
|
} | undefined;
|
|
193
225
|
body?: {
|
|
194
226
|
content: string;
|
|
@@ -226,6 +258,12 @@ export declare function replyCardMessage(message_id: string, card: InteractiveCa
|
|
|
226
258
|
sender_type: string;
|
|
227
259
|
tenant_key?: string | undefined;
|
|
228
260
|
sender_name?: string | undefined;
|
|
261
|
+
open_bot_id?: string | undefined;
|
|
262
|
+
sender_i18n_names?: {
|
|
263
|
+
zh_cn?: string | undefined;
|
|
264
|
+
en_us?: string | undefined;
|
|
265
|
+
ja_jp?: string | undefined;
|
|
266
|
+
} | undefined;
|
|
229
267
|
} | undefined;
|
|
230
268
|
body?: {
|
|
231
269
|
content: string;
|
|
@@ -252,9 +290,44 @@ export declare function updateCardMessage(message_id: string, card: InteractiveC
|
|
|
252
290
|
msg?: string | undefined;
|
|
253
291
|
data?: {} | undefined;
|
|
254
292
|
}>;
|
|
255
|
-
export declare function webhookSendTextMessage(text: string, webhookUrl?: string): Promise<unknown>;
|
|
256
|
-
export declare function webhookSendCardMessage(card: InteractiveCard, webhookUrl?: string): Promise<unknown>;
|
|
257
293
|
export declare function uploadImage(filePath: string): Promise<string>;
|
|
294
|
+
/**
|
|
295
|
+
* 添加表情回复:
|
|
296
|
+
* https://open.feishu.cn/document/server-docs/im-v1/message-reaction/emojis-introduce
|
|
297
|
+
*/
|
|
298
|
+
export declare function createReaction(message_id: string, emoji_type: EmojiType): Promise<{
|
|
299
|
+
code?: number | undefined;
|
|
300
|
+
msg?: string | undefined;
|
|
301
|
+
data?: {
|
|
302
|
+
reaction_id?: string | undefined;
|
|
303
|
+
operator?: {
|
|
304
|
+
operator_id: string;
|
|
305
|
+
operator_type: "app" | "user";
|
|
306
|
+
} | undefined;
|
|
307
|
+
action_time?: string | undefined;
|
|
308
|
+
reaction_type?: {
|
|
309
|
+
emoji_type: string;
|
|
310
|
+
} | undefined;
|
|
311
|
+
} | undefined;
|
|
312
|
+
}>;
|
|
313
|
+
/**
|
|
314
|
+
* 删除表情回复
|
|
315
|
+
*/
|
|
316
|
+
export declare function deleteReaction(message_id: string, reaction_id: string): Promise<{
|
|
317
|
+
code?: number | undefined;
|
|
318
|
+
msg?: string | undefined;
|
|
319
|
+
data?: {
|
|
320
|
+
reaction_id?: string | undefined;
|
|
321
|
+
operator?: {
|
|
322
|
+
operator_id: string;
|
|
323
|
+
operator_type: "app" | "user";
|
|
324
|
+
} | undefined;
|
|
325
|
+
action_time?: string | undefined;
|
|
326
|
+
reaction_type?: {
|
|
327
|
+
emoji_type: string;
|
|
328
|
+
} | undefined;
|
|
329
|
+
} | undefined;
|
|
330
|
+
}>;
|
|
258
331
|
/**
|
|
259
332
|
* 启动 WebSocket 客户端
|
|
260
333
|
*
|
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;AAExE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD,OAAO,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AACtE,OAAO,EACL,sBAAsB,EACtB,sBAAsB,EACtB,2BAA2B,GAC5B,MAAM,WAAW,CAAC;AACnB,YAAY,EACV,IAAI,EACJ,eAAe,EACf,qBAAqB,EACrB,mBAAmB,EACnB,sBAAsB,EACtB,8BAA8B,EAC9B,4BAA4B,EAC5B,2BAA2B,GAC5B,CAAC;AAQF;;;GAGG;AACH,wBAAsB,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM;;;;kBAsIym01b,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;;GA3Hz+31b;AAED;;;GAGG;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AQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CASnE;AAED;;;GAGG;AACH,wBAAsB,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS;;;;mBA+Biv44b,CAAC;gBAAsD,CAAC;;;;mBAA0L,CAAC;qBAA2D,CAAC;;;;GA1B7m54b;AAED;;GAEG;AACH,wBAAsB,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM;;;;mBAqB6u74b,CAAC;gBAAsD,CAAC;;;;mBAA0L,CAAC;qBAA2D,CAAC;;;;GAjBvm84b;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,2BAA2B,KAAK,IAAI,iBASnF"}
|
package/lib/lark/index.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { readFile } from 'node:fs/promises';
|
|
2
2
|
import * as lark from '@larksuiteoapi/node-sdk';
|
|
3
|
-
import {
|
|
4
|
-
export { getTextMessageContent } from './helper.js';
|
|
3
|
+
import { buildErrorCard } from './helper.js';
|
|
4
|
+
export { getLarkErrorMessage, 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 ?? "",
|
|
@@ -41,48 +42,7 @@ async function sendCardMessage(card, chatId) {
|
|
|
41
42
|
});
|
|
42
43
|
}
|
|
43
44
|
async function sendErrorCardMessage(message, chatId) {
|
|
44
|
-
|
|
45
|
-
schema: "2.0",
|
|
46
|
-
config: { update_multi: true },
|
|
47
|
-
header: {
|
|
48
|
-
template: "red",
|
|
49
|
-
padding: "8px 8px 8px 8px",
|
|
50
|
-
icon: { tag: "standard_icon", token: "buzz_outlined" },
|
|
51
|
-
title: { content: "\u9519\u8BEF\u63D0\u793A", tag: "plain_text" }
|
|
52
|
-
},
|
|
53
|
-
body: {
|
|
54
|
-
direction: "vertical",
|
|
55
|
-
elements: [
|
|
56
|
-
{
|
|
57
|
-
tag: "markdown",
|
|
58
|
-
content: `<font color="red">${message}</font>`,
|
|
59
|
-
text_size: "normal_v2",
|
|
60
|
-
text_align: "left",
|
|
61
|
-
margin: "0px 0px 0px 0px"
|
|
62
|
-
}
|
|
63
|
-
]
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
if (process.env.RUN_URL) {
|
|
67
|
-
card.body.elements.push({
|
|
68
|
-
tag: "button",
|
|
69
|
-
type: "danger_filled",
|
|
70
|
-
width: "default",
|
|
71
|
-
size: "tiny",
|
|
72
|
-
margin: "0px 0px 0px 0px",
|
|
73
|
-
behaviors: [
|
|
74
|
-
{
|
|
75
|
-
type: "open_url",
|
|
76
|
-
default_url: process.env.RUN_URL
|
|
77
|
-
}
|
|
78
|
-
],
|
|
79
|
-
text: {
|
|
80
|
-
tag: "plain_text",
|
|
81
|
-
content: "\u67E5\u770B\u8BE6\u60C5"
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
return await sendCardMessage(card, chatId);
|
|
45
|
+
return await sendCardMessage(buildErrorCard(message), chatId);
|
|
86
46
|
}
|
|
87
47
|
async function replyTextMessage(message_id, message) {
|
|
88
48
|
return await client.im.v1.message.reply({
|
|
@@ -112,18 +72,6 @@ async function updateCardMessage(message_id, card) {
|
|
|
112
72
|
}
|
|
113
73
|
});
|
|
114
74
|
}
|
|
115
|
-
async function webhookSendTextMessage(text, webhookUrl) {
|
|
116
|
-
return await fetchJson(webhookUrl ?? process.env.LARK_WEBHOOK_URL ?? "", {
|
|
117
|
-
method: "POST",
|
|
118
|
-
body: JSON.stringify({ msg_type: "text", content: { text } })
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
async function webhookSendCardMessage(card, webhookUrl) {
|
|
122
|
-
return await fetchJson(webhookUrl ?? process.env.LARK_WEBHOOK_URL ?? "", {
|
|
123
|
-
method: "POST",
|
|
124
|
-
body: JSON.stringify({ msg_type: "interactive", card })
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
75
|
async function uploadImage(filePath) {
|
|
128
76
|
const res = await client.im.v1.image.create({
|
|
129
77
|
data: {
|
|
@@ -133,6 +81,17 @@ async function uploadImage(filePath) {
|
|
|
133
81
|
});
|
|
134
82
|
return res.image_key;
|
|
135
83
|
}
|
|
84
|
+
async function createReaction(message_id, emoji_type) {
|
|
85
|
+
return await client.im.v1.messageReaction.create({
|
|
86
|
+
data: { reaction_type: { emoji_type } },
|
|
87
|
+
path: { message_id }
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
async function deleteReaction(message_id, reaction_id) {
|
|
91
|
+
return await client.im.v1.messageReaction.delete({
|
|
92
|
+
path: { message_id, reaction_id }
|
|
93
|
+
});
|
|
94
|
+
}
|
|
136
95
|
function startWsClient(callback) {
|
|
137
96
|
const wsClient = new lark.WSClient({
|
|
138
97
|
appId: process.env.LARK_APP_ID ?? "",
|
|
@@ -143,4 +102,4 @@ function startWsClient(callback) {
|
|
|
143
102
|
});
|
|
144
103
|
}
|
|
145
104
|
|
|
146
|
-
export { replyCardMessage, replyTextMessage, sendCardMessage, sendErrorCardMessage, sendPostMessage, sendTextMessage, startWsClient, updateCardMessage, uploadImage
|
|
105
|
+
export { createReaction, deleteReaction, replyCardMessage, replyTextMessage, sendCardMessage, sendErrorCardMessage, sendPostMessage, sendTextMessage, startWsClient, updateCardMessage, uploadImage };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../../src/lark/index.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 官方文档:https://open.feishu.cn/document/server-docs/im-v1/message-reaction/emojis-introduce
|
|
3
|
+
*/
|
|
4
|
+
export type EmojiType = 'OK' | 'THUMBSUP' | 'THANKS' | 'MUSCLE' | 'FINGERHEART' | 'APPLAUSE' | 'FISTBUMP' | 'JIAYI' | 'DONE' | 'SMILE' | 'BLUSH' | 'LAUGH' | 'SMIRK' | 'LOL' | 'FACEPALM' | 'LOVE' | 'WINK' | 'PROUD' | 'WITTY' | 'SMART' | 'SCOWL' | 'THINKING' | 'SOB' | 'CRY' | 'ERROR' | 'NOSEPICK' | 'HAUGHTY' | 'SLAP' | 'SPITBLOOD' | 'TOASTED' | 'GLANCE' | 'DULL' | 'INNOCENTSMILE' | 'JOYFUL' | 'WOW' | 'TRICK' | 'YEAH' | 'ENOUGH' | 'TEARS' | 'EMBARRASSED' | 'KISS' | 'SMOOCH' | 'DROOL' | 'OBSESSED' | 'MONEY' | 'TEASE' | 'SHOWOFF' | 'COMFORT' | 'CLAP' | 'PRAISE' | 'STRIVE' | 'XBLUSH' | 'SILENT' | 'WAVE' | 'WHAT' | 'FROWN' | 'SHY' | 'DIZZY' | 'LOOKDOWN' | 'CHUCKLE' | 'WAIL' | 'CRAZY' | 'WHIMPER' | 'HUG' | 'BLUBBER' | 'WRONGED' | 'HUSKY' | 'SHHH' | 'SMUG' | 'ANGRY' | 'HAMMER' | 'SHOCKED' | 'TERROR' | 'PETRIFIED' | 'SKULL' | 'SWEAT' | 'SPEECHLESS' | 'SLEEP' | 'DROWSY' | 'YAWN' | 'SICK' | 'PUKE' | 'BETRAYED' | 'HEADSET' | 'EatingFood' | 'MeMeMe' | 'Sigh' | 'Typing' | 'Lemon' | 'Get' | 'LGTM' | 'OnIt' | 'OneSecond' | 'VRHeadset' | 'YouAreTheBest' | 'SALUTE' | 'SHAKE' | 'HIGHFIVE' | 'UPPERLEFT' | 'ThumbsDown' | 'SLIGHT' | 'TONGUE' | 'EYESCLOSED' | 'RoarForYou' | 'CALF' | 'BEAR' | 'BULL' | 'RAINBOWPUKE' | 'ROSE' | 'HEART' | 'PARTY' | 'LIPS' | 'BEER' | 'CAKE' | 'GIFT' | 'CUCUMBER' | 'Drumstick' | 'Pepper' | 'CANDIEDHAWS' | 'BubbleTea' | 'Coffee' | 'Yes' | 'No' | 'OKR' | 'CheckMark' | 'CrossMark' | 'MinusOne' | 'Hundred' | 'AWESOMEN' | 'Pin' | 'Alarm' | 'Loudspeaker' | 'Trophy' | 'Fire' | 'BOMB' | 'Music' | 'XmasTree' | 'Snowman' | 'XmasHat' | 'FIREWORKS' | '2022' | 'REDPACKET' | 'FORTUNE' | 'LUCK' | 'FIRECRACKER' | 'StickyRiceBalls' | 'HEARTBROKEN' | 'POOP' | 'StatusFlashOfInspiration' | '18X' | 'CLEAVER' | 'Soccer' | 'Basketball' | 'GeneralDoNotDisturb' | 'Status_PrivateMessage' | 'GeneralInMeetingBusy' | 'StatusReading' | 'StatusInFlight' | 'GeneralBusinessTrip' | 'GeneralWorkFromHome' | 'StatusEnjoyLife' | 'GeneralTravellingCar' | 'StatusBus' | 'GeneralSun' | 'GeneralMoonRest' | 'MoonRabbit' | 'Mooncake' | 'JubilantRabbit' | 'TV' | 'Movie' | 'Pumpkin' | 'BeamingFace' | 'Delighted' | 'ColdSweat' | 'FullMoonFace' | 'Partying' | 'GoGoGo' | 'ThanksFace' | 'SaluteFace' | 'Shrug' | 'ClownFace' | 'HappyDragon';
|
|
5
|
+
//# sourceMappingURL=emoji.type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emoji.type.d.ts","sourceRoot":"","sources":["../../../src/lark/types/emoji.type.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,SAAS,GACjB,IAAI,GACJ,UAAU,GACV,QAAQ,GACR,QAAQ,GACR,aAAa,GACb,UAAU,GACV,UAAU,GACV,OAAO,GACP,MAAM,GACN,OAAO,GACP,OAAO,GACP,OAAO,GACP,OAAO,GACP,KAAK,GACL,UAAU,GACV,MAAM,GACN,MAAM,GACN,OAAO,GACP,OAAO,GACP,OAAO,GACP,OAAO,GACP,UAAU,GACV,KAAK,GACL,KAAK,GACL,OAAO,GACP,UAAU,GACV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,SAAS,GACT,SAAS,GACT,WAAW,GACX,MAAM,GACN,WAAW,GACX,SAAS,GACT,MAAM,GACN,aAAa,GACb,iBAAiB,GACjB,aAAa,GACb,MAAM,GACN,0BAA0B,GAC1B,KAAK,GACL,SAAS,GACT,QAAQ,GACR,YAAY,GACZ,qBAAqB,GACrB,uBAAuB,GACvB,sBAAsB,GACtB,eAAe,GACf,gBAAgB,GAChB,qBAAqB,GACrB,qBAAqB,GACrB,iBAAiB,GACjB,sBAAsB,GACtB,WAAW,GACX,YAAY,GACZ,iBAAiB,GACjB,YAAY,GACZ,UAAU,GACV,gBAAgB,GAChB,IAAI,GACJ,OAAO,GACP,SAAS,GACT,aAAa,GACb,WAAW,GACX,WAAW,GACX,cAAc,GACd,UAAU,GACV,QAAQ,GACR,YAAY,GACZ,YAAY,GACZ,OAAO,GACP,WAAW,GACX,aAAa,CAAC"}
|
|
@@ -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 };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../../src/telegram/index.test.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@secret-momo/notifier",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.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
|
}
|