Browse Source

Add dedicated post to slack function.

master
jowj 3 years ago
parent
commit
5fdccada37
  1. 23
      mojo-web/mojo-web.py

23
mojo-web/mojo-web.py

@ -2,18 +2,27 @@ import os
from pathlib import Path
import slack
def react_to_monitoring():
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