Skip to main content

pynotificator: Python から様々な通知を簡単に送るためのライブラリ

Project description

PyNotificator logo

Python / コマンドラインから様々な通知を簡単に送るためのライブラリ

概要

実行時間の長いプログラムなどの実行時、

  • Slack で受け取れたらな〜
  • 音鳴らしてくれたらな〜
  • 通知飛ばしてくれればな〜

と思ったことはありませんか?

それ、できます。
そう、PyNotificator ならね。

PyNotificator は Python のプログラム / コマンドラインからビープ音・通知センター、Slack、Discord、LINE にメッセージを簡単に送信できるライブラリです。

インストール

このリポジトリを以下のコマンドでインストールします。動作環境は Python >= 3.6 です。

pip install pynotificator

Windows の通知を利用する場合は win のオプションをつける必要があります。

pip install pynotificator[win]

使い方

コマンドラインツール

ビープ音

$ 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、Windows のビープ音

お使いの Mac、LinuxPC から音を出せます。

# 引数は音を鳴らす回数です。
bn = BeepNotification(3)
bn.notify()

macOS、Windows 通知センター

お使いの Mac、Windows に通知を送れます。

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()

ライセンス

MIT License

作成者

higurashi-takuto

Project details


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.5.0.tar.gz (5.9 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page