当前位置:网站首页>Actual combat simulation │ real time error alarm of enterprise wechat robot
Actual combat simulation │ real time error alarm of enterprise wechat robot
2022-06-13 10:16:00 【InfoQ】
One 、 Create robots
Selection group
►Right click
►Manage chat messages
►Add swarm robots
- Improve basic robot information , Including head portrait 、 Name, etc



Two 、 Robot configuration description
- Every created robot has a unique
webhook
Address
- Be sure to protect your
webhook
Address , If there is a leak , You can remove the robot , Create a new one to deal with
- Click on
webhook
Address , You can see the documentation , You can also configure common push messages
- The custom push message , There is a detailed description in the robot configuration description column , But you need to develop it yourself


3、 ... and 、 Robot information push
- Current custom robot
Supporting text (text)、markdown(markdown)、 picture (image)、 Image & Text (news)
Four message types
- We just need to follow its documentation , Send a message of the specified type to
webhook
Address to push messages
// Text message type
{
"msgtype": "text",
"text": {
"content": " Today's weather in Guangzhou :29 degree , Most of it is cloudy , Probability of rainfall :60%",
"mentioned_list":["wangqing","@all"],
"mentioned_mobile_list":["13800001111","@all"]
}
}
// markdown Message type
{
"msgtype": "markdown",
"markdown": {
"content": " Real time new user feedback <font color=\"warning\">132 example </font>, Please pay attention to .\n
> type :<font color=\"comment\"> User feedback </font>
> General user feedback :<font color=\"comment\">117 example </font>
>VIP User feedback :<font color=\"comment\">15 example </font>"
}
}
// Picture message type
{
"msgtype": "image",
"image": {
"base64": "DATA",
"md5": "MD5"
}
}
// Graphic message type
{
"msgtype": "news",
"news": {
"articles" : [
{
"title" : " Receiving gifts for Mid Autumn Festival ",
"description" : " This year's Mid Autumn Festival, the company will give you a gift ",
"url" : "www.qq.com",
"picurl" : "http://res.mail.qq.com/node/ww/wwopenmng/images/independent/doc/test_pic_msg1.png"
}
]
}
}
Four 、 Error alert push
- Here we use
Thinkphp
Framework for example , Integrate error alerts into the project , Realize real-time error push
- First, in the
config
Add error handling classes to the configuration file , Which file to execute to handle errors
- When the configuration is complete , When a project encounters an error , The program will go through the specified file to process
- Then improve the error push warning logic in the file , Generally, error pre-warning uses
markdown
Type
'exception_handle' => '\\app\\common\\exception\\WorkWx',
<?php
namespace app\common\exception;
use Exception;
use itbdw\Ip\IpLocation;
use app\common\util\Helper;
use think\exception\Handle;
use think\exception\HttpException;
use think\exception\ValidateException;
class WorkWx extends Handle
{
const WEBHOOK = ' Fill in your own webhook Address ';
public function render(Exception $e)
{
$clientIP = Helper::getClientIp();
$clientAddress = IpLocation::getLocation($clientIP);
unset($clientAddress['ip']);
$ipAddress = implode('-', $clientAddress);
// Parameter validation error
if ($e instanceof ValidateException) {
$data = [
'msgtype' => 'markdown',
'markdown' => [
'content' => " come from **<font color=\"info\"> eye </font>** A warm reminder of , Please pay attention to .
>** describe :** <font color=\"comment\"> Parameter validation error </font>
>** End IP:** <font color=\"comment\">{$clientIP}</font>
>** Address :** <font color=\"comment\">{$ipAddress}</font>
>** state :** <font color=\"comment\">{$e->getCode()}</font>
>** Row number :** <font color=\"comment\">{$e->getLine()}</font>
>** file :** <font color=\"red\">{$e->getFile()}</font>
>** Tips :** <font color=\"warning\">{$e->getError()}</font>
>** Information :** <font color=\"warning\">{$e->getMessage()}</font>"
]
];
return Helper::postCurl(self::WEBHOOK, json_encode($data));
}
// Request exception
if ($e instanceof HttpException) {
$data = [
'msgtype' => 'markdown',
'markdown' => [
'content' => " come from **<font color=\"info\"> eye </font>** A warm reminder of , Please pay attention to .
>** describe :** <font color=\"comment\"> Request exception </font>
>** End IP:** <font color=\"comment\">{$clientIP}</font>
>** Address :** <font color=\"comment\">{$ipAddress}</font>
>** state :** <font color=\"comment\">{$e->getCode()}</font>
>** Row number :** <font color=\"comment\">{$e->getLine()}</font>
>** file :** <font color=\"red\">{$e->getFile()}</font>
>** Information :** <font color=\"warning\">{$e->getMessage()}</font>"
]
];
return Helper::postCurl(self::WEBHOOK, json_encode($data));
}
// Other errors are handled by the system
return parent::render($e);
}
}

边栏推荐
- ASCII码值是怎么计算的,怎么计算arccos的值
- Tree and binary tree: application of binary tree traversal
- LeetCode 2016. Maximum difference between incremental elements
- SQL Server创建windows登录账户找不到用户或组
- 大O记法解释
- GPIO of hardware schematic diagram
- Execution order of subclass and parent constructor
- [bearing fault decomposition] ITD bearing fault signal decomposition based on MATLAB [including Matlab source code 1871]
- Redis初始安装和使用【玩转华为云】
- 信息文档管理与配置管理
猜你喜欢
go-zero微服务实战系列(三、API定义和表结构设计)
[51nod p3111] xiaoming'ai intercepts [Las]
Pxxx local socket communication
[51nod P3210] binary statistics
Memory management -- Viewing memory space from the perspective of executing programs and processes
C Oracle multi table query
【 ssl2 ⁶⁶⁶⁶⁶⁶⁶⁶⁶⁶⁶⁶⁶⁶⁶⁶⁶⁶⁶83
go-zero微服务实战系列(三、API定义和表结构设计)
C 11 new feature: static abstract members in interfaces
Matplotlib 学习笔记
随机推荐
[ssl1271] sort I [heap]
Install Kubernetes 1.24
Double carbon in every direction: green demand and competition focus in the calculation from the east to the West
多线程 从UE4的无锁队列开始 (线程安全)
Analysis and implementation of variable parameters in C language
Interrupt handling mechanism
记一次水平越权漏洞的利用
Node red series (25): integrate Gaode map and realize 3D map and track playback
Knowledge points of silicon steel sheet
【动态规划】入门篇
[poj1845] sumdiv [number theory]
Learning makefile with me
电解电容、钽电容、普通电容
【轴承故障分解】基于matlab ITD轴承故障信号分解【含Matlab源码 1871期】
[ssl1280] full arrangement
JS local storage
MySQL事务隔离级别和MVCC
SQL server cannot find user or group when creating windows login account
Matlab hub motor analysis fuzzy PID control vertical vibration analysis
Cynthia项目缺陷管理系统