mirror of
https://github.com/syuilo/ai.git
synced 2024-11-22 05:08:00 +00:00
Refactor
This commit is contained in:
parent
d458919c81
commit
c03b549b12
|
@ -40,8 +40,9 @@ export default class 藍 {
|
|||
|
||||
public friends: loki.Collection<FriendDoc>;
|
||||
|
||||
constructor(account: any) {
|
||||
constructor(account: any, modules: IModule[]) {
|
||||
this.account = account;
|
||||
this.modules = modules;
|
||||
|
||||
this.db = new loki('memory.json', {
|
||||
autoload: true,
|
||||
|
@ -116,10 +117,6 @@ export default class 藍 {
|
|||
//#endregion
|
||||
}
|
||||
|
||||
public install = (module: IModule) => {
|
||||
this.modules.push(module);
|
||||
}
|
||||
|
||||
private onMessage = (msg: any) => {
|
||||
switch (msg.type) {
|
||||
// メンションされたとき
|
||||
|
|
24
src/index.ts
24
src/index.ts
|
@ -12,6 +12,7 @@ import WelcomeModule from './modules/welcome';
|
|||
import TimerModule from './modules/timer';
|
||||
|
||||
import * as request from 'request-promise-native';
|
||||
import IModule from './module';
|
||||
const promiseRetry = require('promise-retry');
|
||||
|
||||
console.log('--- starting ai... ---');
|
||||
|
@ -25,17 +26,20 @@ promiseRetry(retry => {
|
|||
}).then(account => {
|
||||
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());
|
||||
ai.install(new PingModule());
|
||||
ai.install(new WelcomeModule());
|
||||
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());
|
||||
if (config.keywordEnabled) modules.push(new KeywordModule());
|
||||
|
||||
new 藍(account, modules);
|
||||
|
||||
console.log('--- ai started! ---');
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue