Skip to content

feat(plugins): ノート内の絵文字でリアクションする 2 プラグインを追加 - #41

Merged
hitalin merged 2 commits into
mainfrom
feat/emoji-reaction-plugins
Aug 12, 2026
Merged

feat(plugins): ノート内の絵文字でリアクションする 2 プラグインを追加#41
hitalin merged 2 commits into
mainfrom
feat/emoji-reaction-plugins

Conversation

@hitalin

@hitalin hitalin commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

種別

  • theme
  • plugin
  • widget
  • query
  • skill

概要

ノートに写っている絵文字をそのままリアクションに使うプラグインを 2 つ追加します。
プラグインからは選択 UI を出せないため、どちらも候補を Mk:confirm で 1 件ずつ
確認しながら選ぶ形にしています。

  • 同じ絵文字でリアクション (same-emoji-react) — 本文と CW に含まれる
    カスタム絵文字 / Unicode 絵文字 (Twemoji) と同じ絵文字でリアクションする
  • リアクション相乗り (reaction-piggyback) — 既に付いているリアクションに乗る。
    リモートのカスタム絵文字は自鯖に同名があれば読み替える

どちらもリモート絵文字はそのままリアクションに使えないため、Mk:api("emojis")
一覧と照合して自鯖に存在する名前だけを候補にします。

絵文字の切り出し

AiScript には正規表現も 16 進リテラルも無いので、Unicode 絵文字は
to_unicode_codepoint_arr() でコードポイントに分解し、範囲を 10 進テーブルで
持って書字素のまとまりを手で読み進めます (ZWJ 連結・肌の色・VS16・
囲みキーキャップ・地域表示記号の対)。素の数字を 1️⃣ と誤検出しないよう、
キーキャップは U+20E3 が続くときのみ絵文字として扱います。

相乗りのほうは、本家がローカル絵文字のリアクションキーを :name@.:
正規化する (ReactionService.convertLegacyReaction) ため @ 以降を落とし、
結果として同じ :hoge: に畳まれる候補は数を合算して 1 件にまとめます。

チェックリスト(投稿者)

  • public/registry/<種別>/<id>/ にディレクトリを作り、meta.json(skill は frontmatter)と主ソースを置いた
  • meta.id を書く場合、ディレクトリ名と完全一致させた(不一致は既存アイテム乗っ取りの温床として CI が reject します)
  • meta.jsoncreatedAt/updatedAt書いていない(日付は git 履歴から自動採取されます)
  • ソースは難読化していない。文字コード演算での文字列構築・極端な minify をしていない
  • pnpm run registry:build がローカルで成功する

権限(plugin / widget / query のみ)

  • 呼ぶ API / ホスト関数:
    • Mk:api("emojis", {}) — 自鯖のカスタム絵文字一覧。候補が自鯖で使えるかの照合にのみ使う
    • Mk:api("notes/reactions/create", { noteId, reaction }) — 選ばれた 1 件にリアクションする
    • Mk:dialog / Mk:confirm / Mk:toast — 候補の確認と結果表示
  • 外部接続先(あれば): なし(自分のサーバー以外に通信しません)
  • なぜその権限が必要か: permissionswrite:reactions のみ。リアクションの作成に
    必要な最小権限で、投稿・フォロー・DM・削除は行いません。リアクションは必ず
    ユーザーが Mk:confirm で明示的に承認した 1 件だけを、1 回だけ作成します
    (承認が無ければ何もしません)。

本家 Misskey Web との互換性

