mirror of
https://github.com/syuilo/ai.git
synced 2024-11-25 06:01:07 +00:00
じゃんけん高速化
This commit is contained in:
parent
31449bd398
commit
6a43a55b0b
|
@ -1,5 +1,6 @@
|
||||||
import autobind from 'autobind-decorator';
|
import autobind from 'autobind-decorator';
|
||||||
import { parse } from 'twemoji-parser';
|
import { parse } from 'twemoji-parser';
|
||||||
|
const delay = require('timeout-as-promise');
|
||||||
|
|
||||||
import { Note } from '@/misskey/note';
|
import { Note } from '@/misskey/note';
|
||||||
import Module from '@/module';
|
import Module from '@/module';
|
||||||
|
@ -25,13 +26,14 @@ 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) => {
|
const react = async (reaction: string, immediate = false) => {
|
||||||
setTimeout(() => {
|
if (!immediate) {
|
||||||
this.ai.api('notes/reactions/create', {
|
await delay(1500);
|
||||||
noteId: note.id,
|
}
|
||||||
reaction: reaction
|
this.ai.api('notes/reactions/create', {
|
||||||
});
|
noteId: note.id,
|
||||||
}, 1500);
|
reaction: reaction
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const customEmojis = note.text.match(/:([^\n:]+?):/g);
|
const customEmojis = note.text.match(/:([^\n:]+?):/g);
|
||||||
|
@ -54,9 +56,9 @@ export default class extends Module {
|
||||||
let reaction = emojis[0];
|
let reaction = emojis[0];
|
||||||
|
|
||||||
switch (reaction) {
|
switch (reaction) {
|
||||||
case '✊': reaction = '🖐'; break;
|
case '✊': return react('🖐', true);
|
||||||
case '✌': reaction = '✊'; break;
|
case '✌': return react('✊', true);
|
||||||
case '🖐': reaction = '✌'; break;
|
case '🖐': return react('✌', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
return react(reaction);
|
return react(reaction);
|
||||||
|
|
Loading…
Reference in a new issue