This commit is contained in:
syuilo 2018-08-28 16:02:20 +09:00
parent d458919c81
commit c03b549b12
2 changed files with 16 additions and 15 deletions

View file

@ -40,8 +40,9 @@ export default class 藍 {
public friends: loki.Collection<FriendDoc>; public friends: loki.Collection<FriendDoc>;
constructor(account: any) { constructor(account: any, modules: IModule[]) {
this.account = account; this.account = account;
this.modules = modules;
this.db = new loki('memory.json', { this.db = new loki('memory.json', {
autoload: true, autoload: true,
@ -116,10 +117,6 @@ export default class 藍 {
//#endregion //#endregion
} }
public install = (module: IModule) => {
this.modules.push(module);
}
private onMessage = (msg: any) => { private onMessage = (msg: any) => {
switch (msg.type) { switch (msg.type) {
// メンションされたとき // メンションされたとき

View file

@ -12,6 +12,7 @@ import WelcomeModule from './modules/welcome';
import TimerModule from './modules/timer'; import TimerModule from './modules/timer';
import * as request from 'request-promise-native'; import * as request from 'request-promise-native';
import IModule from './module';
const promiseRetry = require('promise-retry'); const promiseRetry = require('promise-retry');
console.log('--- starting ai... ---'); console.log('--- starting ai... ---');
@ -25,17 +26,20 @@ promiseRetry(retry => {
}).then(account => { }).then(account => {
console.log(`account fetched: @${account.username}`); console.log(`account fetched: @${account.username}`);
const ai = new (account); const modules: IModule[] = [
new CoreModule(),
new PingModule(),
new WelcomeModule(),
new EmojiModule(),
new FortuneModule(),
new GuessingGameModule(),
new ReversiModule(),
new TimerModule()
];
ai.install(new CoreModule()); if (config.keywordEnabled) modules.push(new KeywordModule());
ai.install(new PingModule());
ai.install(new WelcomeModule()); new (account, modules);
ai.install(new EmojiModule());
ai.install(new FortuneModule());
ai.install(new GuessingGameModule());
ai.install(new ReversiModule());
ai.install(new TimerModule());
if (config.keywordEnabled) ai.install(new KeywordModule());
console.log('--- ai started! ---'); console.log('--- ai started! ---');
}); });