本家のソースを読んで挙動を合わせ、既存プラグインにある誤りを 1 つ避けています

  • Mk:api は失敗時に throw せず values.ERROR('request_failed') を返すため、
    戻り値をガードする。ただし notes/reactions/create は成功時 204 (= null)
    返すので、既存プラグイン (pakuru) の Core:type(res) == "obj" 判定では
    成功を失敗と誤判定する。本 PR では Core:type(res) == "error" で判定する
  • 絵文字一覧が取れないときは warning を出して Unicode 絵文字だけで続行する
  • ダイアログ type は本家の allowlist (info / warning / error) の範囲に収めた
  • permissions は本家の PermissionKey write:reactions
  • 本家には CUSTOM_EMOJIS 変数があるが NoteDeck に無いため、両対応の
    emojis エンドポイントで取得する
  • 多重リアクションは API エラーになるので、myReaction があれば何もせず終わる

検証

本家 frontend と同じ @syuilo/aiscript@1.2.1 に、本家セマンティクス
(エラー値・204・ダイアログ type allowlist・### metadatadefault から組む
Plugin:config) を再現したモック env を渡すハーネスで、両プラグイン計 36 ケースを
実行して全通しを確認しました。

  • 入力: カスタム絵文字 / :name@host: / :name@.: / Unicode 絵文字 (ZWJ 連結・
    国旗・キーキャップ・肌の色・VS16) / 壊れたリアクションキー / 本文空 /
    reactions キー欠落 / リアクション済み
  • 失敗系: emojis 失敗時、notes/reactions/create 失敗時の全パス

実サーバーでの実機確認は行っていません(ソース読解 + AiScript 実行での検証まで)。

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added a reaction piggyback plugin that suggests popular reactions already used on a note.
    • Added a same-emoji reaction plugin that detects emojis in note text and suggests matching reactions.
    • Both plugins support configurable candidate limits and confirmation before reacting.
  • Registry Updates

    • Updated plugin listings and metadata.
    • Increased the available plugin count from 24 to 26.
    • Refreshed registry timestamps and added icons for the new plugins.

hitalin and others added 2 commits August 12, 2026 13:29
ノート本文と CW に写っている絵文字を拾い、同じ絵文字でリアクションする
note action を追加する。候補が複数あるときは Mk:confirm で 1 件ずつ
確認しながら選べる (プラグインからは選択 UI を出せないため)。

カスタム絵文字は Mk:api("emojis") の一覧と照合し、自鯖に存在する名前だけを
候補にする。:name@host: 表記でも同名が自鯖にあれば :name: に落として使う
(他鯖の絵文字はそのままリアクションに使えないため)。本家には CUSTOM_EMOJIS
変数があるが、NoteDeck に無いため両対応の emojis エンドポイントで取る。

Unicode 絵文字 (Twemoji) は to_unicode_codepoint_arr() でコードポイントに
分解し、書字素のまとまりとして切り出す。AiScript には正規表現も 16 進
リテラルも無いため、範囲は 10 進のテーブルで持ち、ZWJ 連結・肌の色・
VS16・囲みキーキャップ・地域表示記号の対 (国旗) を手で読み進める。
素の数字を 1️⃣ と誤検出しないよう、キーキャップは U+20E3 が続くときのみ
絵文字として扱う。

本家 Misskey Web との互換性:
- Mk:api は失敗時に throw せずエラー値を返すため、emojis / reactions.create
  の戻り値を Core:type(res) == "error" でガードする。notes/reactions/create
  は成功時 204 (= null) を返すので、既存プラグインの obj 判定では成功を
  失敗と誤判定する
- 絵文字一覧が取れないときは警告を出して Unicode 絵文字だけで続行する
- permissions は本家の PermissionKey "write:reactions"、ダイアログ type は
  本家 allowlist (info / warning / error) の範囲に収めた
- 多重リアクションは API エラーになるので、myReaction があれば何もせず終わる

