func part(ircc *irc.IRC, w io.Writer, input string) int { cmd := events.Part{} if err := json.Unmarshal([]byte(input), &cmd); err != nil { fmt.Fprint(w, events.JSONError(err.Error())) return -1 // Not a critical error. } e := []validate.ValidationMsg{} e = append(e, validate.NotNil("channel", cmd.Channel)...) if len(e) > 0 { fmt.Fprint(w, events.ValidationError("part", e)) return -1 // Not a critical error. } ircc.Part(cmd.Channel) return -1 }
// TODO: Add CTCP support for newlines // TODO: check length of message and break message into multiple lines func msg(ircc *irc.IRC, w io.Writer, input string) int { cmd := events.Msg{} if err := json.Unmarshal([]byte(input), &cmd); err != nil { fmt.Fprint(w, events.JSONError(err.Error())) return -1 // Not a critical error. } e := []validate.ValidationMsg{} e = append(e, validate.NotNil("target", cmd.Target)...) e = append(e, validate.NotNil("msg", cmd.Msg)...) if len(e) > 0 { fmt.Fprint(w, events.ValidationError("join", e)) return -1 // Not a critical error. } ircc.Msg(cmd.Target, cmd.Msg, cmd.Notice) return -1 }