当前位置:网站首页>Golang access pin notification
Golang access pin notification
2022-06-09 12:28:00 【raoxiaoya】
Setting and access
1、 Create a nail group
2、 Open group settings , Intelligent group assistant , Add robots , Customize Webhook Access
3、 Set the robot name , Enable message push , Copy Webhook Address
4、 Security Settings , Choose a custom keyword , Up to ten... Can be added
Send a message
use post Send a request to the address copied above
Message protocol :https://open.dingtalk.com/document/robots/message-types-and-data-format
/* -- @Time : 2022/6/8 11:24 -- @Author : raoxiaoya -- @Desc : */
package dingtalk
import (
"encoding/json"
"errors"
"voteapi/pkg/curl"
)
type Response struct {
Errcode int
Errmsg string
}
const KeywordMonitor = "Monitor"
const MessageRobot = "https://oapi.dingtalk.com/robot/send?access_token=xxxxxxxxxxxxxxxxxxxx"
// Send simple text message
func SendDingTalkMessage(messageContent, messagePrefix string) (err error) {
defer func() {
if er := recover(); er != nil {
err = errors.New("SendDingTalkMessage panic")
}
}()
headers := map[string]string{
"Content-Type": "application/json",
}
text := map[string]string{
"content": messagePrefix + ": " + messageContent,
}
postData := map[string]interface{
}{
"msgtype": "text",
"text": text,
}
body, _ := json.Marshal(postData)
resp, err := curl.HttpRequest(MessageRobot, "POST", headers, string(body))
if err != nil {
return err
}
var re Response
_ = json.Unmarshal([]byte(resp), &re)
if re.Errcode > 0 {
return errors.New(resp)
}
return nil
}
call
dingtalk.SendDingTalkMessage(fmt.Sprintf("service [%s] reboot success", v.Name), dingtalk.KeywordMonitor)
边栏推荐
- Fairness through awareness
- IPO,联结一切的桥梁
- Redis数据结构与介绍
- L'ouverture d'un compte à terme est - elle fiable et sécurisée??
- 09 | the fourth step: the construction and delivery of the middle office
- MySQL 乐观锁、悲观锁、多粒度锁
- Range方法返回对象转换办法
- 死锁的排查工具有哪些?
- Common laboratory tools | preparation of experimental solution | molarity calculator
- Error in library(patRoon) : 不存在叫‘patRoon‘这个名字的程辑包
猜你喜欢
![[data center stage] 00 opening words data center stage, is it a trap? Or the golden key?](/img/19/256cdcf783986d1012ddc75c8b2c31.png)
[data center stage] 00 opening words data center stage, is it a trap? Or the golden key?
玩转Web3:创建属于自己的ERC-721(NFT)

请你说说乐观锁和悲观锁,以及适用场景
Play with Web3: create your own erc-721 (NFT)

Xiemengjun: China's go language leader in the fifth year of entrepreneurship

13.<tag-二叉树和BST基础>lt.450. 删除二叉搜索树中的节点 dbc

柴云鹏:创新能力的培养至关重要|OceanBase 数据库大赛访谈

Zotero | Literature Association

Relay alphafold! Star pharmaceutical science and technology released a new era of tbind opening molecular protein complex structure prediction

flutter Dio示例
随机推荐
PMP项目管理知识体系
Smart contract security guide for Web3 project
SIGIR 2022 | CMI:结合对比学习和多兴趣挖掘的微视频推荐
Zotero | 文献关联
7. < tag backtracking and subset problem > lt.70 Subset + lt.90 Subset II
清空表格选中项clearSelection
马斯克 “取消交易”威胁奏效 推特同意开放数据库供其核查
Redission 使用
2022年理财产品还有保本保息的吗?我想投资理财但怕赔钱
tag贪心-刷题预备知识-贪心解题方法 + lt.455. 分发饼干 + lt.376. 摆动序列
Google Chrome plugin | pagenote page tag
接力AlphaFold!星药科技重磅发布TBind-开启分子蛋白复合物结构预测新纪元
Do you dare to deliver your microservices independently?
UDP可靠性实践
6. exchange the nodes in the linked list in pairs
7.<tag-回溯和子集问题>lt.70.子集 + lt.90.子集 II
【管理知多少】中文“其他”、英文“OTHER”、日文“その他”.......
flutter Dio示例
【堆排|快排】Top-k问题
内核中_init,_exit中的作用