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