@secret-momo/notifier 1.2.0 → 1.3.1
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 +1 -4
- package/lib/lark/helper.d.ts +1 -0
- package/lib/lark/helper.d.ts.map +1 -1
- package/lib/lark/helper.js +1 -52
- package/lib/lark/index.d.ts +39 -1
- package/lib/lark/index.d.ts.map +1 -1
- package/lib/lark/index.js +1 -94
- 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.js +1 -23
- package/lib/telegram/index.js +1 -27
- package/lib/telegram/index.test.d.ts +2 -0
- package/lib/telegram/index.test.d.ts.map +1 -0
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -1,4 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { e, sendMessage } from './telegram/index.js';
|
|
3
|
-
export { getTextMessageContent } from './lark/helper.js';
|
|
4
|
-
export { webhookSendCardMessage, webhookSendErrorCardMessage, webhookSendTextMessage } from './lark/webhook.js';
|
|
1
|
+
import{createReaction as r,deleteReaction as a,replyCardMessage as o,replyTextMessage as t,sendCardMessage as d,sendErrorCardMessage as g,sendPostMessage as n,sendTextMessage as M,startWsClient as p,updateCardMessage as x,uploadImage as C}from"./lark/index.js";import{e as m,sendMessage as f}from"./telegram/index.js";import{getLarkErrorMessage as T,getTextMessageContent as b}from"./lark/helper.js";import{webhookSendCardMessage as h,webhookSendErrorCardMessage as i,webhookSendTextMessage as w}from"./lark/webhook.js";export{r as createReaction,a as deleteReaction,m as e,T as getLarkErrorMessage,b as getTextMessageContent,o as replyCardMessage,t as replyTextMessage,d as sendCardMessage,g as sendErrorCardMessage,f as sendMessage,n as sendPostMessage,M as sendTextMessage,p as startWsClient,x as updateCardMessage,C as uploadImage,h as webhookSendCardMessage,i as webhookSendErrorCardMessage,w as webhookSendTextMessage};
|
package/lib/lark/helper.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { InteractiveCard } from './types/card.type';
|
|
2
2
|
import type { LarkIMMessageReceiveV1Event } from './types/receive.type';
|
|
3
3
|
export declare function getTextMessageContent(e: LarkIMMessageReceiveV1Event): string;
|
|
4
|
+
export declare function getLarkErrorMessage(error: unknown): any;
|
|
4
5
|
export declare function buildErrorCard(message: string): InteractiveCard;
|
|
5
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,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"}
|
|
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
|
@@ -1,52 +1 @@
|
|
|
1
|
-
function
|
|
2
|
-
if (e.message?.message_type === "text") {
|
|
3
|
-
return JSON.parse(e.message.content ?? "{}").text ?? "";
|
|
4
|
-
}
|
|
5
|
-
return "";
|
|
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
|
-
}
|
|
51
|
-
|
|
52
|
-
export { buildErrorCard, getTextMessageContent };
|
|
1
|
+
function a(e){return e.message?.message_type==="text"?JSON.parse(e.message.content??"{}").text??"":""}function o(e){const t=e;if(t.response?.data){const{code:n,msg:r}=t.response.data;if(n&&r)return`code=${n}, msg=${r}`}return t.message}function s(e){const t={schema:"2.0",config:{update_multi:!0},header:{template:"red",padding:"8px 8px 8px 8px",icon:{tag:"standard_icon",token:"buzz_outlined"},title:{content:"\u9519\u8BEF\u63D0\u793A",tag:"plain_text"}},body:{direction:"vertical",elements:[{tag:"markdown",content:`<font color="red">${e}</font>`,text_size:"normal_v2",text_align:"left",margin:"0px 0px 0px 0px"}]}};return process.env.RUN_URL&&t.body.elements.push({tag:"button",type:"danger_filled",width:"default",size:"tiny",margin:"0px 0px 0px 0px",behaviors:[{type:"open_url",default_url:process.env.RUN_URL}],text:{tag:"plain_text",content:"\u67E5\u770B\u8BE6\u60C5"}}),t}export{s as buildErrorCard,o as getLarkErrorMessage,a as getTextMessageContent};
|
package/lib/lark/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
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';
|
|
5
6
|
export { webhookSendTextMessage, webhookSendCardMessage, webhookSendErrorCardMessage, } from './webhook';
|
|
6
7
|
export type { Post, InteractiveCard, InteractiveCardHeader, InteractiveCardBody, InteractiveCardElement, InteractiveCardMarkdownElement, InteractiveCardButtonElement, LarkIMMessageReceiveV1Event, };
|
|
7
8
|
/**
|
|
@@ -290,6 +291,43 @@ export declare function updateCardMessage(message_id: string, card: InteractiveC
|
|
|
290
291
|
data?: {} | undefined;
|
|
291
292
|
}>;
|
|
292
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
|
+
}>;
|
|
293
331
|
/**
|
|
294
332
|
* 启动 WebSocket 客户端
|
|
295
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":"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;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","s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,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,94 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import * as lark from '@larksuiteoapi/node-sdk';
|
|
3
|
-
import { buildErrorCard } from './helper.js';
|
|
4
|
-
export { getTextMessageContent } from './helper.js';
|
|
5
|
-
export { webhookSendCardMessage, webhookSendErrorCardMessage, webhookSendTextMessage } from './webhook.js';
|
|
6
|
-
|
|
7
|
-
const client = new lark.Client({
|
|
8
|
-
appId: process.env.LARK_APP_ID ?? "",
|
|
9
|
-
appSecret: process.env.LARK_APP_SECRET ?? ""
|
|
10
|
-
});
|
|
11
|
-
const defaultChatId = process.env.LARK_CHAT_ID ?? "";
|
|
12
|
-
async function sendTextMessage(message, chatId) {
|
|
13
|
-
return client.im.v1.message.create({
|
|
14
|
-
params: {
|
|
15
|
-
receive_id_type: "chat_id"
|
|
16
|
-
},
|
|
17
|
-
data: {
|
|
18
|
-
receive_id: chatId ?? defaultChatId,
|
|
19
|
-
msg_type: "text",
|
|
20
|
-
content: JSON.stringify({ text: message })
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
async function sendPostMessage(post, chatId) {
|
|
25
|
-
return await client.im.v1.message.create({
|
|
26
|
-
params: { receive_id_type: "chat_id" },
|
|
27
|
-
data: {
|
|
28
|
-
receive_id: chatId ?? defaultChatId,
|
|
29
|
-
msg_type: "post",
|
|
30
|
-
content: JSON.stringify(post)
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
async function sendCardMessage(card, chatId) {
|
|
35
|
-
return await client.im.v1.message.create({
|
|
36
|
-
params: { receive_id_type: "chat_id" },
|
|
37
|
-
data: {
|
|
38
|
-
receive_id: chatId ?? defaultChatId,
|
|
39
|
-
msg_type: "interactive",
|
|
40
|
-
content: JSON.stringify(card)
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
async function sendErrorCardMessage(message, chatId) {
|
|
45
|
-
return await sendCardMessage(buildErrorCard(message), chatId);
|
|
46
|
-
}
|
|
47
|
-
async function replyTextMessage(message_id, message) {
|
|
48
|
-
return await client.im.v1.message.reply({
|
|
49
|
-
path: { message_id },
|
|
50
|
-
data: {
|
|
51
|
-
msg_type: "text",
|
|
52
|
-
reply_in_thread: false,
|
|
53
|
-
content: JSON.stringify({ text: message })
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
async function replyCardMessage(message_id, card) {
|
|
58
|
-
return await client.im.v1.message.reply({
|
|
59
|
-
path: { message_id },
|
|
60
|
-
data: {
|
|
61
|
-
msg_type: "interactive",
|
|
62
|
-
reply_in_thread: false,
|
|
63
|
-
content: JSON.stringify(card)
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
async function updateCardMessage(message_id, card) {
|
|
68
|
-
return await client.im.v1.message.patch({
|
|
69
|
-
path: { message_id },
|
|
70
|
-
data: {
|
|
71
|
-
content: JSON.stringify(card)
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
async function uploadImage(filePath) {
|
|
76
|
-
const res = await client.im.v1.image.create({
|
|
77
|
-
data: {
|
|
78
|
-
image_type: "message",
|
|
79
|
-
image: await readFile(filePath)
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
return res.image_key;
|
|
83
|
-
}
|
|
84
|
-
function startWsClient(callback) {
|
|
85
|
-
const wsClient = new lark.WSClient({
|
|
86
|
-
appId: process.env.LARK_APP_ID ?? "",
|
|
87
|
-
appSecret: process.env.LARK_APP_SECRET ?? ""
|
|
88
|
-
});
|
|
89
|
-
return wsClient.start({
|
|
90
|
-
eventDispatcher: new lark.EventDispatcher({}).register({ "im.message.receive_v1": callback })
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
export { replyCardMessage, replyTextMessage, sendCardMessage, sendErrorCardMessage, sendPostMessage, sendTextMessage, startWsClient, updateCardMessage, uploadImage };
|
|
1
|
+
import{readFile as i}from"node:fs/promises";import*as s from"@larksuiteoapi/node-sdk";import{buildErrorCard as c}from"./helper.js";import{getLarkErrorMessage as S,getTextMessageContent as M}from"./helper.js";import{webhookSendCardMessage as R,webhookSendErrorCardMessage as A,webhookSendTextMessage as E}from"./webhook.js";const a=new s.Client({appId:process.env.LARK_APP_ID??"",appSecret:process.env.LARK_APP_SECRET??""}),r=process.env.LARK_CHAT_ID??"";async function o(e,t){return a.im.v1.message.create({params:{receive_id_type:"chat_id"},data:{receive_id:t??r,msg_type:"text",content:JSON.stringify({text:e})}})}async function p(e,t){return await a.im.v1.message.create({params:{receive_id_type:"chat_id"},data:{receive_id:t??r,msg_type:"post",content:JSON.stringify(e)}})}async function n(e,t){return await a.im.v1.message.create({params:{receive_id_type:"chat_id"},data:{receive_id:t??r,msg_type:"interactive",content:JSON.stringify(e)}})}async function d(e,t){return await n(c(e),t)}async function m(e,t){return await a.im.v1.message.reply({path:{message_id:e},data:{msg_type:"text",reply_in_thread:!1,content:JSON.stringify({text:t})}})}async function g(e,t){return await a.im.v1.message.reply({path:{message_id:e},data:{msg_type:"interactive",reply_in_thread:!1,content:JSON.stringify(t)}})}async function _(e,t){return await a.im.v1.message.patch({path:{message_id:e},data:{content:JSON.stringify(t)}})}async function y(e){return(await a.im.v1.image.create({data:{image_type:"message",image:await i(e)}})).image_key}async function v(e,t){return await a.im.v1.messageReaction.create({data:{reaction_type:{emoji_type:t}},path:{message_id:e}})}async function u(e,t){return await a.im.v1.messageReaction.delete({path:{message_id:e,reaction_id:t}})}function f(e){return new s.WSClient({appId:process.env.LARK_APP_ID??"",appSecret:process.env.LARK_APP_SECRET??""}).start({eventDispatcher:new s.EventDispatcher({}).register({"im.message.receive_v1":e})})}export{v as createReaction,u as deleteReaction,S as getLarkErrorMessage,M as getTextMessageContent,g as replyCardMessage,m as replyTextMessage,n as sendCardMessage,d as sendErrorCardMessage,p as sendPostMessage,o as sendTextMessage,f as startWsClient,_ as updateCardMessage,y as uploadImage,R as webhookSendCardMessage,A as webhookSendErrorCardMessage,E as webhookSendTextMessage};
|
|
@@ -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,SAAS,GACT,MAAM,GACN,WAAW,GACX,SAAS,GACT,QAAQ,GACR,MAAM,GACN,eAAe,GACf,QAAQ,GACR,KAAK,GACL,OAAO,GACP,MAAM,GACN,QAAQ,GACR,OAAO,GACP,aAAa,GACb,MAAM,GACN,QAAQ,GACR,OAAO,GACP,UAAU,GACV,OAAO,GACP,OAAO,GACP,SAAS,GACT,SAAS,GACT,MAAM,GACN,QAAQ,GACR,QAAQ,GACR,QAAQ,GACR,QAAQ,GACR,MAAM,GACN,MAAM,GACN,OAAO,GACP,KAAK,GACL,OAAO,GACP,UAAU,GACV,SAAS,GACT,MAAM,GACN,OAAO,GACP,SAAS,GACT,KAAK,GACL,SAAS,GACT,SAAS,GACT,OAAO,GACP,MAAM,GACN,MAAM,GACN,OAAO,GACP,QAAQ,GACR,SAAS,GACT,QAAQ,GACR,WA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W,GACX,aAAa,CAAC"}
|
package/lib/lark/webhook.js
CHANGED
|
@@ -1,23 +1 @@
|
|
|
1
|
-
import
|
|
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 };
|
|
1
|
+
import{fetchJson as r}from"@secret-momo/utils";import{buildErrorCard as o}from"./helper.js";async function n(e,t){return await r(t??process.env.LARK_WEBHOOK_URL??"",{method:"POST",body:JSON.stringify({msg_type:"text",content:{text:e}})})}async function s(e,t){return await r(t??process.env.LARK_WEBHOOK_URL??"",{method:"POST",body:JSON.stringify({msg_type:"interactive",card:e})})}async function a(e,t){return await r(t??process.env.LARK_WEBHOOK_URL??"",{method:"POST",body:JSON.stringify({msg_type:"interactive",card:o(e)})})}export{s as webhookSendCardMessage,a as webhookSendErrorCardMessage,n as webhookSendTextMessage};
|
package/lib/telegram/index.js
CHANGED
|
@@ -1,27 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
function e(text) {
|
|
4
|
-
return text.replace(/[_*[\]()~`>#+\-=|{}.!]/g, "\\$&");
|
|
5
|
-
}
|
|
6
|
-
async function sendMessage(text) {
|
|
7
|
-
const token = process.env.TELEGRAM_BOT_TOKEN;
|
|
8
|
-
const url = `https://api.telegram.org/bot${token}/sendMessage`;
|
|
9
|
-
const res = await fetch(url, {
|
|
10
|
-
method: "POST",
|
|
11
|
-
headers: { "Content-Type": "application/json" },
|
|
12
|
-
body: JSON.stringify({
|
|
13
|
-
chat_id: process.env.TELEGRAM_GROUP_ID,
|
|
14
|
-
text,
|
|
15
|
-
parse_mode: "MarkdownV2",
|
|
16
|
-
disable_web_page_preview: true,
|
|
17
|
-
disable_notification: true
|
|
18
|
-
})
|
|
19
|
-
});
|
|
20
|
-
const { ok, status, statusText } = res;
|
|
21
|
-
if (!ok) {
|
|
22
|
-
logger.child({ name: "telegram" }).warn(`send message(${text}) failed: ${status} ${statusText}`);
|
|
23
|
-
}
|
|
24
|
-
return res.json();
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export { e, sendMessage };
|
|
1
|
+
import{fetch as r,logger as i}from"@secret-momo/utils";function d(e){return e.replace(/[_*[\]()~`>#+\-=|{}.!]/g,"\\$&")}async function p(e){const a=`https://api.telegram.org/bot${process.env.TELEGRAM_BOT_TOKEN}/sendMessage`,t=await r(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({chat_id:process.env.TELEGRAM_GROUP_ID,text:e,parse_mode:"MarkdownV2",disable_web_page_preview:!0,disable_notification:!0})}),{ok:s,status:n,statusText:o}=t;return s||i.child({name:"telegram"}).warn(`send message(${e}) failed: ${n} ${o}`),t.json()}export{d as e,p as sendMessage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../../src/telegram/index.test.ts"],"names":[],"mappings":""}
|