Reject feedback messages if they contain links, increased image request timeout, some other fixes
This commit is contained in:
parent
23eb83d7b6
commit
ba664fd19a
7 changed files with 14 additions and 9 deletions
|
@ -1,7 +1,9 @@
|
|||
const client = require("../utils/client.js");
|
||||
const regex = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#/%?=~_|!:,.;]*[-A-Z0-9+&@#/%=~_|])/ig;
|
||||
|
||||
exports.run = async (message, args) => {
|
||||
if (args.length !== 0) {
|
||||
if (regex.test(args.join(" "))) return `${message.author.mention}, you can't send a message containing a URL. If you want to report an issue, please join the esmBot Support server instead.`;
|
||||
const feedbackChannel = client.guilds.get("592399417676529688").channels.get("592429860769497098");
|
||||
feedbackChannel.createMessage({
|
||||
embed: {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
const magick = require("../build/Release/image.node");
|
||||
const { promisify } = require("util");
|
||||
const { clean } = require("../utils/misc.js");
|
||||
|
||||
exports.run = async (message) => {
|
||||
const image = await require("../utils/imagedetect.js")(message);
|
||||
|
@ -7,7 +8,7 @@ exports.run = async (message) => {
|
|||
message.channel.sendTyping();
|
||||
const {qrText, missing} = await promisify(magick.qrread)(image.path);
|
||||
if (missing) return `${message.author.mention}, I couldn't find a QR code!`;
|
||||
return `\`\`\`\n${qrText}\n\`\`\``;
|
||||
return `\`\`\`\n${await clean(qrText)}\n\`\`\``;
|
||||
};
|
||||
|
||||
exports.category = 1;
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
const fs = require("fs");
|
||||
const { promisify } = require("util");
|
||||
const client = require("../utils/client.js");
|
||||
const database = require("../utils/database.js");
|
||||
const logger = require("../utils/logger.js");
|
||||
|
@ -47,7 +46,7 @@ module.exports = async (message) => {
|
|||
} else if (typeof result === "object" && result.file) {
|
||||
if (result.file.length > 8388119 && process.env.TEMPDIR !== "") {
|
||||
const filename = `${Math.random().toString(36).substring(2, 15)}.${result.name.split(".")[1]}`;
|
||||
await promisify(fs.writeFile)(`${process.env.TEMPDIR}/${filename}`, result.file);
|
||||
await fs.promises.writeFile(`${process.env.TEMPDIR}/${filename}`, result.file);
|
||||
await client.createMessage(message.channel.id, {
|
||||
embed: {
|
||||
color: 16711680,
|
||||
|
|
|
@ -111,5 +111,6 @@
|
|||
"Schmelf?",
|
||||
"Troll",
|
||||
"ay yo the pizza here",
|
||||
"100 gecs"
|
||||
"100 gecs",
|
||||
"with limited resources"
|
||||
]
|
|
@ -9,6 +9,8 @@ ${process.env.NODE_ENV === "development" ? "\n**You are currently using esmBot D
|
|||
|
||||
Default prefix is \`&\`.
|
||||
|
||||
**Want to help support esmBot's development? Consider donating on Patreon!** https://patreon.com/TheEssem
|
||||
|
||||
> Tip: You can get more info about a command by using \`help [command]\`.
|
||||
|
||||
## Table of Contents
|
||||
|
|
|
@ -12,7 +12,7 @@ const typeCheck = async (image, image2, gifv = false) => {
|
|||
const controller = new AbortController();
|
||||
const timeout = setTimeout(() => {
|
||||
controller.abort();
|
||||
}, 15000);
|
||||
}, 25000);
|
||||
try {
|
||||
const imageRequest = await fetch(image, { signal: controller.signal });
|
||||
const imageBuffer = await imageRequest.buffer();
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
module.exports = (string) => {
|
||||
var protocolAndDomainRE = /^(?:\w+:)?\/\/(\S+)$/;
|
||||
var domainRE = /^[^\s.]+\.\S{2,}$/;
|
||||
var match = string.match(protocolAndDomainRE);
|
||||
const protocolAndDomainRE = /^(?:\w+:)?\/\/(\S+)$/;
|
||||
const domainRE = /^[^\s.]+\.\S{2,}$/;
|
||||
const match = string.match(protocolAndDomainRE);
|
||||
if (!match) {
|
||||
return false;
|
||||
}
|
||||
var everythingAfterProtocol = match[1];
|
||||
const everythingAfterProtocol = match[1];
|
||||
if (!everythingAfterProtocol) {
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue