more input validation

This commit is contained in:
Joonas 2023-01-31 22:47:20 +02:00
parent 58abacf8df
commit 76187fd0a8
1 changed files with 10 additions and 2 deletions

View File

@ -25,7 +25,7 @@ client.on("close", async (error) => {
client.on("PRIVMSG", async (msg) => {
if (msg.senderUsername === process.env.TWITCH_USERNAME) return;
if (msg.messageText.length < 3) return;
const splitted = msg.messageText.split(" ");
// chatterinos duplicate message bypass fix lol
@ -90,6 +90,14 @@ client.on("PRIVMSG", async (msg) => {
}
case "weather": {
if (splitted[2] === undefined) {
client.say(
msg.channelName,
`${msg.displayName}, supply a location PoroSad`
);
break;
}
const data = await fetch(`https://wttr.in/${splitted[2]}?format=j1`)
.then((res) => res.json())
.then((data) => {
@ -100,7 +108,7 @@ client.on("PRIVMSG", async (msg) => {
if (data === undefined) {
client.say(
msg.channelName,
`${msg.displayName}, Invalid place PoroSad`
`${msg.displayName}, Invalid location PoroSad`
);
break;
}