def alert_error(slack_config): slack_messenger = SlackMessenger(slack_config["alert_slack_token"], slack_config["alert_channel"], slack_config["alert_slackbot_name"]) slack_messenger.notify( slack_config["alert_list"], "Internal error for Battery Notifier, please check the logs.")
def alert_battery_level(slack_config, alert_level): slack_messenger = SlackMessenger(slack_config["alert_slack_token"], slack_config["alert_channel"], slack_config["alert_slackbot_name"]) slack_messenger.notify( slack_config["alert_list"], "Laptop battery is below " + str(alert_level) + "%.")
def report_result(result): s = SlackMessenger(report_slack_token, report_channel, report_slackbot_name) result_body = "Response body:\n```\n" + \ json.dumps(result, indent=4, sort_keys=True) + "\n```" if result.get("ok"): s.operation_report("*SUCCESS*", "Sent message to channel. " + \ result_body) else: s.operation_report("*ERROR*", "Failed to send message to " +\ "Slack channel." + result_body) s.notify(report_alert_list, "Internal error, please check the logs.")
def slack_notify_users(alert_users, message_text): if report: s = SlackMessenger(report_slack_token, report_channel, report_slackbot_name) s.notify(alert_users, message_text) Logger.debug("Slack alert sent.")