ai/src/index.ts
syuilo 990cd7ccd2
✌️
2018-12-03 17:12:47 +09:00

54 lines
1.4 KiB
TypeScript

import from './ai';
import config from './config';
import CoreModule from './modules/core';
import ReversiModule from './modules/reversi';
import PingModule from './modules/ping';
import EmojiModule from './modules/emoji';
import FortuneModule from './modules/fortune';
import GuessingGameModule from './modules/guessing-game';
import KeywordModule from './modules/keyword';
import WelcomeModule from './modules/welcome';
import TimerModule from './modules/timer';
import DiceModule from './modules/dice';
import ServerModule from './modules/server';
import FollowModule from './modules/follow';
import * as request from 'request-promise-native';
import IModule from './module';
const promiseRetry = require('promise-retry');
console.log('--- starting ai... ---');
promiseRetry(retry => {
return request.post(`${config.apiUrl}/i`, {
json: {
i: config.i
}
}).catch(retry);
}).then(account => {
console.log(`account fetched: @${account.username}`);
const modules: IModule[] = [
new EmojiModule(),
new FortuneModule(),
new GuessingGameModule(),
new ReversiModule(),
new TimerModule(),
new DiceModule(),
new CoreModule(),
new PingModule(),
new WelcomeModule(),
new ServerModule(),
new FollowModule(),
];
if (config.keywordEnabled) modules.push(new KeywordModule());
new (account, modules);
console.log('--- ai started! ---');
}).catch(e => {
console.error('failed to fetch account', e);
});