2 import paho
.mqtt
.client
as mqtt
3 import paho
.mqtt
.publish
as publish
10 #$MQTTADDR $MQTTPORT $MQTTTOPIC "https://xxxx" "air101" DD_APPKEY DD_APPSECRET DD_NOTIFY_LIST DD_API_TOKEN DD_API_SEND
11 # 1 2 3 4 5 6 7 8 9 10
16 ############# MQTT ###############
17 # client = mqtt.Client()
20 # client.connect(sys.argv[1], int(sys.argv[2]), 60)
21 # #topic请根据需要自行修改,需要传入参数
22 # info = sys.argv[4]+"\r\n"+str(repo.head.commit.author)+"-"+str(repo.head.commit.message)
23 # if len(sys.argv) >= 6:
24 # repo = Repo("../../"+sys.argv[5])
25 # info = info+"\r\n子仓库"+sys.argv[5]+"最后提交:\r\n"+str(repo.head.commit.author)+"-"+str(repo.head.commit.message)
26 # pub = client.publish(sys.argv[3],info)
27 # pub.wait_for_publish()
30 # except Exception as e:
34 ###############钉钉提醒######################
36 dd_appkey
= sys
.argv
[6]
37 dd_appsecret
= sys
.argv
[7]
38 dd_list
= sys
.argv
[8].split(",")
39 dd_api_token
= sys
.argv
[9]
40 dd_api_send
= sys
.argv
[10]
42 headers
= {'user-agent': '114514'}
43 token
= requests
.post(dd_api_token
,json
={"appKey":dd_appkey
,"appSecret":dd_appsecret
},headers
=headers
).json()["accessToken"]
45 headers
= {'user-agent': '114514', 'x-acs-dingtalk-access-token': token
}
46 r
= requests
.post(dd_api_send
,json
={
47 "robotCode":dd_appkey
,
49 "msgKey" : "sampleLink",
50 "msgParam" : json
.dumps({
51 "title": sys
.argv
[5]+"的编译炸了",
52 "text": "最后提交:"+str(repo
.head
.commit
.author
)+"\r\n"+str(repo
.head
.commit
.message
),
53 "messageUrl": sys
.argv
[4],
54 "picUrl": "https://www.luatos.com/img/footer-logo.png",
60 except Exception as e
: