Improve AI

This commit is contained in:
syuilo 2018-09-02 22:34:17 +09:00
parent 2894d45aa7
commit 5c45354073
2 changed files with 22 additions and 15 deletions

View file

@ -24,25 +24,30 @@ export default class TimerModule implements IModule {
if ((seconds + minutes + hours) == 0) {
msg.reply(serifs.timer.invalid);
return true;
} else {
msg.reply(serifs.timer.set);
}
const time =
(1000 * seconds) +
(1000 * 60 * minutes) +
(1000 * 60 * 60 * hours);
const str = `${hours ? hoursQuery[0] : ''}${minutes ? minutesQuery[0] : ''}${seconds ? secondsQuery[0] : ''}`;
setTimeout(() => {
const name = msg.friend.name;
this.ai.sendMessage(msg.userId, {
text: serifs.timer.notify(str, name)
});
}, time);
const time =
(1000 * seconds) +
(1000 * 60 * minutes) +
(1000 * 60 * 60 * hours);
if (time > 86400000) {
msg.reply(serifs.timer.tooLong);
return true;
}
msg.reply(serifs.timer.set);
const str = `${hours ? hoursQuery[0] : ''}${minutes ? minutesQuery[0] : ''}${seconds ? secondsQuery[0] : ''}`;
setTimeout(() => {
const name = msg.friend.name;
this.ai.sendMessage(msg.userId, {
text: serifs.timer.notify(str, name)
});
}, time);
return true;
} else {
return false;
}

View file

@ -217,6 +217,8 @@ export default {
invalid: 'うーん...',
tooLong: '長すぎます…',
notify: (time, name) => name ? `${name}${time}経ちましたよ!` : `${time}経ちましたよ!`
}
};