There are many cases where you are running a batch and want to be notified when it ends or an abnormality occurs. Recently, the method of "using Slack for notification" is popular among me. What makes me happy is that I can immediately check it on my mobile phone or computer. And if it's a Slack channel, you can get the people involved right away. I use it when I want to create an oleore monitor for a specific service immediately.
Please rewrite the token of the script below to your own token. In the example below, #uhouho_channnel has a user named tsukune. Tweet "Chiss".
pip install
pip install slackclient
from slackclient import SlackClient
def post_slack(message):
token = "xoxp-XXXXXXXXXX-XXXXXXXXXX-XXXXXXXXXX-XXXXXXXXXX"
sc = SlackClient(token)
sc.api_call("api.test")
sc.api_call(
"channels.info",
channel="1234567890"
)
sc.api_call(
"chat.postMessage",
channel="#uhouho_channnel",
text=message,
username='tsukune',
icon_emoji=':robot_face:'
)
if __name__ == '__main__':
post_slack('Chissu')
Recommended Posts