fix out of bounds crash for meme and conv command

This commit is contained in:
nouryxd 2024-05-16 15:52:02 +02:00
parent 003addc2d8
commit e9c9118321

View file

@ -227,16 +227,6 @@ func (app *application) handleCommand(message twitch.PrivateMessage) {
return return
} }
case "conv":
if userLevel >= 100 {
app.ConvertToMP4(cmdParams[1], message)
}
case "meme":
if userLevel >= 100 {
app.ConvertAndSave(cmdParams[1], cmdParams[2], message)
}
case "set": case "set":
switch cmdParams[1] { switch cmdParams[1] {
case "lastfm": case "lastfm":
@ -380,6 +370,24 @@ func (app *application) handleCommand(message twitch.PrivateMessage) {
// 1000 User Level // 1000 User Level
// Admin // Admin
//------------------------------------ //------------------------------------
case "conv":
if userLevel >= 1000 {
if msgLen > 1 {
reply = "Not enough arguments provided"
} else if msgLen == 2 {
app.ConvertToMP4(cmdParams[1], message)
}
}
case "meme":
if userLevel < 1000 { // Unauthorized
return
} else if userLevel >= 1000 && msgLen <= 2 { // Authorized but not enough args.
reply = "Not enough arguments provided."
} else if userLevel >= 1000 && msgLen >= 3 {
app.ConvertAndSave(cmdParams[1], cmdParams[2], message)
}
case "say": case "say":
if userLevel >= 1000 { if userLevel >= 1000 {
reply = message.Message[6:len(message.Message)] reply = message.Message[6:len(message.Message)]