more input validation
This commit is contained in:
parent
58abacf8df
commit
76187fd0a8
12
index.mjs
12
index.mjs
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue