mirror of
https://github.com/syuilo/ai.git
synced 2024-11-21 20:58:00 +00:00
Improve emoji-react module
This commit is contained in:
parent
e3c89fa069
commit
be0d9a9bf2
|
@ -1,4 +1,5 @@
|
|||
export type Note = {
|
||||
id: string;
|
||||
text: string | null;
|
||||
reply: any | null;
|
||||
};
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue