Fixed issue with skip vote counts, added headless chrome IP to config, other fixes
This commit is contained in:
parent
bc59550625
commit
925eb387dd
7 changed files with 44 additions and 14 deletions
|
@ -28,6 +28,9 @@ GOOGLE=
|
|||
# Put DBL/top.gg token here
|
||||
DBL=
|
||||
|
||||
# Put headless Chrome IP here
|
||||
CHROME=172.17.0.1:9222
|
||||
|
||||
# Put HTML help page output location here, leave blank to disable
|
||||
OUTPUT=
|
||||
# Put temporary image dir here (make sure it's accessible via a web server), leave blank to disable
|
||||
|
|
28
api/index.js
28
api/index.js
|
@ -23,19 +23,41 @@ app.get("/", (req, res) => {
|
|||
});
|
||||
|
||||
app.post("/:method", upload.single("image"), async (req, res, next) => {
|
||||
const type = req.file.mimetype === "video/mp4" ? "image/gif" : req.file.mimetype;
|
||||
const type = req.file ? (req.file.mimetype === "video/mp4" ? "image/gif" : req.file.mimetype) : "image/png";
|
||||
if (!formats.includes(type)) {
|
||||
return res.sendStatus(400);
|
||||
}
|
||||
const object = {
|
||||
cmd: req.params.method,
|
||||
path: req.file.path,
|
||||
path: req.file ? req.file.path : null,
|
||||
type: type.split("/")[1],
|
||||
delay: parseInt(req.params.delay)
|
||||
delay: req.query.delay ? parseInt(req.query.delay) : 0
|
||||
};
|
||||
for (const param of Object.keys(req.query)) {
|
||||
if (param === "delay") continue;
|
||||
switch (param) {
|
||||
case "sharp":
|
||||
case "flop":
|
||||
case "loop":
|
||||
case "vertical":
|
||||
case "first":
|
||||
case "stretch":
|
||||
case "wide":
|
||||
case "soos":
|
||||
case "slow":
|
||||
case "resize":
|
||||
case "append":
|
||||
case "mc":
|
||||
if (req.query[param] === "true") {
|
||||
object[param] = true;
|
||||
} else {
|
||||
object[param] = false;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
object[param] = req.query[param];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
|
|
|
@ -21,7 +21,7 @@ exports.run = async (message, args) => {
|
|||
},
|
||||
"title": `${prefix}${command}`,
|
||||
"url": "https://projectlounge.pw/esmBot/help.html",
|
||||
"description": info.description,
|
||||
"description": command === "tags" ? "The main tags command. Check the help page for more info: https://projectlounge.pw/esmBot/help.html" : info.description,
|
||||
"color": 16711680,
|
||||
"fields": [{
|
||||
"name": "Aliases",
|
||||
|
@ -32,7 +32,7 @@ exports.run = async (message, args) => {
|
|||
"inline": true
|
||||
}, {
|
||||
"name": "Parameters",
|
||||
"value": info.params ? info.params : "None",
|
||||
"value": command === "tags" ? "[name]" : info.params ? info.params : "None",
|
||||
"inline": true
|
||||
}]
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ const fetch = require("node-fetch");
|
|||
exports.run = async (message, args) => {
|
||||
message.channel.sendTyping();
|
||||
if (args.length === 0) return `${message.author.mention}, you need to provide a URL to screenshot!`;
|
||||
const getEndpoint = await fetch("http://172.17.0.1:9222/json/version");
|
||||
const getEndpoint = await fetch(`http://${process.env.CHROME}/json/version`);
|
||||
const endpoint = await getEndpoint.json();
|
||||
const url = urlRegex.test(args[0]) ? args[0] : `http://${args[0]}`;
|
||||
const browser = await puppeteer.connect({
|
||||
|
|
|
@ -43,7 +43,7 @@ Napi::Value Sonic(const Napi::CallbackInfo &info)
|
|||
|
||||
Napi::Object obj = info[0].As<Napi::Object>();
|
||||
Napi::Function cb = info[1].As<Napi::Function>();
|
||||
string text = obj.Get("path").As<Napi::String>().Utf8Value();
|
||||
string text = obj.Get("text").As<Napi::String>().Utf8Value();
|
||||
|
||||
SonicWorker* explodeWorker = new SonicWorker(cb, text);
|
||||
explodeWorker->Queue();
|
||||
|
|
|
@ -11,7 +11,7 @@ module.exports = async (object, fromAPI = false) => {
|
|||
params.push(`${element}=${encodeURIComponent(object[element])}`);
|
||||
}
|
||||
const form = new FormData();
|
||||
form.append("image", fs.createReadStream(object.path));
|
||||
if (object.path) form.append("image", fs.createReadStream(object.path));
|
||||
const req = await fetch(`${process.env.API_URL}/${object.cmd}?${params.join("&")}`, {
|
||||
method: "POST",
|
||||
body: form,
|
||||
|
|
|
@ -145,13 +145,18 @@ exports.skip = async (message) => {
|
|||
if (!message.channel.guild.members.get(client.user.id).voiceState.channelID) return client.createMessage(message.channel.id, `${message.author.mention}, I'm not in a voice channel!`);
|
||||
const player = this.players.get(message.channel.guild.id);
|
||||
if (player.host !== message.author.id) {
|
||||
const voteCount = skipVotes.has(message.channel.guild.id) ? skipVotes.get(message.channel.guild.id) : 0;
|
||||
if (voteCount + 1 === 3) {
|
||||
const votes = skipVotes.has(message.channel.guild.id) ? skipVotes.get(message.channel.guild.id) : { count: 0, ids: [] };
|
||||
if (votes.ids.includes(message.author.id)) return client.createMessage(message.channel.id, `${message.author.mention}, you've already voted to skip!`);
|
||||
const newObject = {
|
||||
count: votes.count + 1,
|
||||
ids: [...votes.ids, message.author.id].filter(item => !!item)
|
||||
};
|
||||
if (votes.count + 1 === 3) {
|
||||
player.player.stop(message.channel.guild.id);
|
||||
skipVotes.set(message.channel.guild.id, 0);
|
||||
skipVotes.set(message.channel.guild.id, { count: 0, ids: [] });
|
||||
} else {
|
||||
await client.createMessage(message.channel.id, `🔊 Voted to skip song (${voteCount + 1}/3 people have voted).`);
|
||||
skipVotes.set(message.channel.guild.id, voteCount + 1);
|
||||
await client.createMessage(message.channel.id, `🔊 Voted to skip song (${votes.count + 1}/3 people have voted).`);
|
||||
skipVotes.set(message.channel.guild.id, newObject);
|
||||
}
|
||||
} else {
|
||||
player.player.stop(message.channel.guild.id);
|
||||
|
|
Loading…
Reference in a new issue