Add dedicated post to slack function.

master
jowj 4 years ago
parent c003f8d6b1
commit 5fdccada37

@ -2,18 +2,27 @@ import os
from pathlib import Path
import slack
slack_token = os.environ.get("SLACK_BOT_TOKEN")
client = slack.WebClient(token=os.environ['SLACK_BOT_TOKEN'])
def post_to_slack(message_list):
if message_list:
client.chat_postMessage(
channel = "#bots-like-gaston",
text = message_list
)
def react_to_monitoring():
results_file = Path("/shared/alerts.log")
does_file_exist = results_file.is_file()
if results_file.is_file():
open_file = open("/shared/alerts.log","r")
open_file = open("/shared/alerts.log", "r")
for line in open_file:
webclient.chat_postMessage(
channel = channel_id,
text = line
)
post_to_slack(line)
os.remove("/shared/alerts.log")
if __name__ == '__main__':
while True:
react_to_monitoring()

Loading…
Cancel
Save