aiscript 1.2.1 (本家 frontend と同一) + 本家セマンティクス (エラー値・204・
type allowlist・### metadata の default から組む Plugin:config) のハーネスで、
API 正常時と emojis / reactions.create 各失敗時の全パスを検証済み。

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
ノートに既に付いているリアクションと同じ絵文字で乗る note action を追加する。
リモートのカスタム絵文字 (:hoge@example.com:) はそのままではリアクションに
使えないため、自鯖に同名の絵文字があるときだけ :hoge: に読み替えて候補にする。
候補は付いている数の多い順で、同じ絵文字でリアクションするプラグインと同じく
Mk:confirm で 1 件ずつ確認しながら選べる。

本家 Misskey はローカル絵文字のリアクションキーを :name@.: に正規化するため
(ReactionService.convertLegacyReaction)、@ 以降を落として名前を取り出す。
その結果 :hoge@.: と :hoge@a.example: が同じ :hoge: に畳まれるので、
候補は 1 つにまとめて数を合算する。カスタム絵文字として読めないのに
コロンを含むキーは壊れているとみなして捨てる。

本家 Misskey Web との互換性 (同じ絵文字でリアクションと同様):
- Mk:api の戻り値を Core:type(res) == "error" でガードする
  (notes/reactions/create は成功時 204 = null なので obj 判定では弾けない)
- 絵文字一覧が取れないときは警告を出して Unicode 絵文字だけで続行する
- permissions は本家の PermissionKey "write:reactions"、ダイアログ type は
  本家 allowlist の範囲に収めた
- Unicode 絵文字しか付いていないノートでは emojis を叩かない

aiscript 1.2.1 (本家 frontend と同一) + 本家セマンティクスのハーネスで、
:name@.: / :name@host: / Unicode / 壊れたキーの各入力と、API 正常時・
emojis 失敗時・reactions.create 失敗時の全パスを検証済み。

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
misstore f5be22d Aug 12 2026, 04:32 AM

@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: bb2542f7-aa83-4f67-8020-f3127b3eaf5c

📥 Commits

Reviewing files that changed from the base of the PR and between 2db779a and f5be22d.

⛔ Files ignored due to path filters (2)
  • public/registry/plugins/reaction-piggyback/icon.svg is excluded by !**/*.svg
  • public/registry/plugins/same-emoji-react/icon.svg is excluded by !**/*.svg
📒 Files selected for processing (13)
  • public/registry/index.json
  • public/registry/plugins.json
  • public/registry/plugins/reaction-piggyback/api.json
  • public/registry/plugins/reaction-piggyback/meta.json
  • public/registry/plugins/reaction-piggyback/plugin.is
  • public/registry/plugins/same-emoji-react/api.json
  • public/registry/plugins/same-emoji-react/meta.json
  • public/registry/plugins/same-emoji-react/plugin.is
  • public/registry/queries.json
  • public/registry/skills.json
  • public/registry/themes.json
  • public/registry/widgets.json
  • scripts/sync-icons.js

📝 Walkthrough

Walkthrough

Changes

The registry now includes reaction-piggyback and same-emoji-react. The plugins detect or reuse emoji reactions, use Misskey APIs, require write:reactions, and provide configurable candidate selection and confirmation flows.

Emoji reaction plugins

Layer / File(s) Summary
Reaction piggyback plugin
public/registry/plugins/reaction-piggyback/*
Ranks existing note reactions, filters supported Unicode and custom emojis, caches local emoji names, and creates a confirmed reaction.
Same-emoji reaction plugin
public/registry/plugins/same-emoji-react/*
Extracts configured emojis from note text and CW, filters custom emojis, caches local emoji names, and creates a confirmed reaction.
Registry and icon synchronization
public/registry/index.json, public/registry/plugins.json, public/registry/queries.json, public/registry/skills.json, public/registry/themes.json, public/registry/widgets.json, scripts/sync-icons.js
Registers both plugins, changes the plugin count from 24 to 26, updates registry timestamps, and adds Lucide icon mappings.

Estimated code review effort: 4 (Complex) | ~45 minutes

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/emoji-reaction-plugins

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@hitalin hitalin self-assigned this Aug 12, 2026
@hitalin
hitalin merged commit 63fe03a into main Aug 12, 2026
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant