From be0d9a9bf2cc032ad21547fa41d57ccb03b7808e Mon Sep 17 00:00:00 2001 From: syuilo Date: Sun, 23 Aug 2020 12:29:36 +0900 Subject: [PATCH] Improve emoji-react module --- src/misskey/note.ts | 1 + src/modules/emoji-react/index.ts | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/misskey/note.ts b/src/misskey/note.ts index 0c1f718..2b12335 100644 --- a/src/misskey/note.ts +++ b/src/misskey/note.ts @@ -1,4 +1,5 @@ export type Note = { id: string; text: string | null; + reply: any | null; }; diff --git a/src/modules/emoji-react/index.ts b/src/modules/emoji-react/index.ts index 8eba70a..22b272a 100644 --- a/src/modules/emoji-react/index.ts +++ b/src/modules/emoji-react/index.ts @@ -20,7 +20,9 @@ export default class extends Module { @autobind private async onNote(note: Note) { + if (note.reply != null) return; if (note.text == null) return; + if (note.text.includes('@')) return; // (自分または他人問わず)メンションっぽかったらreject const customEmojis = note.text.match(/:([^\n:]+?):/g); if (customEmojis) { @@ -45,10 +47,18 @@ export default class extends Module { this.log(`Emoji detected - ${emojis[0]}`); + let reaction = emojis[0]; + + switch (reaction) { + case '✊': reaction = '🖐'; break; + case '✌': reaction = '✊'; break; + case '🖐': reaction = '✌'; break; + } + setTimeout(() => { this.ai.api('notes/reactions/create', { noteId: note.id, - reaction: emojis[0] + reaction: reaction }); }, 2000); return;