initial slack-bot
This commit is contained in:
30
slack-bot/traffic-scraper/prd/test.py
Normal file
30
slack-bot/traffic-scraper/prd/test.py
Normal file
@@ -0,0 +1,30 @@
|
||||
import json
|
||||
from datetime import datetime
|
||||
|
||||
payload = """{\"attachments\": [\n {\n \"title\": \"{title}",\n \"pretext\": \"Did someone say M62!? \\ud83d\\ude27\",\n \"text\": \"\",\n \"mrkdwn_in\": [\"text\", \"pretext\"],\n \"footer\": \"ec2-54-246-210-90.eu-west-1.compute.amazonaws.com\",\n \"footer_icon\": \"https://i.imgur.com/ADsI87O.png\",\n \"ts\": \"1570917914\",\n \"fields\": [\n\t\t \t{\n\t\t \"title\": \"{congestionTitle}\",\n\t\t \"value\": \"{congestionMessage}\",\n\t\t \"short\": false\n\t\t \t},\n\t\t \t{\n\t\t \"title\": \"{accidentTitle}\",\n\t\t \"value\": \"{accidentMessage}\",\n\t\t \"short\": false\n\t\t \t},\n\t \t\t{\n\t\t \"title\": \"\",\n\t\t \"value\": \"{end} \",\n\t\t \"short\": false\n\t\t \t}\n\t \t]\n }\n ]\n}"""
|
||||
|
||||
timeNow = datetime.now().timestamp()
|
||||
|
||||
jsonPayload = json.loads(payload)
|
||||
print(jsonPayload)
|
||||
|
||||
jsonPayload['attachments'][0]['title'] = f'{messageTitle}'
|
||||
print(jsonPayload['attachments'][0]['title'])
|
||||
|
||||
jsonPayload['attachments'][0]['ts'] = timeNow
|
||||
print(jsonPayload['attachments'][0]['ts'])
|
||||
|
||||
jsonPayload['attachments'][0]['fields'][0]['title'] = f'{congestionTitle}'
|
||||
print(jsonPayload['attachments'][0]['fields'][0]['title'])
|
||||
|
||||
jsonPayload['attachments'][0]['fields'][0]['value'] = f'{congestionMessage}'
|
||||
print(jsonPayload['attachments'][0]['fields'][0]['value'])
|
||||
|
||||
jsonPayload['attachments'][0]['fields'][1]['title'] = f'{accidentTitle}'
|
||||
print(jsonPayload['attachments'][0]['fields'][1]['title'])
|
||||
|
||||
jsonPayload['attachments'][0]['fields'][1]['value'] = f'{accidentMessage}'
|
||||
print(jsonPayload['attachments'][0]['fields'][1]['value'])
|
||||
|
||||
jsonPayload['attachments'][0]['fields'][2]['value'] = f'{end}'
|
||||
print(jsonPayload['attachments'][0]['fields'][2]['value'])
|
||||
Reference in New Issue
Block a user