mirror of
https://github.com/syuilo/ai.git
synced 2024-11-22 05:08:00 +00:00
🍫
This commit is contained in:
parent
2cfcfc878b
commit
fc4023791e
|
@ -13,6 +13,7 @@ import TimerModule from './modules/timer';
|
|||
import DiceModule from './modules/dice';
|
||||
import ServerModule from './modules/server';
|
||||
import FollowModule from './modules/follow';
|
||||
import ValentineModule from './modules/valentine';
|
||||
|
||||
import * as request from 'request-promise-native';
|
||||
import IModule from './module';
|
||||
|
@ -41,6 +42,7 @@ promiseRetry(retry => {
|
|||
new WelcomeModule(),
|
||||
new ServerModule(),
|
||||
new FollowModule(),
|
||||
new ValentineModule(),
|
||||
];
|
||||
|
||||
if (config.keywordEnabled) modules.push(new KeywordModule());
|
||||
|
|
51
src/modules/valentine/index.ts
Normal file
51
src/modules/valentine/index.ts
Normal 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
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
|
@ -258,6 +258,13 @@ export default {
|
|||
notify: (time, name) => name ? `${name}、${time}経ちましたよ!` : `${time}経ちましたよ!`
|
||||
},
|
||||
|
||||
/**
|
||||
* バレンタイン
|
||||
*/
|
||||
valentine: {
|
||||
chocolateForYou: name => name ? `${name}、その... チョコレート作ったのでよかったらどうぞ!🍫` : 'チョコレート作ったのでよかったらどうぞ!🍫',
|
||||
},
|
||||
|
||||
server: {
|
||||
cpu: 'サーバーの負荷が高そうです。大丈夫でしょうか...?'
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue