SlackにPython3でMessageをPostするコードを書いたので備忘録です。 Slackにエラーログを送ったり、アラート通知などに活用する。 開発環境 Mac10.14.1 Python3.7.0 Slack: WebHookURLが必要 SlackにPostするときにAPI仕様を確認する ( Attachment structure ) https://api.slack.com/docs/message-attachments import urllib.request import json url = 'https://hooks.slack.com/services/xxxxxxxxxxxxxxxxxxxxx' def post_slack(msg): set_fileds = [{ "title": "TITLE", "value": msg, "short": Fa
Herokuでslackbot(python)を動かしてみました。 Windows Subsystem for Linux(Ubuntu)で開発しています。 おみくじメッセージを送るとおみくじが引けるBOTを作ってみました。 環境 Windows 10 Fall Creators Update(バージョン 1709) Ubuntu 16.04.3 LTS Python 3.5.2 heroku-cli/6.15.18 slackbot 0.5.1 → https://github.com/lins05/slackbot Herokuアカウント作成 Herokuアカウントを作成してください。 https://www.heroku.com/ Windows Subsystem for Linux(Ubuntu)インストール 下記サイトを参考にWindows Subsystem for Linu
前置き このページは基本的な使い方を説明するページです。使い方のすべてを説明するわけではありません。 Pythonのslackbotライブラリを用いれば、Slackで特定のメッセージを受け取って、処理を行ったり、返事を行うことができます。 本ページでは、slackbotの導入と基本的な使い方を紹介します。 また、文字を扱うことが多いので、デフォルトでユニコードを扱えるPython3系で書くことにします。 Python2系でも作れるが、文字の比較などでユニコード文字列指定を行うなど、めんどくさいからです。 以降、Pythonという言葉は、断りがない限りPython3系を指します。 slackbotのインストール $ sudo apt-get install python3-pip # pip3を導入済みなら不要 $ sudo pip3 install slackbot # slackbotラ
機械学習の学習が終わったあと、結果を通知して欲しくて、調べたんでメモ。 Incoming Webhookを使う。 詳しくは、マニュアルで。 SlackでIncoming Webhookの登録をする Slackのアプリで、「Add an app or custom integration」を押す。 ブラウザが立ち上がるんで、右上にある「Build your own」を押す。 「Make a custom integration」を押す。 「Incoming Webhook」を押す。 投稿先のチャンネルを選んで作成すると、URLが出てくるんでコピーしとく。 Pythonを書く 実質、ワンライナー。 requestsを、pipとかで入れとく。 import requests import json requests.post('上でコピったURL', data = json.dumps({ 't
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く