From 27ee2688f42c7f22b07b0d26f0adc0ed3caa79b8 Mon Sep 17 00:00:00 2001 From: antonio Date: Wed, 31 Jul 2024 02:29:19 -0400 Subject: [PATCH] Migrating from slackclient to slack_sdk python3 library --- README.md | 4 ++-- jsmon.py | 6 +++--- setup.py | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index c3091fb..0dec046 100644 --- a/README.md +++ b/README.md @@ -24,9 +24,9 @@ JSMON_TELEGRAM_TOKEN=YOUR TELEGRAM TOKEN JSMON_TELEGRAM_CHAT_ID=YOUR TELEGRAM CHAT ID #JSMON_NOTIFY_SLACK=True #JSMON_SLACK_TOKEN=sometoken -#JSMON_SLACK_CHANNEL_ID=somechannel +#JSMON_SLACK_CHANNEL_ID=somechannel_ID ``` -To Enable slack, uncomment the slack lines in the env and add your token. +To Enable slack, uncomment the slack lines in the env and add your token (`JSMON_SLACK_CHANNEL_ID` should be in the form of: C04P1XXXXXX). To create a cron script to run JSMon regularly: ``` diff --git a/jsmon.py b/jsmon.py index ee271ab..b9e7870 100755 --- a/jsmon.py +++ b/jsmon.py @@ -17,8 +17,8 @@ NOTIFY_SLACK = config("JSMON_NOTIFY_SLACK", default=False, cast=bool) NOTIFY_TELEGRAM = config("JSMON_NOTIFY_TELEGRAM", default=False, cast=bool) if NOTIFY_SLACK: - from slack import WebClient - from slack.errors import SlackApiError + from slack_sdk import WebClient + from slack_sdk.errors import SlackApiError if(SLACK_TOKEN == "CHANGEME"): print("ERROR SLACK TOKEN NOT FOUND!") exit(1) @@ -130,7 +130,7 @@ def notify_telegram(endpoint,prev, new, diff, prevsize,newsize): def notify_slack(endpoint,prev, new, diff, prevsize,newsize): try: - response = client.files_upload( + response = client.files_upload_v2( initial_comment = "[JSmon] {} has been updated! Download below diff HTML file to check changes.".format(endpoint), channels = SLACK_CHANNEL_ID, content = diff, diff --git a/setup.py b/setup.py index 26a075d..9cc98ad 100644 --- a/setup.py +++ b/setup.py @@ -11,5 +11,5 @@ author_email='mail@r0b.re', license='MIT', url='https://github.com/robre/jsmon', - install_requires=['requests', 'jsbeautifier', 'python-decouple','slackclient'], + install_requires=['requests', 'jsbeautifier', 'python-decouple','slack_sdk'], )