fix: prevent panic when accessing empty message array in HandleCommand

This commit is contained in:
AkashiNeko
2025-06-19 09:56:37 +08:00
parent e011a7d339
commit f5d3fa2f90

View File

@@ -48,9 +48,12 @@ func init() {
func HandleCommand(c *qbot.Client, msg *qbot.Message) bool {
skip := 0
if len(msg.Array) == 0 {
return false
}
if msg.Array[0].Type == qbot.Reply {
skip++
if len(msg.Array) != 1 && msg.Array[1].Type == qbot.At {
if len(msg.Array) > 1 && msg.Array[1].Type == qbot.At {
skip++
}
} else if msg.Array[0].Type == qbot.At {