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 = {
id: string;
text: string | null;
reply: any | null;
};

View file

@ -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;