misc.mcserver: 3 min timeout, why not
This commit is contained in:
parent
2499ce6b36
commit
550ac7c0b3
1 changed files with 50 additions and 41 deletions
|
@ -25,7 +25,8 @@ yt.callback = async function(msg, line) {
|
||||||
if (!line) return "Arguments are required.";
|
if (!line) return "Arguments are required.";
|
||||||
|
|
||||||
const req = await fetch(
|
const req = await fetch(
|
||||||
`https://www.googleapis.com/youtube/v3/search?key=${hf.apikeys.google
|
`https://www.googleapis.com/youtube/v3/search?key=${
|
||||||
|
hf.apikeys.google
|
||||||
}&maxResults=5&part=snippet&type=video&q=${encodeURIComponent(line)}`
|
}&maxResults=5&part=snippet&type=video&q=${encodeURIComponent(line)}`
|
||||||
).then((x) => x.json());
|
).then((x) => x.json());
|
||||||
|
|
||||||
|
@ -58,7 +59,8 @@ fyt.callback = async function(msg, line) {
|
||||||
if (!line) return "Arguments are required.";
|
if (!line) return "Arguments are required.";
|
||||||
|
|
||||||
const req = await fetch(
|
const req = await fetch(
|
||||||
`https://www.googleapis.com/youtube/v3/search?key=${hf.apikeys.google
|
`https://www.googleapis.com/youtube/v3/search?key=${
|
||||||
|
hf.apikeys.google
|
||||||
}&maxResults=2&part=snippet&type=video&q=${encodeURIComponent(line)}`
|
}&maxResults=2&part=snippet&type=video&q=${encodeURIComponent(line)}`
|
||||||
).then((x) => x.json());
|
).then((x) => x.json());
|
||||||
|
|
||||||
|
@ -114,7 +116,8 @@ wolfram.callback = async function(msg, line, args, { verbose, v }) {
|
||||||
for (const x in extra) {
|
for (const x in extra) {
|
||||||
embed.fields.push({
|
embed.fields.push({
|
||||||
name: extra[x].title,
|
name: extra[x].title,
|
||||||
value: `[${extra[x].subpods[0].plaintext.length > 0
|
value: `[${
|
||||||
|
extra[x].subpods[0].plaintext.length > 0
|
||||||
? extra[x].subpods[0].plaintext
|
? extra[x].subpods[0].plaintext
|
||||||
: "<click for image>"
|
: "<click for image>"
|
||||||
}](${extra[x].subpods[0].img.src})`,
|
}](${extra[x].subpods[0].img.src})`,
|
||||||
|
@ -182,7 +185,8 @@ gimg.callback = async function(msg, line) {
|
||||||
url: image.url,
|
url: image.url,
|
||||||
},
|
},
|
||||||
footer: {
|
footer: {
|
||||||
text: `Image ${Number(index) + 1}/${images.length
|
text: `Image ${Number(index) + 1}/${
|
||||||
|
images.length
|
||||||
}. Rerun to get a different image.`,
|
}. Rerun to get a different image.`,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -259,8 +263,10 @@ vote.callback = async function(msg, line, topic, { maybe }) {
|
||||||
topic = topic.join(" ");
|
topic = topic.join(" ");
|
||||||
|
|
||||||
return {
|
return {
|
||||||
content: `**${msg.author.username}#${msg.author.discriminator
|
content: `**${msg.author.username}#${
|
||||||
}** has started a vote:\n## __${topic}__\n<:ms_tick:503341995348066313>: Yes\n<:ms_cross:503341994974773250>: No${maybe ? "\n<:ms_tilda:581268710925271095>: Maybe/Uncertain" : ""
|
msg.author.discriminator
|
||||||
|
}** has started a vote:\n## __${topic}__\n<:ms_tick:503341995348066313>: Yes\n<:ms_cross:503341994974773250>: No${
|
||||||
|
maybe ? "\n<:ms_tilda:581268710925271095>: Maybe/Uncertain" : ""
|
||||||
}`,
|
}`,
|
||||||
addReactions: [
|
addReactions: [
|
||||||
":ms_tick:503341995348066313",
|
":ms_tick:503341995348066313",
|
||||||
|
@ -523,7 +529,8 @@ generate.callback = async function(msg, line) {
|
||||||
const title = `Responses for "${safeString(line)}"`;
|
const title = `Responses for "${safeString(line)}"`;
|
||||||
|
|
||||||
const out = {
|
const out = {
|
||||||
content: `Generated in ${formatTime(Date.now() - start)}${retries > 0 ? " with " + retries + " retries" : ""
|
content: `Generated in ${formatTime(Date.now() - start)}${
|
||||||
|
retries > 0 ? " with " + retries + " retries" : ""
|
||||||
}`,
|
}`,
|
||||||
embeds: [],
|
embeds: [],
|
||||||
files: images,
|
files: images,
|
||||||
|
@ -755,22 +762,24 @@ mcserver.callback = async function(msg, line) {
|
||||||
|
|
||||||
const data = await new Promise((resolve, reject) => {
|
const data = await new Promise((resolve, reject) => {
|
||||||
logger.verbose("mcserver", "querying", ip, port);
|
logger.verbose("mcserver", "querying", ip, port);
|
||||||
const timeout = setTimeout(() => {
|
|
||||||
logger.verbose("mcserver", "timeout");
|
|
||||||
resolve("timeout");
|
|
||||||
}, 60000);
|
|
||||||
|
|
||||||
const client = net.createConnection(
|
const client = net.createConnection(
|
||||||
{
|
{
|
||||||
host: ip,
|
host: ip,
|
||||||
port: port,
|
port: port,
|
||||||
timeout: 60000,
|
timeout: 180000,
|
||||||
},
|
},
|
||||||
function () {
|
function () {
|
||||||
logger.verbose("mcserver", "connect");
|
logger.verbose("mcserver", "connect");
|
||||||
client.write(HANDSHAKE_PACKET);
|
client.write(HANDSHAKE_PACKET);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
const timeout = setTimeout(() => {
|
||||||
|
logger.verbose("mcserver", "timeout");
|
||||||
|
client.destroy();
|
||||||
|
resolve("timeout");
|
||||||
|
}, 180000);
|
||||||
|
|
||||||
let totalData = Buffer.alloc(0);
|
let totalData = Buffer.alloc(0);
|
||||||
client.on("data", function (data) {
|
client.on("data", function (data) {
|
||||||
totalData = Buffer.concat([totalData, data]);
|
totalData = Buffer.concat([totalData, data]);
|
||||||
|
|
Loading…
Reference in a new issue