当前位置:网站首页>Teach you to build a nail warning robot hand in hand
Teach you to build a nail warning robot hand in hand
2022-07-27 08:03:00 【Shenzhi Kalan Temple】
Abstract
With the continuous increase of production and on-line business and the increasing demand for unattended , The emergence of nail warning robot has greatly solved our problem . This paper starts from 0 To 1 Introduce and explain in detail the construction and customization of the nail early warning robot , It is divided into robot construction , Early warning content development , Three steps for online deployment
Robot building
All the following configuration development comes from Nail official website documents , If you like to read the official website or have further personalized needs, you can go to check , You can also build it step by step from the perspective of junior developers with the essayist
The first is to have a group and you have the permission to add robots to this group , then
- Add robots
Group settings -- Intelligent group assistant -- Add robots -- Customize , Select Add , Then make the relevant settings

- Set up the robot

Start with a nice name , There are three security settings , There must be at least one
- Custom keywords : Customize the keywords of sending content , The content sent will only be sent if it contains the set keywords
- The signature of the : That is encryption , Generally, this one is used more ,
- IP Address : It's easy to understand , specific IP You can send content
Here we choose the second countersign , Then click Add , Here the group will prompt you that you have successfully added a robot
We open the robot and save the two data , Namely Webhook token And the countersigned ciphertext
https://oapi.dingtalk.com/robot/send?access_token=xxxxxxxxxxxWebhook: https://oapi.dingtalk.com/robot/send?access_token=xxxxxxxxxxx
The signature of the :yyyyyyyyyyyyyyyyyyy
these two items. xxxxxx and yyyyy Keep it in reserve
Early warning content development
The above robots are added , Equivalent to a receiving data API The interface is ready , We are now developing early warning content
Use the simplest python, The overall framework code is as follows
from datetime import datetime, timedelta
import requests
import hmac
import hashlib
import base64
import urllib.parse
import urllib.request
import json
import time
import os
import sys
import re
def getUrl(secret,access_token):
timestamp = str(round(time.time() * 1000))
secret_enc = secret.encode('utf-8')
string_to_sign = '{}\n{}'.format(timestamp, secret)
string_to_sign_enc = string_to_sign.encode('utf-8')
hmac_code = hmac.new(secret_enc, string_to_sign_enc, digestmod=hashlib.sha256).digest()
sign = urllib.parse.quote_plus(base64.b64encode(hmac_code))
url = "https://oapi.dingtalk.com/robot/send?access_token=%s&sign=%s×tamp=%s" % (access_token, sign, timestamp)
return url
def sendToGroup(url,header,data):
sendData = json.dumps(data)# Convert dictionary type data to json Format
sendData = sendData.encode("utf-8") # python3 Of Request requirement data by byte type
request = urllib.request.Request(url=url, data=sendData, headers=header)
opener = urllib.request.urlopen(request)
return opener
secret= ''
access_token=''
data={
"msgtype": "text",
"text": {
"content": " The analysis task has been completed "
},
"at": {
"atMobiles": ["13216816870"],
"isAtAll": False
}
}
header = {
"Content-Type": "application/json",
"Charset": "UTF-8"
}
url=getUrl(secret,access_token)
opener=sendToGroup(url,header,data)Put the above xxxx and yyyy Put it in the code secret and access_token, Can run , The nail robot will pop up

What the whole content needs to be developed is in the code data Which part
Our common query is through the database , So we also connect to the database to query , Add one more sql function code
def exeSqlRes(dbip,dbport,dbacco,dbpwd,dbname,sql):
conn = connect(host=dbip, port=dbport, user=dbacco, password=dbpwd, database=dbname)
cursor = conn.cursor()
try:
cursor.execute(sql)
list1 = cursor.fetchall()
global dataStr1,dataStr2
dataStr1 = " In line operation date :%s" % (list1[0][0])
dataStr2 = " Public offering operation date :%s" % (list1[1][0])
except:
print(" Database connection failed \n")
conn.close()
sql = '''
SELECT SZ_TO_CHAR_D(max(d_date),'YYYYMMDD') as SYSTEMDATE from datacollect_log
union all
SELECT SZ_TO_CHAR_D(max(d_date),'YYYYMMDD') as SYSTEMDATE from datacollect_log
)
'''
exeSqlRes('xx.xx.xx.xx',3306,'xxxxx','xxxxx','xxxxx',sql)data The official website of nailing introduces a lot , Yes txt,json,xml etc. , Limited to space , Here we only list the most commonly used MARKDOWN form
data = {
"msgtype": "markdown",
"markdown": {
"title":" Data monitoring ",
"text": "#### Current data run date @17665011132 \n > - **%s** \n > - **%s** \n > \n > ###### %s Release [ Check the details ](https://www.dingtalk.com) \n" % (dataStr1,dataStr2,timeStr)
},
"at": {
"atMobiles": [
"176xxxx1132"
],
"atUserIds": [
""
],
"isAtAll": "false"
}
}You can do it according to your actual needs data Development , After I finish the development here, the code pops up

All configurations are completed
Online deployment
Put this python Put the code in crontab It can be scheduled to run on demand
*/10 * * * * /bisz/python/anaconda3/bin/python /bisz/python/DingDingSend.py
边栏推荐
- Stored procedure test 1 -- first acquaintance of love
- Opengauss stopped from the library and found that the main library could not write data
- Comprehensive cases
- Dasctf2022.07 enabling game password WP
- Do me a favor ~ don't pay attention, don't log in, a questionnaire in less than a minute
- HU相关配置
- Redisson 3.17.5 发布,官方推荐的 Redis 客户端
- Solid smart contract development - 3.3-solid syntax control structure
- 大家节日快乐哈
- Methods of server network testing
猜你喜欢

【Day42 文献精读】A Bayesian Model of Perceived Head-Centered Velocity during Smooth Pursuit Eye Movement

Framework of electronic mass production project -- basic idea

【飞控开发基础教程4】疯壳·开源编队无人机-串口(光流数据获取)

HU相关配置

Happy holidays, everyone

一段平平无奇的秋招经历

擎创科技加入龙蜥社区,共建智能运维平台新生态

Enhancement: BTE process introduction

企业架构驱动的数字化转型!
![API version control [eolink translation]](/img/3a/8a78e57a2474f33d011d91631fde74.jpg)
API version control [eolink translation]
随机推荐
Redisson 3.17.5 发布,官方推荐的 Redis 客户端
Lua iterator
如何在 60 秒内去分析和定位问题?
软件调优方法有哪些?看看飞腾技术专家怎么说 | 龙蜥技术
大家节日快乐哈
如何获取广告服务流量变现数据,助力广告效果分析?
Why do major domestic manufacturers regard cloud computing as a pastry? Do you really understand this trillion market
Demo:pa30 Bank Country Code default CN enhancement
10000 word parsing MySQL index principle -- InnoDB index structure and reading
DEMO:ST05 找文本ID 信息
What are the software tuning methods? Let's see what Feiteng technology experts say about dragon lizard technology
"Intermediate and advanced test questions": what is the implementation principle of mvcc?
RPC remote procedure call
Day111. Shangyitong: integrate nuxt framework, front page data, hospital details page
How to obtain the cash flow data of advertising services to help analyze the advertising effect?
[flight control development foundation tutorial 4] crazy shell · open source formation UAV - serial port (optical flow data acquisition)
Day111.尚医通:集成NUXT框架、前台页面首页数据、医院详情页
How does slf4j configure logback?
Shell script learning day01
How to log in multiple wechat on the computer