当前位置:网站首页>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
边栏推荐
- Interview reply V
- Bash: sudo: command not found in container
- Zero training platform course-1. SQL injection Foundation
- QingChuang technology joined dragon lizard community to build a new ecosystem of intelligent operation and maintenance platform
- Day111.尚医通:集成NUXT框架、前台页面首页数据、医院详情页
- Practical new drug R & D project management platform
- Shell loop exercise
- 将对象转换为键值对
- Why do major domestic manufacturers regard cloud computing as a pastry? Do you really understand this trillion market
- 3D激光SLAM:LeGO-LOAM论文解读---摘要
猜你喜欢

Lua迭代器

API 版本控制【 Eolink 翻译】

Demo submit a program and obtain ALV data of the program

Translation character '/b' in C #

QingChuang technology joined dragon lizard community to build a new ecosystem of intelligent operation and maintenance platform

Abstract factory pattern

帮个忙呗~不关注不登录,不到一分钟的一个问卷

How to obtain the cash flow data of advertising services to help analyze the advertising effect?

Comprehensive cases

Lu Xun: I don't remember saying it, or you can check it yourself!
随机推荐
孙子出题难,儿子监考严。老子不会做,还我上学钱
Prevent cookies from modifying ID to cheat login
C language: random generated number + insertion sort
Chromedriver download - self use
The code interface is a little automated
Interview reply V
What is a rebound shell? What's the use of bouncing shells?
Translation character '/b' in C #
The seta 2020 international academic conference will be held soon. Welcome to attend!
JS access cookie example
What is the real HTAP? (1) Background article
Enhancement: BTE process introduction
Opengauss stopped from the library and found that the main library could not write data
Want the clouds in the picture to float? Video editing services can be achieved in three steps with one click
Lu Xun: I don't remember saying it, or you can check it yourself!
MCU multi-level menu
实用的新药研发项目管理平台
Stored procedure trial 2 -- establish a test table to test different types of stored procedures
容器内使用sudo报错bash: sudo: command not found解决
How to log in multiple wechat on the computer