ja: 「中村繪里子・吉田尚記の本格雑談くちをひらく」の更新通知を Twitter (@kuchihira_bot, 公黙認) と Bluesky (@kuchihira-bot.bsky.social, 非公式)に投稿するBotプログラム。このボットは RSS の更新内容を Twitter に投稿できます。基本的な RSS フィード形式であれば他のポッドキャストにも利用可能です。
en: A bot program that posts "中村繪里子・吉田尚記の本格雑談くちをひらく" update notifications to Twitter (@kuchihira_bot, semi-official) and Bluesky (@kuchihira-bot.bsky.social, unofficial) This bot can post RSS updates to Twitter. It works with standard RSS feeds and can be used for other podcasts as well.
-
git clone or go install
git clone https://github.com/mikuta0407/kuchihira-bot.git cd kuchihira-bot make buildor
mkdir kuchihira-bot cd kuchihira-bot go install github.com/mikuta0407/kuchihira-bot@latest -
make config and data directory
mkdir ./_config mkdir ./_data
-
create
_config/config-discord.json{ "username":"くちをひらくBot", "avatar_url":"", "url":"https://discord.com/api/webhooks/..." } -
create
_config/config-twtr.json{ "apikey":"hogeApiKey", "apikeysec":"hogeApiKeySecret", "oauthtoken":"hogeOAuthToken", "oauthtokensec":"hogeOAuthTokenSecret" } -
create
_config/config-kuchihira.json{ "hashtag":"#くちをひらく", "rss":"https://www.omnycontent.com/d/playlist/67122501-9b17-4d77-84bd-a93d00dc791e/bf2b4e95-c669-4e1c-abcf-a98c00a5f513/b923e360-dc05-438d-be85-a98c00a5f517/podcast.rss", "omnyfm":"https://omny.fm/shows/kuchiwohiraku/", "voicy":"https://voicy.jp/channel/584", "mentions":[ "@yoshidahisanori", "@eriko_co_log", "@kuchiwohiraku" ] } -
generate
_config/config-bsky.json./kuchihira-bot login -u handle.example.net -p yourpassword -s host(optional)
config-bsky.jsonis generated in_config. Auth data is generated by first post in_config/<handle>.auth
one-time exec
./kuchihira-bot postdaemon mode
./kuchihira-bot daemon
dryrun mode (no actual post. only stdout)
./kuchihira-bot post --debug
./kuchihira-bot daemon --debugEpisode updates are usually done between 17:00 (JST) and 17:02 (JST), so start fetching RSS updates every 20 seconds starting at 16:50 (JST).
50 16 * * * /path/to/kuchihira-bot/kuchihira-bot post
Please change binary path, user and group!
[Unit]
Description=Kuchiwohiraku Bot
[Service]
ExecStart=/path/to/kuchihira-bot/kuchihira-bot daemon
Restart=always
Type=simple
User=hogeuser
Group=hogeuser
[Install]
WantedBy=multi-user.target
ja:
バイナリの位置に対する相対パスでコンフィグファイルやデータを見に行くため、go runで実行しないでください。/tmp以下の_configを読みに行こうとして動かなくなります。
動作テストを行う際は、
単発実行の場合は
make debug
デーモンモードの場合は
make daemondebug
を使用するなど、makeコマンドを使用してください。この2つのmakeコマンドは、カレントディレクトリにkuchihira-bot_debugとしてバイナリファイルを出力し、--debugオプションを付加させた状態で起動します。
(internal/config/config.go内のGetConfigDir()でコメントアウトを入れ替えれば、シェルのカレントディレクトリを見に行くようにはなりますが、おすすめはしません。)
en:
Do not run with go run as it retrieves configuration files and data relative to the binary location. If you start it with go run, it will try to read _config under /tmp and will not work.
Please use the following make command when testing the operation.
For one-shot execution
make debug
In daemon mode
make daemondebug
These two make commands output a binary file as kuchihira-bot_debug in the current directory and start with the --debug option added.
(If you replace the comment out with GetConfigDir() in internal/config/config.go, you will be able to see the current directory of the shell, but I do not recommend it.)
MIT
- Bluesky posting logic is based on the implementation at https://github.com/mattn/bsky.
-
元々、 https://gist.github.com/mikuta0407/955808cff9eb725a313a17286c43b558 でも公開しているPHP製プログラムとして2023年5月から稼働させていました。Bluesky投稿を勝手に実装してみるにあたり、PHPでBlueskyのリンク付き投稿の実装がかなり辛かったため、既にmattn氏によって作られていたリンク付き投稿のコードを利用するために、Goを用いて最初から作り直してみました。
正直なところ、行数は増え、cobraによるCLIコマンドを(blueskyログインのためだけに)足したため、プログラムの規模に対して内容が過剰になってしまいました。
書き直したメリットとしては、
- Goによってシングルバイナリになったこと
- すべての変数を外に出したこと(PHPで作ったときは(面倒くさくて)ハードコーディングしていた部分を外に出しながら作った)
- 逆に配置時面倒くさくなったとも言える
- templatesを使ってパワーな文字列結合をしなくなったこと
くらいでしょうか。
このプログラムは利用者が作者自身しかいない気がしますが、一応制作物としてここに置いておきます。くちをひらかーの皆様、もしツッコミどころや鉞組があればお待ちしています。