naskya / annict-discord-bot

Annict で記録したアニメの視聴記録の一部を Discord チャンネルに投稿

Home Page:https://blog.naskya.net/post/0012/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

annict-discord-bot

Annict に記録したアニメの視聴記録(作品の視聴開始・終了のみ)を Discord の特定のチャンネルに転送します。

Discord bot の作成および投稿したいサーバーへの招待が必要です。

設定

config という名前のファイルに入っているダミーの文字列を置き換えて

  • Annict のユーザー ID
  • Annict のアクセストークン
  • Discord bot のアクセストークン
  • Discord チャンネルの ID

を設定します。

使用例

systemd timer を用いて定期的に実行します。

# /etc/systemd/system/annict-discord-bot.service

[Unit]
Description=forward activities recorded on Annict to Discord

[Service]
Type=simple
ExecStart=/path/to/annict-discord-bot/main.py
WorkingDirectory=/path/to/annict-discord-bot

[Install]
WantedBy=multi-user.target
# /etc/systemd/system/annict-discord-bot.timer

[Unit]
Description=run annict-discord-bot

[Timer]
OnCalendar=*-*-* *:00/20:00
Persistent=true

[Install]
WantedBy=timers.target

/path/to/annict-discord-bot はリポジトリを clone したディレクトリに置き換えてください。

systemctl コマンドで定期実行を有効化します。

# systemctl enable annict-discord-bot.service
# systemctl enable annict-discord-bot.timer

ログの確認は journalctl コマンドで行います。

$ journalctl -xeu annict-discord-bot

備考

一度投稿した内容は再投稿しないようになっています。そのため

$ ./main.py
$ ./main.py

とすると二度目の実行ではメッセージは投稿されません(実行すると実際に Discord チャンネルにメッセージが投稿される のでご注意ください)。

メッセージを投稿すること無く、現在までに Annict に記録してあるもののデータの取得を行って投稿済みの扱いにしたい (今後新たに記録したもののみを Discord チャンネルに投稿したい)場合には dry という引数をつけて実行します。

$ ./main.py dry

About

Annict で記録したアニメの視聴記録の一部を Discord チャンネルに投稿

https://blog.naskya.net/post/0012/

License:MIT License


Languages

Language:Python 100.0%