lint fixes

This commit is contained in:
Aine
2023-10-03 00:03:29 +03:00
parent ef221038f7
commit 0d0dcf20b9
18 changed files with 196 additions and 152 deletions

View File

@@ -5,21 +5,24 @@ import (
"strings"
)
// MinSendCommandParts is minimal count of space-separated parts for !pm send command
const MinSendCommandParts = 3
// ErrInvalidArgs returned when a command's arguments are invalid
var ErrInvalidArgs = fmt.Errorf("invalid arguments")
// ParseSend parses "!pm send" command, returns to, subject, body, err
func ParseSend(commandSlice []string) (string, string, string, error) {
func ParseSend(commandSlice []string) (to, subject, body string, err error) {
message := strings.Join(commandSlice, " ")
lines := strings.Split(message, "\n")
if len(lines) < 3 {
if len(lines) < MinSendCommandParts {
return "", "", "", ErrInvalidArgs
}
commandSlice = strings.Split(lines[0], " ")
to := commandSlice[1]
subject := lines[1]
body := strings.Join(lines[2:], "\n")
to = commandSlice[1]
subject = lines[1]
body = strings.Join(lines[2:], "\n")
return to, subject, body, nil
}