Skip to content

Commit

Permalink
hotfix negative amounts in mls crashing the server
Browse files Browse the repository at this point in the history
  • Loading branch information
wsrvn committed Feb 2, 2024
1 parent 510ebed commit 1ae2574
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions plugins/autistic_plugins/FunCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ tm.commands.add(
help: config.commands.mls.help,
params: [{ name: 'amount', type: 'int' }, { name: 'size', type: 'int', optional: true }],
callback: async (info: tm.MessageInfo, amount: number, size?: number): Promise<void> => {
amount = ~~(Math.abs(amount))
if (amount <= 0) { return }
// todo size check
if (info.privilege === 4 || amount <= config.commands.shared.notOwnerLimit) {
await h.displayManialinks(amount, size)
Expand All @@ -114,7 +114,7 @@ tm.commands.add(
help: config.commands.imls.help,
params: [{ name: 'amount', type: 'int', optional: true }],
callback: async (info: tm.MessageInfo, amount?: number): Promise<void> => {
amount = ~~(Math.abs(amount ?? 1))
if (amount === undefined) { amount = 1 } else if (amount <= 0) { return }
if (info.privilege === 4 || amount <= config.commands.shared.notOwnerLimit) {
await h.displayManialinks(amount, undefined, true, await h.getDbImages())
await new Promise(resolve => setTimeout(resolve, config.commands.shared.clearInterval * 1000))
Expand Down Expand Up @@ -143,14 +143,14 @@ tm.commands.add(
params: [{ name: 'url' }],
callback: async (info: tm.MessageInfo, url: string): Promise<void> => {
let urls = ""
if (url.charAt(url.length-1) !== '/') {
if (url.charAt(url.length - 1) !== '/') {
urls = url + "/"
} else {
urls = url
}
const link = new URL(urls)
const domain = link.protocol + "//" + link.hostname
const response = await fetch(urls, {method: 'GET'}).catch((err: Error) => err)
const response = await fetch(urls, { method: 'GET' }).catch((err: Error) => err)
if (response instanceof Error) {
tm.sendMessage("Failed getting directory listing.", info.login)
return
Expand All @@ -163,9 +163,9 @@ tm.commands.add(
const xml: Document = new DOMParser({
locator: {},
errorHandler: {
warning: function(w) {},
error: function(e) {},
fatalError: function (f) {}
warning: function (w) { },
error: function (e) { },
fatalError: function (f) { }
}
}).parseFromString(html, "text/xml")
xpath.select(`//a/@href`, xml).map(a => (a as any).value).forEach(a => {
Expand All @@ -184,7 +184,7 @@ tm.commands.add(
help: config.commands.smls.help,
params: [{ name: 'amount', type: 'int' }, { name: 'size', type: 'int', optional: true }],
callback: async (info: tm.MessageInfo, amount: number, size?: number): Promise<void> => {
amount = ~~(Math.abs(amount))
if (amount <= 0) { return }
const seed: number = h.getRandom(1, 10)
if (info.privilege === 4 || amount <= config.commands.shared.notOwnerLimit) {
await h.displayManialinks(amount, size, false, undefined, 'MedalsBig', 'MedalSlot',
Expand Down

0 comments on commit 1ae2574

Please sign in to comment.