mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 15:07:42 +02:00
Fix parse-domain
This commit is contained in:
@@ -203,6 +203,10 @@ client.on('ready', async () => {
|
||||
client.logger.error(`[TIMEZONES] Failed to set timezones\n${err.stack}`);
|
||||
}
|
||||
|
||||
// Set up parse-domain
|
||||
await client.loadParseDomain();
|
||||
client.logger.info('[PARSE DOMAIN] parse-domain loaded.');
|
||||
|
||||
// Fetch adult site list
|
||||
try {
|
||||
await client.fetchAdultSiteList();
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
const Command = require('../../framework/Command');
|
||||
const request = require('node-superfetch');
|
||||
const { parseDomain, ParseResultType } = import('parse-domain');
|
||||
const { GODADDY_KEY, GODADDY_SECRET } = process.env;
|
||||
|
||||
module.exports = class DomainAvailableCommand extends Command {
|
||||
@@ -30,8 +29,8 @@ module.exports = class DomainAvailableCommand extends Command {
|
||||
}
|
||||
|
||||
async run(msg, { url }) {
|
||||
const { type, domain, topLevelDomains } = parseDomain(url.hostname);
|
||||
if (type !== ParseResultType.Listed) return msg.reply('This domain is not supported.');
|
||||
const { type, domain, topLevelDomains } = this.client.parseDomain(url.hostname);
|
||||
if (type !== this.client.ParseResultType.Listed) return msg.reply('This domain is not supported.');
|
||||
try {
|
||||
const { body } = await request
|
||||
.get('https://api.godaddy.com/v1/domains/available')
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
const Command = require('../../framework/Command');
|
||||
const request = require('node-superfetch');
|
||||
const { parseDomain, ParseResultType } = import('parse-domain');
|
||||
|
||||
module.exports = class IsItDownCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -28,8 +27,8 @@ module.exports = class IsItDownCommand extends Command {
|
||||
}
|
||||
|
||||
async run(msg, { url }) {
|
||||
const { type, domain, topLevelDomains } = parseDomain(url.hostname);
|
||||
if (type !== ParseResultType.Listed) return msg.reply('This domain is not supported.');
|
||||
const { type, domain, topLevelDomains } = this.client.parseDomain(url.hostname);
|
||||
if (type !== this.client.ParseResultType.Listed) return msg.reply('This domain is not supported.');
|
||||
try {
|
||||
const { text } = await request
|
||||
.post('https://www.isitdownrightnow.com/check.php')
|
||||
|
||||
@@ -55,6 +55,13 @@ module.exports = class XiaoClient extends CommandClient {
|
||||
this.nsfwModel = null;
|
||||
}
|
||||
|
||||
async loadParseDomain() {
|
||||
const parseDomainModule = await import('parse-domain');
|
||||
this.parseDomain = parseDomainModule.parseDomain;
|
||||
this.ParseResultType = parseDomainModule.ParseResultType;
|
||||
return parseDomainModule;
|
||||
}
|
||||
|
||||
async registerFontsIn(filepath) {
|
||||
const files = fs.readdirSync(filepath);
|
||||
for (const file of files) {
|
||||
|
||||
+6
-1
@@ -3,7 +3,12 @@ const crypto = require('crypto');
|
||||
const request = require('node-superfetch');
|
||||
const fs = require('fs');
|
||||
const tf = require('@tensorflow/tfjs-node');
|
||||
const { parseDomain, ParseResultType } = import('parse-domain');
|
||||
let parseDomain;
|
||||
let ParseResultType;
|
||||
import('parse-domain').then(loadedModule => {
|
||||
parseDomain = loadedModule.parseDomain;
|
||||
ParseResultType = loadedModule.ParseResultType;
|
||||
});
|
||||
const { decode: decodeHTML } = require('html-entities');
|
||||
const { stripIndents } = require('common-tags');
|
||||
const { URL } = require('url');
|
||||
|
||||
Reference in New Issue
Block a user