Mirror of github.com/gissleh/irc
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
464 B

  1. package irc
  2. import (
  3. "strings"
  4. "time"
  5. )
  6. // ParseInput parses an input command into an event.
  7. func ParseInput(line string) Event {
  8. event := NewEvent("input", "")
  9. event.Time = time.Now()
  10. if strings.HasPrefix(line, "/") {
  11. split := strings.SplitN(line[1:], " ", 2)
  12. event.verb = split[0]
  13. if len(split) == 2 {
  14. event.Text = split[1]
  15. }
  16. } else {
  17. event.Text = line
  18. event.verb = "text"
  19. }
  20. event.name = event.kind + "." + event.verb
  21. return event
  22. }