This commit is contained in:
syuilo 2019-01-12 13:14:16 +09:00
parent 2cfcfc878b
commit fc4023791e
No known key found for this signature in database
GPG key ID: BDC4C49D06AB9D69
3 changed files with 60 additions and 0 deletions

View file

@ -13,6 +13,7 @@ import TimerModule from './modules/timer';
import DiceModule from './modules/dice'; import DiceModule from './modules/dice';
import ServerModule from './modules/server'; import ServerModule from './modules/server';
import FollowModule from './modules/follow'; import FollowModule from './modules/follow';
import ValentineModule from './modules/valentine';
import * as request from 'request-promise-native'; import * as request from 'request-promise-native';
import IModule from './module'; import IModule from './module';
@ -41,6 +42,7 @@ promiseRetry(retry => {
new WelcomeModule(), new WelcomeModule(),
new ServerModule(), new ServerModule(),
new FollowModule(), new FollowModule(),
new ValentineModule(),
]; ];
if (config.keywordEnabled) modules.push(new KeywordModule()); if (config.keywordEnabled) modules.push(new KeywordModule());

View file

@ -0,0 +1,51 @@
import from '../../ai';
import IModule from '../../module';
import Friend from '../../friend';
import serifs from '../../serifs';
export default class ValentineModule implements IModule {
public readonly name = 'valentine';
private ai: ;
public install = (ai: ) => {
this.ai = ai;
this.crawleValentine();
setInterval(this.crawleValentine, 1000 * 60 * 3);
}
/**
*
*/
private crawleValentine = () => {
const now = new Date();
const isValentine = now.getMonth() == 1 && now.getDate() == 14;
if (!isValentine) return;
const date = `${now.getFullYear()}-${now.getMonth()}-${now.getDate()}`;
const friends = this.ai.friends.find({} as any);
friends.forEach(f => {
const friend = new Friend(this.ai, { doc: f });
// 親愛度が7以上必要
if (friend.love < 7) return;
const data = friend.getPerModulesData(this);
if (data.lastChocolated == date) return;
data.lastChocolated = date;
friend.setPerModulesData(this, data);
const text = serifs.valentine.chocolateForYou(friend.name);
this.ai.sendMessage(friend.userId, {
text: text
});
});
}
}

View file

@ -258,6 +258,13 @@ export default {
notify: (time, name) => name ? `${name}${time}経ちましたよ!` : `${time}経ちましたよ!` notify: (time, name) => name ? `${name}${time}経ちましたよ!` : `${time}経ちましたよ!`
}, },
/**
*
*/
valentine: {
chocolateForYou: name => name ? `${name}、その... チョコレート作ったのでよかったらどうぞ!🍫` : 'チョコレート作ったのでよかったらどうぞ!🍫',
},
server: { server: {
cpu: 'サーバーの負荷が高そうです。大丈夫でしょうか...' cpu: 'サーバーの負荷が高そうです。大丈夫でしょうか...'
}, },