LoginSignup
37
50

More than 3 years have passed since last update.

SlackにPythonからメッセージを送る

Posted at

時間がかかるPythonプログラムの最後に、ジョブが終わったよなど、slackに通知する。

slack-python-webhookを使用する。

my_tool.py
import slackweb
def message_to_slack(message):
    slack = slackweb.Slack(url="MY_SLACK_URL")
    slack.notify(text=message)

My_URLの部分はincoming webhookから取得する。

使う時は

from my_tool import message_to_slack
message_to_slack("Job Completed!")

などとする。

37
50
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
37
50