2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

YouTubeLiveイベント配信のコメントに反応する魔改造Qiitan

Last updated at Posted at 2025-12-27

はじめに

Qiitaアドベントカレンダー2025年振り返りイベントの賑やかしに、YouTubeLiveイベント配信のコメントに反応する魔改造Qiitanを作ってみました。

元ネタ

わんコメ

YouTubeLiveイベント配信のコメント取得は「わんコメ」アプリに任せます。

「わんコメ」アプリにはプラグイン機能が付いているので、サンプル(コメントフィルタ)を参考にして魔改造Qiitanを動かすコードを作成しました。

コメントが付いたらフィルタプラグインが発火されるので、その中でObnizを発火するコードを書くだけです。

成果物はこちら。([OBNIZ-ID]のところに自分のObniz IDを記入してください)

plugin.js
module.exports = {
  name: 'Filter Sample Plugin', // @required plugin name
  uid: 'com.onecomme.plugin-filter-sample', // @required unique plugin id
  version: '0.0.1', // @required semver version
  author: 'OneComme', // @required author name
  url: 'https://onecomme.com', // @optional link (ex. documentation link)
  permissions: ['filter.comment'], // @required https://onecomme.com/docs/developer/websocket-api/#%E3%82%A4%E3%83%99%E3%83%B3%E3%83%88%E3%81%AE%E7%A8%AE%E9%A1%9E%E3%81%A8%E3%83%87%E3%83%BC%E3%82%BF
  defaultState: {},
  /**
   * コメントフィルタ
   * @param {Comment} comment 
   * @param {Service} service 
   * @param {UserNameData | null} userData 
   * @returns Promise<Comment | false>
   */
  filterComment(comment, service, userData) {
    console.info("This is a plugin test")

    // move qiitan
    const url = 'https://obniz.com/obniz/[OBNIZ-ID]/api/1';
    const data = [
  {
    io: {
      animation: {
        name: "LED",
        repeat: 2,
        status: "loop",
        states: [
          {
            duration: 2000,
            state: { io11: true }
          },
          {
            duration: 500,
            state: { io11: null }
          }
        ]
      }
    }
  }
];

    async function postAnimation() {
  try {
    const res = await fetch(url, {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json'
      },
      body: JSON.stringify(data)
    });
    console.info("qiitan success");
  } catch (err) {
    console.info("qiitan fail");
  }
}

    postAnimation();

    return comment
  },
}

プラグインの配置場所はこちら。(macOSの場合)

/Users/[ユーザー名]/Library/Application Support/onecomme/plugins

デバッグメモ

consoleを用いることで、ログファイルに出力されます。

console.info("Hello OneComme!");

ログファイルの所在はこちら。(macOSの場合)

/Users/[ユーザ名]/Library/Logs/onecomme/main.log
2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?