Fix parse-domain

This commit is contained in:
Dragon Fire
2024-03-20 17:09:53 -04:00
parent 845e57c725
commit 51a81624f3
5 changed files with 21 additions and 7 deletions
+4
View File
@@ -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();
+2 -3
View File
@@ -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')
+2 -3
View File
@@ -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')
+7
View File
@@ -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
View File
@@ -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');