28 lines
No EOL
821 B
TypeScript
28 lines
No EOL
821 B
TypeScript
import { Client } from '@larksuiteoapi/node-sdk';
|
|
import TelegramBot from 'node-telegram-bot-api';
|
|
|
|
export async function sendLarkMessage(receiveId: string, message: string): Promise<any> {
|
|
console.log(process.env.LARK_APP_ID!, process.env.LARK_APP_SECRET!);
|
|
const lark = new Client({
|
|
appId: process.env.LARK_APP_ID!,
|
|
appSecret: process.env.LARK_APP_SECRET!
|
|
});
|
|
|
|
const res = await lark.im.message.create({
|
|
params: {
|
|
receive_id_type: 'chat_id',
|
|
},
|
|
data: {
|
|
receive_id: receiveId,
|
|
content: JSON.stringify({text: message}),
|
|
msg_type: 'text'
|
|
}
|
|
});
|
|
|
|
return { success: true, data: res.data };
|
|
}
|
|
|
|
export function sendTelegramMessage(chatId: string, message: string) {
|
|
const bot = new TelegramBot(process.env.TELEGRAM_BOT_TOKEN!);
|
|
bot.sendMessage(chatId, message);
|
|
} |