こちら
から対応するバージョンのwhlファイルをインストールし、パスを指定してpip install
を行う。
pip install ~/python_line_notify-1.2.0a0-py3-none-any.whl
OR
python -m pip install ~/python_line_notify-1.2.0a0-py3-none-any.whl
import python_line_notify
# トークンの発行方法は下記を参照
client = python_line_notify.Client('<Line Notify Token>')
# 相対パスから画像を添付(png, jpgのみ)
client.send(content='image from File', image='./test/wumpus.png')
# URLから画像を添付(jpgのみ), 通知OFF
client.send(content='image from URL', image='https://~~~~~/~~~.jpg', notify=True)
# StickerIDからステッカーを添付
# (StickerPackageId, StickerId)
# https://devdocs.line.me/files/sticker_list.pdf
client.send(content='sticker from ids', sticker=(2, 141))
下記のリンクからLine Notifyのページにアクセスして、通知を行いたいLineアカウントでログイン。
URL -> https://notify-bot.line.me/ja/
マイページの「アクセストークンの発行」から「トークンを発行する」をクリック
トークンに利用する名前(適当で良い ※ただし、通知時にその名前が表示されるので注意)を入力し、通知を送信するトークルームを一つ選択して、「発行する」を押す。
※「1:1でLine Notifyから通知を受け取る」にしておけば、自分自身に通知を送信できる
※発行したトークンは、大切に保管して下さい。トークンはなるべくスクリプトに直に書かず、環境変数などから読み込むことを推奨します。
https://notify-bot.line.me/doc/ja/
MIT