mirror of https://github.com/gissleh/irc.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
481 B
27 lines
481 B
package irc
|
|
|
|
import (
|
|
"strings"
|
|
"time"
|
|
)
|
|
|
|
// ParseInput parses an input command into an event.
|
|
func ParseInput(line string) Event {
|
|
event := NewEvent("input", "")
|
|
event.Time = time.Now()
|
|
|
|
if strings.HasPrefix(line, "/") {
|
|
split := strings.SplitN(line[1:], " ", 2)
|
|
event.verb = strings.ToLower(split[0])
|
|
if len(split) == 2 {
|
|
event.Text = split[1]
|
|
}
|
|
} else {
|
|
event.Text = line
|
|
event.verb = "text"
|
|
}
|
|
|
|
event.name = event.kind + "." + event.verb
|
|
|
|
return event
|
|
}
|