Compare commits
2 Commits
fa6f06f639
...
6a389be6a7
Author | SHA1 | Date | |
---|---|---|---|
6a389be6a7 | |||
35c72daff4 |
@ -51,6 +51,9 @@ func BuildURI(rawuri, rawpath string) string {
|
||||
}
|
||||
|
||||
func HasCommand(s, prefix, cmd string) bool {
|
||||
s = strings.TrimSpace(s)
|
||||
|
||||
// a command cannot be less than two characters e.g. !x
|
||||
if len(s) < 2 {
|
||||
return false
|
||||
}
|
||||
@ -65,3 +68,21 @@ func HasCommand(s, prefix, cmd string) bool {
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func SplitCommandAndArgs(s, prefix string) (cmd string, args []string) {
|
||||
s = strings.TrimSpace(s)
|
||||
|
||||
x := strings.Split(s, " ")
|
||||
|
||||
if len(x) > 1 {
|
||||
args = x[1:]
|
||||
}
|
||||
|
||||
cmd = x[0]
|
||||
|
||||
if strings.Index(s, prefix) == 0 {
|
||||
cmd = cmd[len(prefix):]
|
||||
}
|
||||
|
||||
return cmd, args
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user