initial slack-bot
This commit is contained in:
@@ -4,6 +4,8 @@ from datetime import datetime
|
||||
import re
|
||||
import emoji
|
||||
import random
|
||||
import json
|
||||
import os
|
||||
|
||||
|
||||
class getTrafficInfo(object):
|
||||
@@ -44,9 +46,9 @@ class getTrafficInfo(object):
|
||||
self.motorway = motorway
|
||||
self.incidentTypes = ['congestion', 'accident']
|
||||
|
||||
# def __del__(self):
|
||||
# print('Quitting')
|
||||
# self.browser.quit()
|
||||
def __del__(self):
|
||||
print('Quitting')
|
||||
self.browser.quit()
|
||||
|
||||
@classmethod
|
||||
def getTrafficURL(cls, motorway, driver='chrome'):
|
||||
@@ -140,7 +142,7 @@ class getTrafficInfo(object):
|
||||
),
|
||||
]
|
||||
currentTime = datetime.now().strftime('%H:%M:%S')
|
||||
self.output.append('START')
|
||||
# self.output.append('START')
|
||||
self.output.append(
|
||||
emoji.emojize(
|
||||
f'Did someone say {self.motorway}!?'
|
||||
@@ -182,11 +184,19 @@ class getTrafficInfo(object):
|
||||
except IndexError:
|
||||
pass
|
||||
self.output.append(random.choice(self.sarcasticMessage))
|
||||
self.output.append('END')
|
||||
# self.output.append('END')
|
||||
return self
|
||||
|
||||
def savetoDisk(self, path=os.getcwd()):
|
||||
self.timeNow = datetime.now().strftime('%d-%m-%Y_%H:%M:%S')
|
||||
if len(self.output) > 0:
|
||||
with open(f'{path}/{self.timeNow}.json', 'w+') as outputFile:
|
||||
json.dump(self.output, outputFile)
|
||||
else:
|
||||
print('No messages to save')
|
||||
|
||||
inst = getTrafficInfo.getTrafficURL('M62').findIncidents() \
|
||||
.getIncidentInformation().generateOutput()
|
||||
for i in inst.output:
|
||||
print(i)
|
||||
|
||||
# inst = getTrafficInfo.getTrafficURL('M62').findIncidents() \
|
||||
# .getIncidentInformation().generateOutput()
|
||||
# for i in inst.output:
|
||||
# print(i)
|
||||
|
||||
Reference in New Issue
Block a user