commit 1ad07b5
sewn
·
2023-12-14 17:07:01 +0000 UTC
parent edb498b
Handle empty message properly Sending nothing in senpai makes the if check to work properly, however if sent nothing but a space, senpai will panic, as parseCommand assumes it is alphanumerical and not just a space. This commit fixes it by making parseCommand return false instead of panic when a message is empty. Co-authored-by: delthas <delthas@dille.cc> Co-authored-by: sewn <sewn@disroot.org>
1 files changed,
+1,
-1
+1,
-1
1@@ -876,7 +876,7 @@ func fieldsN(s string, n int) []string {
2 }
3
4 func parseCommand(s string) (command, args string, isCommand bool) {
5- if s[0] != '/' {
6+ if len(s) == 0 || s[0] != '/' {
7 return "", s, false
8 }
9 if len(s) > 1 && s[1] == '/' {