mirror of
https://github.com/syuilo/ai.git
synced 2024-11-09 23:48:01 +00:00
Refactor
This commit is contained in:
parent
d458919c81
commit
c03b549b12
|
@ -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) {
|
||||||
// メンションされたとき
|
// メンションされたとき
|
||||||
|
|
24
src/index.ts
24
src/index.ts
|
@ -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! ---');
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue