mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:36:43 +02:00
66 lines
2.3 KiB
JavaScript
66 lines
2.3 KiB
JavaScript
const CommandClient = require('../framework/Client');
|
|
const request = require('node-superfetch');
|
|
const winston = require('winston');
|
|
const moment = require('moment-timezone');
|
|
const Redis = require('./Redis');
|
|
const JeopardyScrape = require('./JeopardyScrape');
|
|
const Tensorflow = require('./Tensorflow');
|
|
const FontManager = require('./fonts/FontManager');
|
|
const PhoneManager = require('./phone/PhoneManager');
|
|
const TimerManager = require('./remind/TimerManager');
|
|
const PokemonStore = require('./pokemon/PokemonStore');
|
|
const AvatarChanger = require('./AvatarChanger');
|
|
const activities = require('./Activity');
|
|
const { REPORT_CHANNEL_ID, JOIN_LEAVE_CHANNEL_ID } = process.env;
|
|
|
|
module.exports = class XiaoClient extends CommandClient {
|
|
constructor(options) {
|
|
super(options);
|
|
|
|
this.logger = winston.createLogger({
|
|
transports: [new winston.transports.Console()],
|
|
format: winston.format.combine(
|
|
winston.format.timestamp({ format: 'MM/DD/YYYY HH:mm:ss' }),
|
|
winston.format.printf(log => `[${log.timestamp}] [${log.level.toUpperCase()}]: ${log.message}`)
|
|
)
|
|
});
|
|
this.fonts = new FontManager(this);
|
|
this.redis = new Redis(this);
|
|
this.timers = new TimerManager(this);
|
|
this.pokemon = new PokemonStore();
|
|
this.jeopardy = new JeopardyScrape(this);
|
|
this.dispatchers = new Map();
|
|
this.cleverbots = new Map();
|
|
this.phone = new PhoneManager(this);
|
|
this.tensorflow = new Tensorflow(this);
|
|
this.activities = activities;
|
|
this.avatarChanger = new AvatarChanger(this);
|
|
this.adultSiteList = null;
|
|
}
|
|
|
|
setTimezones() {
|
|
moment.tz.link('America/Vancouver|Neopia');
|
|
moment.tz.link('America/Los_Angeles|Discord');
|
|
moment.tz.link('America/New_York|Lily');
|
|
}
|
|
|
|
async fetchAdultSiteList(force = false) {
|
|
if (!force && this.adultSiteList) return this.adultSiteList;
|
|
const { text } = await request
|
|
.get('https://raw.githubusercontent.com/blocklistproject/Lists/master/alt-version/porn-nl.txt');
|
|
this.adultSiteList = text.split('\n').filter(site => site && !site.startsWith('#'));
|
|
setTimeout(() => this.fetchAdultSiteList(true), 8.64e+7);
|
|
return this.adultSiteList;
|
|
}
|
|
|
|
fetchReportChannel() {
|
|
if (!REPORT_CHANNEL_ID) return null;
|
|
return this.channels.fetch(REPORT_CHANNEL_ID);
|
|
}
|
|
|
|
fetchJoinLeaveChannel() {
|
|
if (!JOIN_LEAVE_CHANNEL_ID) return null;
|
|
return this.channels.fetch(JOIN_LEAVE_CHANNEL_ID);
|
|
}
|
|
};
|