mirror of
https://github.com/syuilo/ai.git
synced 2024-11-22 05:08:00 +00:00
✌️
This commit is contained in:
parent
ab4fbb2e33
commit
3d10634bcd
|
@ -46,7 +46,7 @@ export default class 藍 {
|
||||||
|
|
||||||
public friends: loki.Collection<FriendDoc>;
|
public friends: loki.Collection<FriendDoc>;
|
||||||
|
|
||||||
constructor(account: User, ready?: Function) {
|
constructor(account: User, ready: (run: Function) => void) {
|
||||||
this.account = account;
|
this.account = account;
|
||||||
|
|
||||||
this.db = new loki('memory.json', {
|
this.db = new loki('memory.json', {
|
||||||
|
@ -57,7 +57,7 @@ export default class 藍 {
|
||||||
if (err) {
|
if (err) {
|
||||||
this.log(chalk.red(`Failed to load DB: ${err}`));
|
this.log(chalk.red(`Failed to load DB: ${err}`));
|
||||||
} else {
|
} else {
|
||||||
if (ready) ready();
|
ready(this.run);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -69,7 +69,7 @@ export default class 藍 {
|
||||||
}
|
}
|
||||||
|
|
||||||
@autobind
|
@autobind
|
||||||
public run() {
|
private run() {
|
||||||
//#region Init DB
|
//#region Init DB
|
||||||
this.contexts = getCollection(this.db, 'contexts', {
|
this.contexts = getCollection(this.db, 'contexts', {
|
||||||
indices: ['key']
|
indices: ['key']
|
||||||
|
|
|
@ -40,8 +40,7 @@ promiseRetry(retry => {
|
||||||
|
|
||||||
log('Starting AiOS...');
|
log('Starting AiOS...');
|
||||||
|
|
||||||
const ai = new 藍(account);
|
const ai = new 藍(account, run => {
|
||||||
|
|
||||||
new EmojiModule(ai);
|
new EmojiModule(ai);
|
||||||
new FortuneModule(ai);
|
new FortuneModule(ai);
|
||||||
new GuessingGameModule(ai);
|
new GuessingGameModule(ai);
|
||||||
|
@ -57,7 +56,8 @@ promiseRetry(retry => {
|
||||||
new ValentineModule(ai);
|
new ValentineModule(ai);
|
||||||
if (config.keywordEnabled) new KeywordModule(ai);
|
if (config.keywordEnabled) new KeywordModule(ai);
|
||||||
|
|
||||||
ai.run();
|
run();
|
||||||
|
});
|
||||||
}).catch(e => {
|
}).catch(e => {
|
||||||
log(chalk.red('Failed to fetch the account'));
|
log(chalk.red('Failed to fetch the account'));
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue