-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscriptv1_2OOP.py
More file actions
83 lines (65 loc) · 2.02 KB
/
scriptv1_2OOP.py
File metadata and controls
83 lines (65 loc) · 2.02 KB
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import win32com.client
import urllib.parse
from pyshorteners import Shortener
import requests
class CC_to_BZscript:
def get_body(self):
application = win32com.client.Dispatch('Outlook.Application')
namespace = application.GetNamespace('MAPI')
inbox_folder = namespace.GetDefaultFolder(6)
inbox = inbox_folder.Folders
example_folder = inbox["Centercode Projects"]
example_example_folder = example_folder.Folders["Folder Name"]
messages = example_example_folder.Items
messages.Sort("[ReceivedTime]", False)
message = messages.GetLast()
query = message.Body
return query
def dothesplits(self):
query = CC_to_BZscript.get_body(self)
query = query.split("Triage")[0]
summary = query.split("Summary:")[1]
summary_mid = summary.split("Details and")[0]
summary_fin = urllib.parse.quote(summary_mid)
return summary_fin
def return_body(self):
query = CC_to_BZscript.get_body(self)
formatted = urllib.parse.quote(query)
return formatted
def construct_url(self):
url = "Bugzilla Template with concactenated variables"
for i in range(0,100):
while True:
try:
shorten = Shortener('Tinyurl')
url = shorten.short(url)
except requests.exceptions.ReadTimeout:
continue
break
return url
def slackbot(self):
url = CC_to_BZscript.construct_url(self)
query = CC_to_BZscript.get_body(self)
name_beg = query.split("Triage: ")[1]
name = name_beg.split("\r")[0]
slack_name = name[0] + name.split(" ")[1]
slack_name = slack_name.lower()
summary_non_utf = query.split("Summary:")[1]
summ = summary_non_utf.split("Details and")[0]
ID_start = query.split("ID :")[1]
ID_finish = ID_start.split("Incident")[0]
token = "???"
channel_id = "???"
r = requests.post('https://slack.com/api/chat.postMessage',
data={
"token": token,
"channel": channel_id,
"text":
"------------------------------\n"
+ ID_finish
+ summ
+ "Bug URL: " + url
+ "\n" + "<@"+ slack_name +">" +
"\n------------------------------"
}
)