Merge pull request #29 from ChowRex/main

Add Wechat Work Group bot example
This commit is contained in:
naiba 2023-03-08 11:06:58 +08:00 committed by GitHub
commit c7e8ab9e04
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 122 additions and 16 deletions

View File

@ -34,7 +34,6 @@ Refer to the example below, it is very flexible.
- Notes for this methodThe XXXXXX in botXXXXXX is the token provided when you follow the official @Botfather in Telegram and enter /newbot to create a new bot. (In the line after _Use this token to access the HTTP API_). The 'bot' are essential. After creating a bot, you need to talk to the BOT in Telegram (send a random message) before you can send a message by using API. YYYYYY is Telegram user's ID, you can get it by talking to the bot @userinfobot. - Notes for this methodThe XXXXXX in botXXXXXX is the token provided when you follow the official @Botfather in Telegram and enter /newbot to create a new bot. (In the line after _Use this token to access the HTTP API_). The 'bot' are essential. After creating a bot, you need to talk to the BOT in Telegram (send a random message) before you can send a message by using API. YYYYYY is Telegram user's ID, you can get it by talking to the bot @userinfobot.
- **Email notification example - Outlook, contributed by [@Cantoblanco](https://github.com/cantoblanco)** - **Email notification example - Outlook, contributed by [@Cantoblanco](https://github.com/cantoblanco)**
- Name: MS Mail Notification - Name: MS Mail Notification
- URLhttps://graph.microsoft.com/v1.0/me/microsoft.graph.sendMail - URLhttps://graph.microsoft.com/v1.0/me/microsoft.graph.sendMail
- Request method: POST - Request method: POST
@ -63,6 +62,60 @@ Refer to the example below, it is very flexible.
- Notes for this method: This method requires calling Microsoft Graph V1.0, you need to go to Microsoft Graph and create your own application, give `Mail.Send` permission and get the Token, or you can go [Microsoft Graph Explorer](https://developer.microsoft.com/en-us/graph/graph-explorer) directly to give permission and get the Token, just replace the Token in the Header with the actual Token. - Notes for this method: This method requires calling Microsoft Graph V1.0, you need to go to Microsoft Graph and create your own application, give `Mail.Send` permission and get the Token, or you can go [Microsoft Graph Explorer](https://developer.microsoft.com/en-us/graph/graph-explorer) directly to give permission and get the Token, just replace the Token in the Header with the actual Token.
- **Wechat Work Group bot Example, contributed by [@ChowRex](https://github.com/ChowRex)**
Support placeholders:
```json
{
"content": "#NEZHA#",
"ServerName": "#SERVER.NAME#",
"ServerIP": "#SERVER.IP#",
"ServerIPV4": "#SERVER.IPV4#",
"ServerIPV6": "#SERVER.IPV6#",
"CPU": "#SERVER.CPU#",
"MEM": "#SERVER.MEM#",
"SWAP": "#SERVER.SWAP#",
"DISK": "#SERVER.DISK#",
"NetInSpeed": "#SERVER.NETINSPEED#",
"NetOutSpeed": "#SERVER.NETOUTSPEED#",
"TransferIn": "#SERVER.TRANSFERIN#",
"TranferOut": "#SERVER.TRANSFEROUT#",
"Load1": "#SERVER.LOAD1#",
"Load5": "#SERVER.LOAD5#",
"Load15": "#SERVER.LOAD15#",
"TCP_CONN_COUNT": "#SERVER.TCPCONNCOUNT", # Invalid
"UDP_CONN_COUNT": "#SERVER.UDPCONNCOUNT", # Invalid
}
```
> Sorry, this document is **NOT** available in English.
>
> [群机器人配置说明 - 文档 - 企业微信开发者中心](https://developer.work.weixin.qq.com/document/path/91770#markdown%E7%B1%BB%E5%9E%8B)
- NameWechatWork Group bot notification
- URLhttps://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=YOUR_BOT_KEY
- Request method: POST
- Request type: JSON
- Body:
```json
{
"msgtype": "markdown",
"markdown": {
"content": "# Nezha Notification\n\n\"#NEZHA#\"\n\n> ServerName: \"#SERVER.NAME#\"\n> IP: \"#SERVER.IP#\"\n> IPv4: \"#SERVER.IPV4#\"\n> IPv6: \"#SERVER.IPV6#\"\n> CPU: \"#SERVER.CPU#\"\n> Memory: \"#SERVER.MEM#\"\n> SWAP: \"#SERVER.SWAP#\"\n> Storage: \"#SERVER.DISK#\"\n> Real-time Upload: \"#SERVER.NETINSPEED#\"\n> Real-time Download: \"#SERVER.NETOUTSPEED#\"\n> Total Upload: \"#SERVER.TRANSFERIN#\"\n> Total Download: \"#SERVER.TRANSFEROUT#\"\n> 1m Load: \"#SERVER.LOAD1#\"\n> 5m Load: \"#SERVER.LOAD5#\"\n> 15m Load: \"#SERVER.LOAD15#\"\n> TCP Connections: \"#SERVER.TCPCONNCOUNT\"\n> UDP Connections: \"#SERVER.UDPCONNCOUNT\"\n\n"
}
}
```
Delete relevant content information as needed
![Notice Picture](https://user-images.githubusercontent.com/30169860/223605886-b7736825-24b8-4b6c-8bc9-96ac388599ef.png)
<br/> <br/>
<br/> <br/>

View File

@ -49,7 +49,7 @@ URL 里面也可放置占位符,请求时会进行简单的字符串替换。
- URL 参数获取说明botXXXXXX 中的 XXXXXX 是在 telegram 中关注官方 @Botfather ,输入/newbot 创建新的机器人bot会提供的 token在提示 Use this token to access the HTTP API:后面一行)这里 'bot' 三个字母不可少。创建 bot 后,需要先在 telegram 中与 BOT 进行对话(随便发个消息),然后才可用 API 发送消息。YYYYYY 是 telegram 用户的数字 ID。与机器人@userinfobot 对话可获得。 - URL 参数获取说明botXXXXXX 中的 XXXXXX 是在 telegram 中关注官方 @Botfather ,输入/newbot 创建新的机器人bot会提供的 token在提示 Use this token to access the HTTP API:后面一行)这里 'bot' 三个字母不可少。创建 bot 后,需要先在 telegram 中与 BOT 进行对话(随便发个消息),然后才可用 API 发送消息。YYYYYY 是 telegram 用户的数字 ID。与机器人@userinfobot 对话可获得。
- **邮件通知示例 - SendCloud 贡献者:[@白歌](https://github.com/cantoblanco)** - **邮件通知示例 - SendCloud 贡献者:[@白歌](https://github.com/cantoblanco)**
**注意SendCloud 有每日免费发送邮件限额限制,这里仅作示例,你可以选择付费服务或其他类似的免费服务,使用方法类似。** **注意SendCloud 有每日免费发送邮件限额限制,这里仅作示例,你可以选择付费服务或其他类似的免费服务,使用方法类似。**
- 名称:邮件告警 - 名称:邮件告警
- URLhttps://api.sendcloud.net/apiv2/mail/send?apiUser=<替换APIUSER>apiKey=<替换APIKEY>&from=<自定义发件邮箱>&fromName=Nezha&to=<自定义收件邮箱>&subject=Nezha-Notification&html=#NEZHA# - URLhttps://api.sendcloud.net/apiv2/mail/send?apiUser=<替换APIUSER>apiKey=<替换APIKEY>&from=<自定义发件邮箱>&fromName=Nezha&to=<自定义收件邮箱>&subject=Nezha-Notification&html=#NEZHA#
@ -57,8 +57,61 @@ URL 里面也可放置占位符,请求时会进行简单的字符串替换。
- 请求类型: JSON - 请求类型: JSON
- Header: 留空 - Header: 留空
- Body: 留空 - Body: 留空
- URL 参数获取说明:此方式需提前在 [SendCloud](https://www.sendcloud.net/) 注册账号,创建发件邮箱,然后在[这里](https://www.sendcloud.net/sendSetting/apiuser)获取 APIUSER 和 APIKEY替换 URL 中的 <替换APIUSER><替换APIKEY> 为自己的 APIUSER 和 APIKEY替换 URL 中的 <自定义发件邮箱><自定义收件邮箱> 为自己的发件邮箱和收件邮箱。 - URL 参数获取说明:此方式需提前在 [SendCloud](https://www.sendcloud.net/) 注册账号,创建发件邮箱,然后在[这里](https://www.sendcloud.net/sendSetting/apiuser)获取 APIUSER 和 APIKEY替换 URL 中的 <替换APIUSER><替换APIKEY> 为自己的 APIUSER 和 APIKEY替换 URL 中的 <自定义发件邮箱><自定义收件邮箱> 为自己的发件邮箱和收件邮箱。
- **企业微信 群机器人 示例 贡献者:[@ChowRex](https://github.com/ChowRex)**
支持的占位符一览
```json
{
"content": "#NEZHA#",
"ServerName": "#SERVER.NAME#",
"ServerIP": "#SERVER.IP#",
"ServerIPV4": "#SERVER.IPV4#",
"ServerIPV6": "#SERVER.IPV6#",
"CPU": "#SERVER.CPU#",
"MEM": "#SERVER.MEM#",
"SWAP": "#SERVER.SWAP#",
"DISK": "#SERVER.DISK#",
"NetInSpeed": "#SERVER.NETINSPEED#",
"NetOutSpeed": "#SERVER.NETOUTSPEED#",
"TransferIn": "#SERVER.TRANSFERIN#",
"TranferOut": "#SERVER.TRANSFEROUT#",
"Load1": "#SERVER.LOAD1#",
"Load5": "#SERVER.LOAD5#",
"Load15": "#SERVER.LOAD15#",
"TCP_CONN_COUNT": "#SERVER.TCPCONNCOUNT", # 无效
"UDP_CONN_COUNT": "#SERVER.UDPCONNCOUNT", # 无效
}
```
> [群机器人配置说明 - 文档 - 企业微信开发者中心](https://developer.work.weixin.qq.com/document/path/91770#markdown%E7%B1%BB%E5%9E%8B)
- 名称:企业微信群机器人
- URLhttps://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=YOUR_BOT_KEY
- 请求方式: POST
- 请求类型: JSON
- Body:
```json
{
"msgtype": "markdown",
"markdown": {
"content": "# 哪吒通知消息\n\n\"#NEZHA#\"\n\n> 名称: \"#SERVER.NAME#\"\n> IP: \"#SERVER.IP#\"\n> IPv4: \"#SERVER.IPV4#\"\n> IPv6: \"#SERVER.IPV6#\"\n> CPU: \"#SERVER.CPU#\"\n> 内存: \"#SERVER.MEM#\"\n> 交换分区: \"#SERVER.SWAP#\"\n> 存储: \"#SERVER.DISK#\"\n> 实时上传速度: \"#SERVER.NETINSPEED#\"\n> 实时下载速度: \"#SERVER.NETOUTSPEED#\"\n> 总上传: \"#SERVER.TRANSFERIN#\"\n> 总下载: \"#SERVER.TRANSFEROUT#\"\n> 1分钟内负载: \"#SERVER.LOAD1#\"\n> 5分钟内负载: \"#SERVER.LOAD5#\"\n> 15分钟内负载: \"#SERVER.LOAD15#\"\n> TCP连接数: \"#SERVER.TCPCONNCOUNT\"\n> UDP连接数: \"#SERVER.UDPCONNCOUNT\"\n\n"
}
}
```
根据需求删减相关内容信息即可
![通知效果](https://user-images.githubusercontent.com/30169860/223605620-eac53ee6-09f9-4583-94fa-9b0cdedba81c.png)
<br/> <br/>
<br/> <br/>