Skip to content

Commit

Permalink
Comment out URL shortener as this was causing build issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
Pickysaurus committed Aug 28, 2024
1 parent ff49866 commit 794f1e2
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 25 deletions.
4 changes: 2 additions & 2 deletions src/events/ready.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { DiscordEventInterface, ClientExt } from '../types/DiscordTypes';
import { NewsFeedManager } from '../feeds/NewsFeedManager';
import { ModFeedManager } from '../feeds/ModFeedManager';
import { GameFeedManager } from '../feeds/GameFeedManager';
// import { AutoModManager } from '../feeds/AutoModManager';
import { AutoModManager } from '../feeds/AutoModManager';

// Prepare the online status embed for quick reuse.
const onlineEmbed = new EmbedBuilder()
Expand All @@ -25,7 +25,7 @@ const main: DiscordEventInterface = {
client.gameFeeds = GameFeedManager.getInstance(client);
client.modFeeds = ModFeedManager.getInstance(client);
client.newsFeed = NewsFeedManager.getInstance(client);
// client.automod = AutoModManager.getInstance(client);
client.automod = AutoModManager.getInstance(client);
}
catch(err) {
logMessage('Error starting up feeds', err, true);
Expand Down
47 changes: 24 additions & 23 deletions src/feeds/AutoModManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { getUserByNexusModsId } from "../api/users";
import { logMessage } from "../api/util";
import { ClientExt } from "../types/DiscordTypes";
import { IAutomodRule } from "../types/util";
const uu = require('url-unshort')();
// const uu = require('url-unshort')();

const pollTime: number = (1000*60*2); //2 mins

Expand Down Expand Up @@ -262,27 +262,28 @@ async function analyseMod(mod: Partial<IMod>, rules: IAutomodRule[]): Promise<IM
}

async function analyseURLS(text: string): Promise<string[]> {
const regEx = new RegExp(/\b(https?:\/\/.*?\.[a-z]{2,4}\/[^\s\[\]]*\b)/g);
const matches = text.match(regEx);
if (!matches) return [];
// logMessage("URLs in mod description", matches.toString());
const matchUrls: Set<string> = new Set(matches.filter(uri => !uri.toLowerCase().includes('nexusmods.com')));
if (!matchUrls.size) return [];
// logMessage("URLs to check in mod description", matchUrls);
const result: string[] = []
for (const url of matchUrls.values()) {
try {
const finalUrl = await uu.expand(url);
if (finalUrl) {
logMessage("Expanded URL", { url, finalUrl })
result.push(`${url} => ${finalUrl}`)
}
// else logMessage('Could not expand url', url)
return []
// const regEx = new RegExp(/\b(https?:\/\/.*?\.[a-z]{2,4}\/[^\s\[\]]*\b)/g);
// const matches = text.match(regEx);
// if (!matches) return [];
// // logMessage("URLs in mod description", matches.toString());
// const matchUrls: Set<string> = new Set(matches.filter(uri => !uri.toLowerCase().includes('nexusmods.com')));
// if (!matchUrls.size) return [];
// // logMessage("URLs to check in mod description", matchUrls);
// const result: string[] = []
// for (const url of matchUrls.values()) {
// try {
// const finalUrl = await uu.expand(url);
// if (finalUrl) {
// logMessage("Expanded URL", { url, finalUrl })
// result.push(`${url} => ${finalUrl}`)
// }
// // else logMessage('Could not expand url', url)

}
catch(err) {
logMessage("Error expanding URL", { err, url }, true);
}
}
return result;
// }
// catch(err) {
// logMessage("Error expanding URL", { err, url }, true);
// }
// }
// return result;
}

0 comments on commit 794f1e2

Please sign in to comment.