pynotificator: Python から様々な通知を簡単に送るためのライブラリ
Project description
Python / コマンドラインから様々な通知を簡単に送るためのライブラリ
概要
実行時間の長いプログラムなどの実行時、
- 「 Slack で受け取れたらな〜 」
- 「 音鳴らしてくれたらな〜 」
- 「 通知飛ばしてくれればな〜 」
と思ったことはありませんか?
それ、できます。
そう、PyNotificator ならね。
PyNotificator は Python のプログラム / コマンドラインからビープ音・通知センター、Slack、Discord、LINE にメッセージを簡単に送信できるライブラリです。
インストール
このリポジトリを以下のコマンドでインストールします。動作環境は Python >= 3.6
です。
pip install pynotificator
使い方
コマンドラインツール
ビープ音
$ beep-notify [-h] [--times TIMES]
通知
$ center-notify [-h] [--message MESSAGE] [--title TITLE]
[--subtitle SUBTITLE] [--nosound]
Slack
$ slack-notify [-h] [--message MESSAGE] url
Discord
$ discord-notify [-h] [--message MESSAGE] url
LINE
$ line-notify [-h] [--message MESSAGE] token
Python
インポート
使用するクラスのみをインポートすることを推奨します。
# ビープ音を使用したい場合
from pynotificator import BeepNotification
macOS、Linux のビープ音
お使いの Mac、LinuxPC から音を出せます。
# 引数は音を鳴らす回数です。
bn = BeepNotification(3)
bn.notify()
macOS 通知センター
お使いの Mac に通知を送れます。
cn = CenterNotification('本文', title='タイトル', subtitle='サブタイトル', sound=True)
cn.notify()
実行サンプル
Slack
Slack の Incoming Webhook を利用し、メッセージを送信します。 Slack API より、Webhook 用の URL を取得してください。
sn = SlackNotification('本文', 'https://hooks.slack.com/services/xxx')
sn.notify()
Discord
Discord の Webhook を利用し、メッセージを送信します。 サーバー設定 > ウェブフック より、Webhook 用の URL を取得してください。
dn = DiscordNotification('本文', 'https://discordapp.com/api/webhooks/xxx')
dn.notify()
LINE
LINE Notify を利用し、メッセージを送信します。 LINE Notify からトークンを発行してください。
ln = LineNotification('本文', 'xxx')
ln.notify()
クラス図
ライセンス
作成者
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pynotificator-0.4.1.tar.gz
(5.5 kB
view hashes)