-
Notifications
You must be signed in to change notification settings - Fork 0
/
TeamsMessaging.py
55 lines (50 loc) · 1.87 KB
/
TeamsMessaging.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
import requests
class TeamsMessaging:
def __init__(self, teams_webhooks):
self.schedule_webhook = teams_webhooks["schedule_webhook"]
self.success_webhook = teams_webhooks["success_webhook"]
self.failure_webhook = teams_webhooks["failure_webhook"]
self.info_webhook = teams_webhooks["info_webhook"]
def send_schedule_message(self, message):
headers = {
'Content-Type': 'application/json'
}
# body = {
# "text":"<p style=\"color:amber;\"> Perf Test run on Trio scheduled by v-sigop </p>"
# }
body = {
'text':'AUTO :' + '<p style=\"color:amber\">' + message +'</p>'
}
r = requests.post(self.schedule_webhook,headers=headers,json=body)
print r.status_code
print r.text
def send_success_message(self, message):
headers = {
'Content-Type': 'application/json'
}
body = {
'text':'AUTO :' + '<p style=\"color:green\">' + message +'</p>'
}
r = requests.post(self.success_webhook,headers=headers,json=body)
print r.status_code
print r.text
def send_failure_message(self, message):
headers = {
'Content-Type': 'application/json'
}
body = {
'text':'AUTO :' + '<p style=\"color:red\">' + message +'</p>'
}
r = requests.post(self.failure_webhook,headers=headers,json=body)
print r.status_code
print r.text
def send_info_message (self, message):
headers = {
'Content-Type': 'application/json'
}
body = {
'text':'AUTO :' + '<p style=\"color:black\">' + message +'</p>'
}
r = requests.post(self.info_webhook,headers=headers,json=body)
print r.status_code
print r.text