3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-03-18 15:00:00 +00:00

added a limit of 2048 to the resize command so it cant cripple the bot

This commit is contained in:
roflmaoqwerty 2020-02-20 22:57:35 +11:00 committed by Miikka
parent 60fdae5df9
commit 22982b8113

View file

@ -1539,6 +1539,7 @@ export class UtilityPlugin extends ZeppelinPlugin<TConfigSchema> {
async jumboCmd(msg: Message, args: { emoji: string }) { async jumboCmd(msg: Message, args: { emoji: string }) {
// Get emoji url // Get emoji url
const config = this.getConfig(); const config = this.getConfig();
const size = config.jumbo_size > 2048 ? 2048 : config.jumbo_size;
const emojiRegex = new RegExp(`(<.*:).*:(\\d+)`); const emojiRegex = new RegExp(`(<.*:).*:(\\d+)`);
const results = emojiRegex.exec(args.emoji); const results = emojiRegex.exec(args.emoji);
let extention = ".png"; let extention = ".png";
@ -1551,7 +1552,7 @@ export class UtilityPlugin extends ZeppelinPlugin<TConfigSchema> {
} }
url += `${results[2]}${extention}`; url += `${results[2]}${extention}`;
if (extention === ".png") { if (extention === ".png") {
const image = await this.resizeBuffer(await this.getBufferFromUrl(url), config.jumbo_size, config.jumbo_size); const image = await this.resizeBuffer(await this.getBufferFromUrl(url), size, size);
file = { file = {
name: `emoji${extention}`, name: `emoji${extention}`,
file: image, file: image,
@ -1567,11 +1568,11 @@ export class UtilityPlugin extends ZeppelinPlugin<TConfigSchema> {
let url = CDN_URL + `/${twemoji.convert.toCodePoint(args.emoji)}.svg`; let url = CDN_URL + `/${twemoji.convert.toCodePoint(args.emoji)}.svg`;
let image; let image;
try { try {
image = await this.resizeBuffer(await this.getBufferFromUrl(url), config.jumbo_size, config.jumbo_size); image = await this.resizeBuffer(await this.getBufferFromUrl(url), size, size);
} catch { } catch {
if (url.toLocaleLowerCase().endsWith("fe0f.svg")) { if (url.toLocaleLowerCase().endsWith("fe0f.svg")) {
url = url.slice(0, url.lastIndexOf("-fe0f")) + ".svg"; url = url.slice(0, url.lastIndexOf("-fe0f")) + ".svg";
image = await this.resizeBuffer(await this.getBufferFromUrl(url), config.jumbo_size, config.jumbo_size); image = await this.resizeBuffer(await this.getBufferFromUrl(url), size, size);
} }
} }
file = { file = {