From 1688303c8fff71069fccf53d28a6113e123e7aeb Mon Sep 17 00:00:00 2001 From: Abheek Dhawan Date: Sat, 1 May 2021 22:18:13 -0500 Subject: [PATCH] Use config file for URLs --- .gitignore | 1 + bot/awesomescibo.mjs | 5 +++-- bot/config.default.json | 4 ++++ 3 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 bot/config.default.json diff --git a/.gitignore b/.gitignore index 6ec2bb9..7c3dd2f 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ bot/README.md .json .env userScore/* +config.json diff --git a/bot/awesomescibo.mjs b/bot/awesomescibo.mjs index 5ec615d..8b310f1 100755 --- a/bot/awesomescibo.mjs +++ b/bot/awesomescibo.mjs @@ -11,6 +11,7 @@ import axios from "axios"; import userScore from "./mongooseModels/mongooseUserScoreModel.js"; import {} from "dotenv/config.js"; import mongoose from "mongoose"; +import config from ('./config.json') const helpMessage = "`do be helping`: display this help message\n`do be roundgen`: send a pdf round to the channel\n`do be roundgen dm`: dm a pdf round to you\n`do be scoring`: start a scoring session\n > `do be scoring (a/b)(4/10)`: add points to Team A or Team B\n > `do be scoring stop`: end scoring session and post final points\n > `do be servers`: send the number of servers this bot is a part of\n > `do be iss`: show the current location of the International Space Station\n`do be training`: send a quick practice problem (you **must** react to your answer, or the bot will yell at you)\n > subject options: astro, phys, chem, math, bio, ess, energy\n`do be top`: list cross-server top 10 players\n `do be about`: List people who contributed to this bot\n Source Code: https://github.com/ADawesomeguy/AwesomeSciBo (don't forget to star!)"; @@ -47,7 +48,7 @@ client.on("guildCreate", (guild) => { }); function getSubjectUrl(subject) { - return `https://moose.lcsrc.org/subjects/${subject}.json`; + return `${config.subjectURL}${subject}.json`; } async function updateScore(isCorrect, score, authorId) { @@ -365,7 +366,7 @@ async function generateRound(message, isDM) { generatingMsg.delete({ timeout: 100 }).catch(console.error); } execSync( - "curl --request POST --url https://localhost:3136/convert/html --header 'Content-Type: multipart/form-data' --form files=@index.html -o round.pdf", + `curl --request POST --url ${config.gotenbergURL} --header 'Content-Type: multipart/form-data' --form files=@index.html -o round.pdf`, { encoding: "utf-8" } ); if (isDM) { diff --git a/bot/config.default.json b/bot/config.default.json new file mode 100644 index 0000000..7bfe57b --- /dev/null +++ b/bot/config.default.json @@ -0,0 +1,4 @@ +{ + "subjectURL": "https://moose.lcsrc.org/subjects/", + "gotenbergURL": "https://localhost:3136/convert/html" +}