mirror of
https://github.com/syuilo/ai.git
synced 2024-11-25 14:01:09 +00:00
Improve emoji-react module
This commit is contained in:
parent
be0d9a9bf2
commit
d1c0087986
|
@ -4,6 +4,7 @@ const emojiRegex = require('emoji-regex');
|
||||||
import { Note } from '../../misskey/note';
|
import { Note } from '../../misskey/note';
|
||||||
import Module from '../../module';
|
import Module from '../../module';
|
||||||
import Stream from '../../stream';
|
import Stream from '../../stream';
|
||||||
|
import includes from '../../utils/includes';
|
||||||
|
|
||||||
export default class extends Module {
|
export default class extends Module {
|
||||||
public readonly name = 'emoji-react';
|
public readonly name = 'emoji-react';
|
||||||
|
@ -24,6 +25,15 @@ export default class extends Module {
|
||||||
if (note.text == null) return;
|
if (note.text == null) return;
|
||||||
if (note.text.includes('@')) return; // (自分または他人問わず)メンションっぽかったらreject
|
if (note.text.includes('@')) return; // (自分または他人問わず)メンションっぽかったらreject
|
||||||
|
|
||||||
|
const react = (reaction: string) => {
|
||||||
|
setTimeout(() => {
|
||||||
|
this.ai.api('notes/reactions/create', {
|
||||||
|
noteId: note.id,
|
||||||
|
reaction: reaction
|
||||||
|
});
|
||||||
|
}, 2000);
|
||||||
|
};
|
||||||
|
|
||||||
const customEmojis = note.text.match(/:([^\n:]+?):/g);
|
const customEmojis = note.text.match(/:([^\n:]+?):/g);
|
||||||
if (customEmojis) {
|
if (customEmojis) {
|
||||||
// カスタム絵文字が複数種類ある場合はキャンセル
|
// カスタム絵文字が複数種類ある場合はキャンセル
|
||||||
|
@ -31,13 +41,7 @@ export default class extends Module {
|
||||||
|
|
||||||
this.log(`Custom emoji detected - ${customEmojis[0]}`);
|
this.log(`Custom emoji detected - ${customEmojis[0]}`);
|
||||||
|
|
||||||
setTimeout(() => {
|
return react(customEmojis[0]);
|
||||||
this.ai.api('notes/reactions/create', {
|
|
||||||
noteId: note.id,
|
|
||||||
reaction: customEmojis[0]
|
|
||||||
});
|
|
||||||
}, 2000);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const emojis = note.text.match(emojiRegex());
|
const emojis = note.text.match(emojiRegex());
|
||||||
|
@ -55,13 +59,11 @@ export default class extends Module {
|
||||||
case '🖐': reaction = '✌'; break;
|
case '🖐': reaction = '✌'; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
setTimeout(() => {
|
return react(reaction);
|
||||||
this.ai.api('notes/reactions/create', {
|
}
|
||||||
noteId: note.id,
|
|
||||||
reaction: reaction
|
if (includes(note.text, ['ぴざ'])) return react('🍕');
|
||||||
});
|
if (includes(note.text, ['ぷりん'])) return react('🍮');
|
||||||
}, 2000);
|
if (includes(note.text, ['寿司', 'sushi']) || note.text === 'すし') return react('🍣');
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue