fix: update .env.example
This commit is contained in:
parent
838171e62a
commit
7d1f9bed86
@ -1,4 +1,4 @@
|
|||||||
BOTS='TELEGRAM'
|
BOTS='TELEGRAM,FEISHU'
|
||||||
FEISHU_TOKEN=''
|
FEISHU_BOT_URL=''
|
||||||
TELEGRAM_TOKEN=''
|
TELEGRAM_TOKEN=''
|
||||||
TELEGRAM_CHAT_ID=''
|
TELEGRAM_CHAT_ID=''
|
@ -1,8 +1,11 @@
|
|||||||
# 腾讯兔小巢 Webhooks
|
# 腾讯兔小巢 Webhooks
|
||||||
接入飞书群机器人到腾讯兔小巢,当有新反馈时自动推送消息到飞书群机器人
|
接入 webhook 到腾讯兔小巢,当有新反馈时自动推送消息到飞书群机器人,Telegram bot
|
||||||
|
|
||||||
## 如何使用
|
## 如何使用
|
||||||
- 在飞书新建一个群机器人,复制群机器人的 webhook 地址,详情见 [飞书开放平台·自定义机器人指南](https://open.feishu.cn/document/ukTMukTMukTM/ucTM5YjL3ETO24yNxkjN)
|
- 将 `.env.example` 重命名为 `.env.local`,`BOTS` 选项设置你需要接入的机器人,用逗号隔开 `FEISHU_BOT_URL`修改为你自己飞书群机器人的 webhook url,同样,`TELEGRAM_TOKEN` 和 `TELEGRAM_CHAT_ID` 修改为你的 telegram bot
|
||||||
- 将 `.env.example` 重命名为 `.env.local`,`FEISHU_token`修改为你自己的群机器人 webhook TOKEN
|
|
||||||
- 点击右侧按钮一键部署到 Vercel [![Deploy](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https://github.com/tyanbiao/txc-webhooks.git)
|
- 点击右侧按钮一键部署到 Vercel [![Deploy](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https://github.com/tyanbiao/txc-webhooks.git)
|
||||||
- 在腾讯兔小巢中配置 Webhooks,`${your domain}/hooks/${product name}`,参考 [腾讯兔小巢·配置 Webhooks](https://txc.qq.com/helper/webHookGuide)
|
- 在腾讯兔小巢中配置 Webhooks,`${your domain}/hooks/${product name}`,参考 [腾讯兔小巢·配置 Webhooks](https://txc.qq.com/helper/webHookGuide)
|
||||||
|
|
||||||
|
## 如何创建机器人
|
||||||
|
- 飞书: [飞书开放平台·自定义机器人指南](https://open.feishu.cn/document/ukTMukTMukTM/ucTM5YjL3ETO24yNxkjN)
|
||||||
|
- Telegram: [How do I create a bot?](https://core.telegram.org/bots#3-how-do-i-create-a-bot)
|
@ -34,7 +34,7 @@ function handleMessage(name: string, data: any): string {
|
|||||||
return `${name}有${action}: ${content}`
|
return `${name}有${action}: ${content}`
|
||||||
}
|
}
|
||||||
|
|
||||||
function main(req: VercelRequest, res: VercelResponse) {
|
async function main(req: VercelRequest, res: VercelResponse) {
|
||||||
if (req.method !== 'POST') {
|
if (req.method !== 'POST') {
|
||||||
res.setHeader('Allow', 'POST')
|
res.setHeader('Allow', 'POST')
|
||||||
return res.status(405).end('Method Not Allowed')
|
return res.status(405).end('Method Not Allowed')
|
||||||
@ -44,10 +44,10 @@ function main(req: VercelRequest, res: VercelResponse) {
|
|||||||
const product = req.query.product.toString() || 'Unknown'
|
const product = req.query.product.toString() || 'Unknown'
|
||||||
const content = handleMessage(product, req.body)
|
const content = handleMessage(product, req.body)
|
||||||
if (bots.indexOf('TELEGRAM') >= 0) {
|
if (bots.indexOf('TELEGRAM') >= 0) {
|
||||||
sendToTelegram(content)
|
await sendToTelegram(content)
|
||||||
}
|
}
|
||||||
if (bots.indexOf('FEISHU') >= 0) {
|
if (bots.indexOf('FEISHU') >= 0) {
|
||||||
sendToFeishu(content)
|
await sendToFeishu(content)
|
||||||
}
|
}
|
||||||
return res.status(200).end('ok')
|
return res.status(200).end('ok')
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import fetch from 'node-fetch'
|
import fetch from 'node-fetch'
|
||||||
|
|
||||||
export async function sendToFeishu(content: string) {
|
export async function sendToFeishu(content: string) {
|
||||||
const URL = `https://open.feishu.cn/open-apis/bot/v2/hook/${process.env.FEISHU_TOKEN}`
|
const URL = process.env.FEISHU_BOT_URL
|
||||||
const body = JSON.stringify({
|
const body = JSON.stringify({
|
||||||
"msg_type": "text",
|
"msg_type": "text",
|
||||||
"content": {
|
"content": {
|
||||||
|
Loading…
Reference in New Issue
Block a user