fix: 修复bug
This commit is contained in:
parent
d3971b01c7
commit
02e161b97d
@ -1,4 +1,6 @@
|
|||||||
import {VercelRequest, VercelResponse} from '@vercel/node'
|
import {VercelRequest, VercelResponse} from '@vercel/node'
|
||||||
|
import { sendToTelegram } from '../bot/telegram'
|
||||||
|
import { sendToFeishu } from '../bot/feishu'
|
||||||
|
|
||||||
function handleMessage(name: string, data: any): string {
|
function handleMessage(name: string, data: any): string {
|
||||||
let action = ''
|
let action = ''
|
||||||
@ -25,7 +27,9 @@ function handleMessage(name: string, data: any): string {
|
|||||||
content = data?.payload?.reply?.content
|
content = data?.payload?.reply?.content
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
throw new Error('Bad Request')
|
action = data.type
|
||||||
|
content = JSON.stringify(data?.payload)
|
||||||
|
break
|
||||||
}
|
}
|
||||||
return `${name}有${action}: ${content}`
|
return `${name}有${action}: ${content}`
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
async function sendToFeishu(content: string) {
|
import fetch from 'node-fetch'
|
||||||
|
|
||||||
|
export async function sendToFeishu(content: string) {
|
||||||
const URL = `https://open.feishu.cn/open-apis/bot/v2/hook/${process.env.FEISHU_TOKEN}`
|
const URL = `https://open.feishu.cn/open-apis/bot/v2/hook/${process.env.FEISHU_TOKEN}`
|
||||||
const body = JSON.stringify({
|
const body = JSON.stringify({
|
||||||
"msg_type": "text",
|
"msg_type": "text",
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
async function sendToTelegram(text: string) {
|
import fetch from 'node-fetch'
|
||||||
|
export async function sendToTelegram(text: string) {
|
||||||
const URL = `https://api.telegram.org/bot${process.env.TELEGRAM_TOKEN}/sendMessage`
|
const URL = `https://api.telegram.org/bot${process.env.TELEGRAM_TOKEN}/sendMessage`
|
||||||
const body = `chat_id=${process.env.TELEGRAM_CHAT_ID}&text=${text}`
|
const body = `chat_id=${process.env.TELEGRAM_CHAT_ID}&text=${text}`
|
||||||
const res = await fetch(URL, {
|
const res = await fetch(URL, {
|
||||||
|
Loading…
Reference in New Issue
Block a user