kuchihira-bot

command module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 11, 2024 License: MIT Imports: 1 Imported by: 0

README

kuchihira-bot

ja: 「中村繪里子・吉田尚記の本格雑談くちをひらく」の更新通知を Twitter (@kuchihira_bot, 公黙認) と Bluesky (@kuchihira-bot.bsky.social, 非公式)に投稿するBotプログラム

en: A bot program that posts "中村繪里子・吉田尚記の本格雑談くちをひらく" update notifications to Twitter (@kuchihira_bot, semi-official) and Bluesky (@kuchihira-bot.bsky.social, unofficial)

setup

  1. git clone or go install

    git clone https://github.com/mikuta0407/kuchihira-bot.git
    cd kuchihira-bot
    go build .
    

    or

    mkdir kuchihira-bot
    cd kuchihira-bot
    go install github.com/mikuta0407/kuchihira-bot@latest
    
  2. make config directory

    mkdir ./_config
    
  3. create _config/config-discord.json

    {
        "username":"くちをひらくBot",
        "avatar_url":"",
        "url":"https://discord.com/api/webhooks/..."
    }
    
  4. create _config/config-twtr.json

    {
        "apikey":"hogeApiKey",
        "apikeysec":"hogeApiKeySecet",
        "oauthtoken":"hogeOAuthToken",
        "oauthtokensec":"hogeOAuthTokenSecret"
    }
    
  5. create _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"
        ]
    }
    
  6. generate _config/config-bsky.json

    ./kuchihira-bot login -u handle.example.net -p yourpassword -s host(optional)
    

    config-bsky.json is generated in _config. Auth data is generated by first post in _config/<handle>.auth

usage

./kuchihira-bot post

cron example

Episode 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 * * * ~/projects/kuchihira-bot/kuchihira-bot post

Licence

MIT

Note

Digression(余談)

  • 元々、 https://gist.github.com/mikuta0407/955808cff9eb725a313a17286c43b558 でも公開しているPHP製プログラムとして2023年5月から稼働させていました。Bluesky投稿を勝手に実装してみるにあたり、PHPでBlueskyのリンク付き投稿の実装がかなり辛かったため、既にmattn氏によって作られていたリンク付き投稿のコードを利用するために、Goを用いて最初から作り直してみました。

    正直なところ、行数は増え、cobraによるCLIコマンドを(blueskyログインのためだけに)足したため、プログラムの規模に対して内容が過剰になってしまいました。

    書き直したメリットとしては、

    • Goによってシングルバイナリになったこと
    • すべての変数を外に出したこと(PHPで作ったときは(面倒くさくて)ハードコーディングしていた部分を外に出しながら作った)
      • 逆に配置時面倒くさくなったとも言える
    • templatesを使ってパワーな文字列結合をしなくなったこと

    くらいでしょうか。

    このプログラムは利用者が作者自身しかいない気がしますが、一応制作物としてここに置いておきいます。くちをひらかーの皆様、もしツッコミどころや鉞組があればお待ちしています。

Documentation

Overview

Copyright © 2024 mikuta0407

Directories

Path Synopsis
internal
rss

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL