forked from Dmaina5054/InfluxLarkbot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlarkconn.py
64 lines (43 loc) · 1.02 KB
/
larkconn.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import requests
import json
import time
import os
from dotenv import load_dotenv
import asyncio
from redis import Redis
from worklist import *
redisclient = Redis(db=1)
load_dotenv()
webhookurl = os.getenv('webhookurl')
def sendalert(data):
modifieddata = data
payload = json.dumps({
"msg_type": "post",
"content": {
"post": {
"en_us": {
#"title": f"{data.split(' ')[0]} 2218 Offline Issue",
"title":"OFFLINE BUILDINGS AS PER IAP PING STATUS",
"content": [
[
{
"tag": "text",
#"text": f"""{data}"""
"text": f"""{modifieddata}"""
},
]
]
}
}
}
})
headers = {
'Content-Type': 'application/json'
}
if len(data) == 0:
print('Nothing to send')
else:
#print(data)
return requests.request("POST", webhookurl, headers=headers, data=payload)
#print(data)
#print(f'Alerted {data}')