Improve emoji-react module

This commit is contained in:
syuilo 2020-08-23 12:29:36 +09:00
parent e3c89fa069
commit be0d9a9bf2
2 changed files with 12 additions and 1 deletions

View file

@ -1,4 +1,5 @@
export type Note = { export type Note = {
id: string; id: string;
text: string | null; text: string | null;
reply: any | null;
}; };

View file

@ -20,7 +20,9 @@ export default class extends Module {
@autobind @autobind
private async onNote(note: Note) { private async onNote(note: Note) {
if (note.reply != null) return;
if (note.text == null) return; if (note.text == null) return;
if (note.text.includes('@')) return; // (自分または他人問わず)メンションっぽかったらreject
const customEmojis = note.text.match(/:([^\n:]+?):/g); const customEmojis = note.text.match(/:([^\n:]+?):/g);
if (customEmojis) { if (customEmojis) {
@ -45,10 +47,18 @@ export default class extends Module {
this.log(`Emoji detected - ${emojis[0]}`); this.log(`Emoji detected - ${emojis[0]}`);
let reaction = emojis[0];
switch (reaction) {
case '✊': reaction = '🖐'; break;
case '✌': reaction = '✊'; break;
case '🖐': reaction = '✌'; break;
}
setTimeout(() => { setTimeout(() => {
this.ai.api('notes/reactions/create', { this.ai.api('notes/reactions/create', {
noteId: note.id, noteId: note.id,
reaction: emojis[0] reaction: reaction
}); });
}, 2000); }, 2000);
return; return;