diff --git a/fink_fat/slack_bot/slack_bot.py b/fink_fat/slack_bot/slack_bot.py index 5ec43774..8238eeb7 100644 --- a/fink_fat/slack_bot/slack_bot.py +++ b/fink_fat/slack_bot/slack_bot.py @@ -1,18 +1,16 @@ from slack_sdk import WebClient from slack_sdk.errors import SlackApiError -import configparser -import time import os from fink_fat.others.utils import init_logging -def init_slackbot()->WebClient: +def init_slackbot() -> WebClient: try: - token_slack = os.environ['ANOMALY_SLACK_TOKEN'] - except KeyError as ke: - l = init_logging() - l.error("ANOMALY_SLACK_TOKEN environement variable not found !!", exc_info=1) + token_slack = os.environ["ANOMALY_SLACK_TOKEN"] + except KeyError: + logger = init_logging() + logger.error("ANOMALY_SLACK_TOKEN environement variable not found !!", exc_info=1) client = WebClient(token=token_slack) return client @@ -21,25 +19,17 @@ def post_msg_on_slack(webclient: WebClient, msg: str): logging = init_logging() try: webclient.chat_postMessage( - channel='#bot_asteroid_test', - text=msg, - blocks=[ - { - "type": "section", - "text": { - "type": "mrkdwn", - "text": msg - } - } - ] - ) + channel="#bot_asteroid_test", + text=msg, + blocks=[{"type": "section", "text": {"type": "mrkdwn", "text": msg}}], + ) logging.info("Post msg on slack successfull") except SlackApiError as e: if e.response["ok"] is False: logging.error("Post slack msg error", exc_info=1) -if __name__ == "__main__": +if __name__ == "__main__": slack_client = init_slackbot() - post_msg_on_slack(slack_client, "bonjour") \ No newline at end of file + post_msg_on_slack(slack_client, "bonjour")