mirror of
https://github.com/nullnyat/NullcatChan.git
synced 2025-08-05 03:53:50 +09:00
Improve AI
This commit is contained in:
@ -4,6 +4,7 @@ import MessageLike from '../../message-like';
|
||||
import serifs from '../../serifs';
|
||||
import Friend from '../../friend';
|
||||
import getDate from '../../utils/get-date';
|
||||
import includes from '../../utils/includes';
|
||||
|
||||
function zeroPadding(num: number, length: number): string {
|
||||
return ('0000000000' + num).slice(-length);
|
||||
@ -107,8 +108,6 @@ export default class CoreModule implements IModule {
|
||||
}
|
||||
|
||||
private greet = (msg: MessageLike): boolean => {
|
||||
if (!msg.text) return false;
|
||||
|
||||
const incLove = () => {
|
||||
//#region 1日に1回だけ親愛度を上げる
|
||||
const today = getDate();
|
||||
@ -124,19 +123,25 @@ export default class CoreModule implements IModule {
|
||||
//#endregion
|
||||
};
|
||||
|
||||
if (msg.text.includes('こんにちは')) {
|
||||
if (includes(msg.text, ['こんにちは'])) {
|
||||
msg.reply(serifs.core.hello(msg.friend.name));
|
||||
incLove();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (msg.text.includes('おはよ')) {
|
||||
if (includes(msg.text, ['こんばんは'])) {
|
||||
msg.reply(serifs.core.helloNight(msg.friend.name));
|
||||
incLove();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (includes(msg.text, ['おはよ', 'お早う'])) {
|
||||
msg.reply(serifs.core.goodMorning(msg.friend.name));
|
||||
incLove();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (msg.text.includes('おやすみ')) {
|
||||
if (includes(msg.text, ['おやすみ', 'お休み'])) {
|
||||
msg.reply(serifs.core.goodNight(msg.friend.name));
|
||||
incLove();
|
||||
return true;
|
||||
@ -146,8 +151,7 @@ export default class CoreModule implements IModule {
|
||||
}
|
||||
|
||||
private nadenade = (msg: MessageLike): boolean => {
|
||||
if (!msg.text) return false;
|
||||
if (!msg.text.includes('なでなで')) return false;
|
||||
if (!includes(msg.text, ['なでなで'])) return false;
|
||||
|
||||
// メッセージのみ
|
||||
if (!msg.isMessage) return true;
|
||||
@ -175,8 +179,7 @@ export default class CoreModule implements IModule {
|
||||
}
|
||||
|
||||
private kawaii = (msg: MessageLike): boolean => {
|
||||
if (!msg.text) return false;
|
||||
if (!msg.text.includes('かわいい') && !msg.text.includes('可愛い')) return false;
|
||||
if (!includes(msg.text, ['かわいい', '可愛い'])) return false;
|
||||
|
||||
msg.reply(msg.friend.love >= 5 ? serifs.core.kawaii2 : serifs.core.kawaii1);
|
||||
|
||||
|
@ -2,6 +2,7 @@ import 藍 from '../../ai';
|
||||
import IModule from '../../module';
|
||||
import MessageLike from '../../message-like';
|
||||
import serifs from '../../serifs';
|
||||
import includes from '../../utils/includes';
|
||||
|
||||
const hands = [
|
||||
'👏',
|
||||
@ -124,7 +125,7 @@ export default class EmojiModule implements IModule {
|
||||
public install = (ai: 藍) => { }
|
||||
|
||||
public onMention = (msg: MessageLike) => {
|
||||
if (msg.text && (msg.text.includes('絵文字') || msg.text.includes('emoji'))) {
|
||||
if (includes(msg.text, ['絵文字', 'emoji'])) {
|
||||
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;
|
||||
|
@ -3,6 +3,7 @@ import IModule from '../../module';
|
||||
import MessageLike from '../../message-like';
|
||||
import serifs from '../../serifs';
|
||||
import * as seedrandom from 'seedrandom';
|
||||
import includes from '../../utils/includes';
|
||||
|
||||
const omikujis = [
|
||||
'大大吉',
|
||||
@ -30,9 +31,7 @@ export default class FortuneModule implements IModule {
|
||||
public install = (ai: 藍) => { }
|
||||
|
||||
public onMention = (msg: MessageLike) => {
|
||||
if (msg.text == null) return false;
|
||||
|
||||
if (msg.text.includes('占') || msg.text.includes('うらな') || msg.text.includes('運勢') || msg.text.includes('おみくじ')) {
|
||||
if (includes(msg.text, ['占', 'うらな', '運勢', 'おみくじ'])) {
|
||||
const date = new Date();
|
||||
const seed = `${date.getFullYear()}/${date.getMonth()}/${date.getDay()}@${msg.userId}`;
|
||||
const rng = seedrandom(seed);
|
||||
|
@ -4,6 +4,7 @@ import IModule from '../../module';
|
||||
import MessageLike from '../../message-like';
|
||||
import serifs from '../../serifs';
|
||||
import getCollection from '../../utils/get-collection';
|
||||
import includes from '../../utils/includes';
|
||||
|
||||
export default class GuessingGameModule implements IModule {
|
||||
public readonly name = 'guessingGame';
|
||||
@ -28,7 +29,7 @@ export default class GuessingGameModule implements IModule {
|
||||
}
|
||||
|
||||
public onMention = (msg: MessageLike) => {
|
||||
if (msg.text && (msg.text.includes('数当て') || msg.text.includes('数あて'))) {
|
||||
if (includes(msg.text, ['数当て', '数あて'])) {
|
||||
const exist = this.guesses.findOne({
|
||||
userId: msg.userId,
|
||||
isEnded: false
|
||||
|
@ -9,6 +9,7 @@ import * as WebSocket from 'ws';
|
||||
import Friend from '../../friend';
|
||||
import getDate from '../../utils/get-date';
|
||||
import { User } from '../../misskey/user';
|
||||
import includes from '../../utils/includes';
|
||||
|
||||
export default class ReversiModule implements IModule {
|
||||
public readonly name = 'reversi';
|
||||
@ -45,7 +46,7 @@ export default class ReversiModule implements IModule {
|
||||
}
|
||||
|
||||
public onMention = (msg: MessageLike) => {
|
||||
if (msg.text && (msg.text.includes('リバーシ') || msg.text.includes('りばーし') || msg.text.includes('オセロ') || msg.text.includes('おせろ') || msg.text.toLowerCase().includes('reversi'))) {
|
||||
if (includes(msg.text, ['リバーシ', 'オセロ', 'reversi', 'othello'])) {
|
||||
if (config.reversiEnabled) {
|
||||
msg.reply(serifs.reversi.ok);
|
||||
|
||||
|
Reference in New Issue
Block a user