Exemplo n.º 1
0
func newEventPING(line string, server string) *api.Event {
	event := new(api.Event)
	event.Raw = line
	event.Type = api.E_PING
	event.Data = server
	return event
}
Exemplo n.º 2
0
func newEventPART(line string, user string, channel string) *api.Event {
	event := new(api.Event)
	event.Raw = line
	event.Type = api.E_PART
	event.Channel = channel
	event.User = user
	return event
}
Exemplo n.º 3
0
func newEventNOTICE(line string, message string, cmd_id int) *api.Event {
	event := new(api.Event)
	event.Raw = line
	event.Type = api.E_NOTICE
	event.Data = message
	event.CmdId = cmd_id
	return event
}
Exemplo n.º 4
0
func newEventNICK(line string, user string, newuser string) *api.Event {
	event := new(api.Event)
	event.Raw = line
	event.Type = api.E_NICK
	event.Data = newuser
	event.User = user
	return event
}
Exemplo n.º 5
0
func newEventQUIT(line string, user string, msg string) *api.Event {
	event := new(api.Event)
	event.Raw = line
	event.Type = api.E_QUIT
	event.Data = msg
	event.User = user
	return event
}
Exemplo n.º 6
0
func newEventJOIN(line string, user string, channel string) *api.Event {
	event := new(api.Event)
	event.Raw = line
	event.Type = api.E_JOIN
	event.Channel = channel
	event.Data = channel
	event.User = user
	return event
}
Exemplo n.º 7
0
func newEventKICK(line string, user string, channel string, target string, msg string) *api.Event {
	event := new(api.Event)
	event.Raw = line
	event.Type = api.E_KICK
	event.Data = target
	event.Channel = channel
	event.User = user
	return event
}
Exemplo n.º 8
0
func newEventPRIVMSG(line string, user string, channel string, msg string) *api.Event {
	event := new(api.Event)
	event.Raw = line
	event.Type = api.E_PRIVMSG
	event.Data = msg
	if strings.Index(channel, "#") == 0 {
		event.Channel = channel
	}
	event.User = user
	return event
}
Exemplo n.º 9
0
func (robot *Grobot) HandleEvent(serv *Server, event *api.Event) {
	switch event.Type {
	case api.E_KICK:
		if serv.Config.Nickname == event.Data && robot.Config.AutoRejoinOnKick {
			serv.JoinChannel(event.Channel)
		}
	case api.E_PING:
		serv.SendMeRaw[api.PRIORITY_HIGH] <- fmt.Sprintf("PONG :%s\r\n", event.Data)
	case api.E_NOTICE:
		robot.HandleNotice(serv, event)
	case api.E_DISCONNECT:
		serv.Disconnect()
	case api.E_PRIVMSG:
		if _, ok := serv.Config.Channels[event.Channel]; ok == true {
			event.AdminCmd = serv.Config.Channels[event.Channel].Master
		}
	}
	robot.SendEvent(event)
}