Lingr の bot を作ってみた

鹿児島らぐ 🏛️ のLingr room を作ってみた 🏛️ので,そこにML のSubject を流すbot を設置してみました.

こちらにページに作り方が載っています.bot用のAPI があるので楽々です.

bot 登録

以下のページでbot を登録します.

  • “Lingr” http://lingr.com/bot/create 🏛️

    • Bot id : 任意
    • Callback URL : このURL にroom の内容が飛んできます.その内容から反応したりすることが出来ます.とりあえず最低限HTTP で200 を返すものを用意して指定.

メッセージ受信用のcgi を作成

ひとまず受け答えはしないつもりなのでHTTP 200 を返すだけのScript を用意.

投稿テスト

get だけで投稿できるので試しに投稿してみます,

以下のページで情報が入手できます.

“Lingr” http://lingr.com/developer 🏛️

bot_verifier は載っていませんが,bot ID とSecret から求められます.
KagolugML_bot と xxxxxxxxxxxxxxxxxxxxxxxxxxx を結合した文字列をsha1 にかけます.

$ echo -n 'KagolugML_botxxxxxxxxxxxxxxxxxxxxxxxxxxx'|sha1sum 
b3c03556dca8dfffb8c509cb709817044c98ad87  -

この場合 b3c03556dca8dfffb8c509cb709817044c98ad87 が bot_verifier です.

  • 投稿先のroom : kagolug
  • bot ID : KagolugML_bot
  • bot_verifier : b3c03556dca8dfffb8c509cb709817044c98ad87

以下のようにアクセスしてみるとroom にメッセージが投稿されました,

w3m -dump ‘http://lingr.com/api/room/say?room=kagolug&bot=KagolugML_bot&text=はろーわーるど&bot_verifier=b3c03556dca8dfffb8c509cb709817044c98ad87 🏛️‘

メールからLinger に投稿

鹿児島らぐのML だけを登録したメールアドレスを用意.そのアドレスの .forward に以下のSctipt を呼ぶように "|exec /home/mk/bin/ml2lingr.pl" のような感じで設定しておきます,後はメールが届くとこのScriptが呼ばれてRoom に投稿されます.


※bot_verifier はダミーです.

てことでirc のbot とか書くよりずっとお手軽に書けました.
今回は単に投稿するだけですが,cgi でroom のメッセージを解析して反応するとかするとbot らしくなりますね.

コメントを残す

メールアドレスが公開されることはありません。 ※ が付いている欄は必須項目です

Your post must include a link to this post.

How does this work?
Write a response on your own website and include a link to this post. Then submit your response’s URL here. Your response may appear here after moderation. To update or remove it, edit or delete your original post and submit the same URL again. Learn more about Webmentions.