Ejemplo n.º 1
0
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
}
Ejemplo n.º 2
0
// 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
}
Ejemplo n.º 3
0
func exit(ircc *irc.IRC, w io.Writer) int {
	ircc.Disconnect()
	return 0
}