mirror of
https://github.com/nullnyat/NullcatChan.git
synced 2025-08-04 09:16:31 +09:00
リファクタリングなど
This commit is contained in:
@ -53,7 +53,7 @@ export default class CoreModule implements IModule {
|
||||
data.lastBirthdayChecked = today;
|
||||
friend.setPerModulesData(this, data);
|
||||
|
||||
const text = friend.name ? serifs.core.happyBirthdayWithName.replace('{name}', friend.name) : serifs.core.happyBirthday;
|
||||
const text = serifs.core.happyBirthday(friend.name);
|
||||
|
||||
this.ai.sendMessage(friend.userId, {
|
||||
text: text
|
||||
@ -92,7 +92,7 @@ export default class CoreModule implements IModule {
|
||||
|
||||
if (withSan) {
|
||||
msg.friend.updateName(name);
|
||||
msg.reply(serifs.core.setNameOk.replace('{name}', name));
|
||||
msg.reply(serifs.core.setNameOk(name));
|
||||
} else {
|
||||
msg.reply(serifs.core.san).then(reply => {
|
||||
this.ai.subscribeReply(this, msg.userId, msg.isMessage, msg.isMessage ? msg.userId : reply.id, {
|
||||
@ -108,6 +108,7 @@ export default class CoreModule implements IModule {
|
||||
if (!msg.text) return false;
|
||||
|
||||
const incLove = () => {
|
||||
//#region 1日に1回だけ親愛度を上げる
|
||||
const today = getDate();
|
||||
|
||||
const data = msg.friend.getPerModulesData(this);
|
||||
@ -118,41 +119,24 @@ export default class CoreModule implements IModule {
|
||||
msg.friend.setPerModulesData(this, data);
|
||||
|
||||
msg.friend.incLove();
|
||||
//#endregion
|
||||
};
|
||||
|
||||
if (msg.text.includes('こんにちは')) {
|
||||
if (msg.friend.name) {
|
||||
msg.reply(serifs.core.helloWithName.replace('{name}', msg.friend.name));
|
||||
} else {
|
||||
msg.reply(serifs.core.hello);
|
||||
}
|
||||
|
||||
msg.reply(serifs.core.hello(msg.friend.name));
|
||||
incLove();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (msg.text.includes('おはよ')) {
|
||||
if (msg.friend.name) {
|
||||
msg.reply(serifs.core.goodMorningWithName.replace('{name}', msg.friend.name));
|
||||
} else {
|
||||
msg.reply(serifs.core.goodMorning);
|
||||
}
|
||||
|
||||
msg.reply(serifs.core.goodMorning(msg.friend.name));
|
||||
incLove();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (msg.text.includes('おやすみ')) {
|
||||
if (msg.friend.name) {
|
||||
msg.reply(serifs.core.goodNightWithName.replace('{name}', msg.friend.name));
|
||||
} else {
|
||||
msg.reply(serifs.core.goodNight);
|
||||
}
|
||||
|
||||
msg.reply(serifs.core.goodNight(msg.friend.name));
|
||||
incLove();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -201,7 +185,7 @@ export default class CoreModule implements IModule {
|
||||
if (msg.text == null) return;
|
||||
|
||||
const done = () => {
|
||||
msg.reply(serifs.core.setNameOk.replace('{name}', msg.friend.name));
|
||||
msg.reply(serifs.core.setNameOk(msg.friend.name));
|
||||
this.ai.unsubscribeReply(this, msg.userId);
|
||||
};
|
||||
|
||||
|
@ -128,7 +128,7 @@ export default class EmojiModule implements IModule {
|
||||
const hand = hands[Math.floor(Math.random() * hands.length)];
|
||||
const face = faces[Math.floor(Math.random() * faces.length)];
|
||||
const emoji = Array.isArray(hand) ? hand[0] + face + hand[1] : hand + face + hand;
|
||||
msg.reply(serifs.emoji.suggest.replace('$', emoji));
|
||||
msg.reply(serifs.emoji.suggest(emoji));
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
@ -30,7 +30,9 @@ export default class FortuneModule implements IModule {
|
||||
public install = (ai: 藍) => { }
|
||||
|
||||
public onMention = (msg: MessageLike) => {
|
||||
if (msg.text && (msg.text.includes('占') || msg.text.includes('うらな') || msg.text.includes('運勢'))) {
|
||||
if (msg.text == null) return false;
|
||||
|
||||
if (msg.text.includes('占') || msg.text.includes('うらな') || msg.text.includes('運勢') || msg.text.includes('おみくじ')) {
|
||||
const date = new Date();
|
||||
const seed = `${date.getFullYear()}/${date.getMonth()}/${date.getDay()}@${msg.userId}`;
|
||||
const rng = seedrandom(seed);
|
||||
|
@ -102,15 +102,15 @@ export default class GuessingGameModule implements IModule {
|
||||
|
||||
if (exist.secret < g) {
|
||||
text = firsttime
|
||||
? serifs.guessingGame.less.replace('$', g.toString())
|
||||
: serifs.guessingGame.lessAgain.replace('$', g.toString());
|
||||
? serifs.guessingGame.less(g.toString())
|
||||
: serifs.guessingGame.lessAgain(g.toString());
|
||||
} else if (exist.secret > g) {
|
||||
text = firsttime
|
||||
? serifs.guessingGame.grater.replace('$', g.toString())
|
||||
: serifs.guessingGame.graterAgain.replace('$', g.toString());
|
||||
? serifs.guessingGame.grater(g.toString())
|
||||
: serifs.guessingGame.graterAgain(g.toString());
|
||||
} else {
|
||||
end = true;
|
||||
text = serifs.guessingGame.congrats.replace('{tries}', exist.tries.length.toString());
|
||||
text = serifs.guessingGame.congrats(exist.tries.length.toString());
|
||||
}
|
||||
|
||||
if (end) {
|
||||
|
@ -217,29 +217,29 @@ class Session {
|
||||
|
||||
if (msg.body.game.surrendered) {
|
||||
if (this.isSettai) {
|
||||
text = serifs.reversi.settaiButYouSurrendered.replace('{name}', this.userName);
|
||||
text = serifs.reversi.settaiButYouSurrendered(this.userName);
|
||||
} else {
|
||||
text = serifs.reversi.youSurrendered.replace('{name}', this.userName);
|
||||
text = serifs.reversi.youSurrendered(this.userName);
|
||||
}
|
||||
} else if (msg.body.winnerId) {
|
||||
if (msg.body.winnerId == this.account.id) {
|
||||
if (this.isSettai) {
|
||||
text = serifs.reversi.iWonButSettai.replace('{name}', this.userName);
|
||||
text = serifs.reversi.iWonButSettai(this.userName);
|
||||
} else {
|
||||
text = serifs.reversi.iWon.replace('{name}', this.userName);
|
||||
text = serifs.reversi.iWon(this.userName);
|
||||
}
|
||||
} else {
|
||||
if (this.isSettai) {
|
||||
text = serifs.reversi.iLoseButSettai.replace('{name}', this.userName);
|
||||
text = serifs.reversi.iLoseButSettai(this.userName);
|
||||
} else {
|
||||
text = serifs.reversi.iLose.replace('{name}', this.userName);
|
||||
text = serifs.reversi.iLose(this.userName);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (this.isSettai) {
|
||||
text = serifs.reversi.drawnSettai.replace('{name}', this.userName);
|
||||
text = serifs.reversi.drawnSettai(this.userName);
|
||||
} else {
|
||||
text = serifs.reversi.drawn.replace('{name}', this.userName);
|
||||
text = serifs.reversi.drawn(this.userName);
|
||||
}
|
||||
}
|
||||
|
||||
@ -418,8 +418,8 @@ class Session {
|
||||
*/
|
||||
private postGameStarted = async () => {
|
||||
const text = this.isSettai
|
||||
? serifs.reversi.startedSettai.replace('{name}', this.userName)
|
||||
: serifs.reversi.started.replace('{name}', this.userName).replace('{strength}', this.strength.toString());
|
||||
? serifs.reversi.startedSettai(this.userName)
|
||||
: serifs.reversi.started(this.userName, this.strength.toString());
|
||||
|
||||
return await this.post(`${text}\n→[観戦する](${this.url})`);
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ export default class TimerModule implements IModule {
|
||||
setTimeout(() => {
|
||||
const name = msg.friend.name;
|
||||
this.ai.sendMessage(msg.userId, {
|
||||
text: name ? serifs.timer.notifyWithName.replace('{time}', str).replace('{name}', name) : serifs.timer.notify.replace('{time}', str)
|
||||
text: serifs.timer.notify(str, name)
|
||||
});
|
||||
}, time);
|
||||
|
||||
|
Reference in New Issue
Block a user