This commit is contained in:
syuilo 2018-09-02 21:50:57 +09:00
parent 050ed27e2b
commit 160ed4a191
7 changed files with 19 additions and 20 deletions

View file

@ -1,6 +1,7 @@
import from './ai';
import Friend from './friend';
import { User } from './misskey/user';
import includes from './utils/includes';
const delay = require('timeout-as-promise');
export default class MessageLike {
@ -62,4 +63,8 @@ export default class MessageLike {
});
}
}
public includes = (words: string[]): boolean => {
return includes(this.text, words);
}
}

View file

@ -4,7 +4,6 @@ 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);
@ -137,25 +136,25 @@ export default class CoreModule implements IModule {
.sort((a, b) => a.length < b.length ? 1 : -1)[0]
.substr(1);
if (includes(msg.text, ['こんにちは', 'こんにちわ'])) {
if (msg.includes(['こんにちは', 'こんにちわ'])) {
msg.reply(serifs.core.hello(msg.friend.name));
incLove();
return true;
}
if (includes(msg.text, ['こんばんは', 'こんばんわ'])) {
if (msg.includes(['こんばんは', 'こんばんわ'])) {
msg.reply(serifs.core.helloNight(msg.friend.name));
incLove();
return true;
}
if (includes(msg.text, ['おは', 'お早う'])) {
if (msg.includes(['おは', 'お早う'])) {
msg.reply(serifs.core.goodMorning(tension, msg.friend.name));
incLove();
return true;
}
if (includes(msg.text, ['おやすみ', 'お休み'])) {
if (msg.includes(['おやすみ', 'お休み'])) {
msg.reply(serifs.core.goodNight(msg.friend.name));
incLove();
return true;
@ -165,7 +164,7 @@ export default class CoreModule implements IModule {
}
private nadenade = (msg: MessageLike): boolean => {
if (!includes(msg.text, ['なでなで'])) return false;
if (!msg.includes(['なでなで'])) return false;
// メッセージのみ
if (!msg.isMessage) return true;
@ -199,7 +198,7 @@ export default class CoreModule implements IModule {
}
private kawaii = (msg: MessageLike): boolean => {
if (!includes(msg.text, ['かわいい', '可愛い'])) return false;
if (!msg.includes(['かわいい', '可愛い'])) return false;
msg.reply(
msg.friend.love >= 5 ? serifs.core.kawaii.love :
@ -210,7 +209,7 @@ export default class CoreModule implements IModule {
}
private humu = (msg: MessageLike): boolean => {
if (!includes(msg.text, ['踏んで'])) return false;
if (!msg.includes(['踏んで'])) return false;
// メッセージのみ
if (!msg.isMessage) return true;
@ -223,7 +222,7 @@ export default class CoreModule implements IModule {
}
private batou = (msg: MessageLike): boolean => {
if (!includes(msg.text, ['罵倒して', '罵って'])) return false;
if (!msg.includes(['罵倒して', '罵って'])) return false;
// メッセージのみ
if (!msg.isMessage) return true;
@ -237,7 +236,7 @@ export default class CoreModule implements IModule {
}
private ponkotu = (msg: MessageLike): boolean => {
if (!includes(msg.text, ['ぽんこつ'])) return false;
if (!msg.includes(['ぽんこつ'])) return false;
msg.friend.decLove();

View file

@ -2,7 +2,6 @@ import 藍 from '../../ai';
import IModule from '../../module';
import MessageLike from '../../message-like';
import serifs from '../../serifs';
import includes from '../../utils/includes';
const hands = [
'👏',
@ -125,7 +124,7 @@ export default class EmojiModule implements IModule {
public install = (ai: ) => { }
public onMention = (msg: MessageLike) => {
if (includes(msg.text, ['絵文字', 'emoji'])) {
if (msg.includes(['絵文字', '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;

View file

@ -3,7 +3,6 @@ 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 = [
'大大吉',
@ -31,7 +30,7 @@ export default class FortuneModule implements IModule {
public install = (ai: ) => { }
public onMention = (msg: MessageLike) => {
if (includes(msg.text, ['占', 'うらな', '運勢', 'おみくじ'])) {
if (msg.includes(['占', 'うらな', '運勢', 'おみくじ'])) {
const date = new Date();
const seed = `${date.getFullYear()}/${date.getMonth()}/${date.getDay()}@${msg.userId}`;
const rng = seedrandom(seed);

View file

@ -4,7 +4,6 @@ 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';
@ -29,7 +28,7 @@ export default class GuessingGameModule implements IModule {
}
public onMention = (msg: MessageLike) => {
if (includes(msg.text, ['数当て', '数あて'])) {
if (msg.includes(['数当て', '数あて'])) {
const exist = this.guesses.findOne({
userId: msg.userId,
isEnded: false

View file

@ -8,8 +8,6 @@ import MessageLike from '../../message-like';
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';
@ -46,7 +44,7 @@ export default class ReversiModule implements IModule {
}
public onMention = (msg: MessageLike) => {
if (includes(msg.text, ['リバーシ', 'オセロ', 'reversi', 'othello'])) {
if (msg.includes(['リバーシ', 'オセロ', 'reversi', 'othello'])) {
if (config.reversiEnabled) {
msg.reply(serifs.reversi.ok);

View file

@ -1,4 +1,4 @@
import { hiraganaToKatagana, zenkakuToHankaku, hankakuToZenkaku } from './japanese';
import { hiraganaToKatagana, hankakuToZenkaku } from './japanese';
export default function(text: string, words: string[]): boolean {
if (text == null) return false;