Exemplo n.º 1
0
func (c clientHandler) OnReceive(l message.M) {
	if l.Command == "QUIT" {
		c.client.Send(message.Message3(
			nil,
			"ERROR",
			message.ParamsT([]string{}, "Closing Link: "+c.client.Name())))

		c.client.Channels().Each(func(ch *channel.Channel) {
			ch.Send(message.Message3(
				message.Prefix(c.client.Name(), c.client.UserName(), c.client.server.Name()),
				"QUIT",
				nil))
		})

		c.client.Close()
		return
	}

	if handler, ok := handlers[l.Command]; ok {
		handler(c.client, c.client.server, l.Args())
	}
}
Exemplo n.º 2
0
func WhoIsServer(host, user string) message.M {
	return message.Message3(
		message.Prefix(host),
		RPL_WHOISSERVER,
		message.ParamsT([]string{user, host}, ""))
}
Exemplo n.º 3
0
func ChannelModeIs(host, nick, channel string) message.M {
	return message.Message3(
		message.Prefix(host),
		RPL_CHANNELMODEIS,
		message.Params([]string{nick, channel, "+"}))
}
Exemplo n.º 4
0
func Away(host, nick, awayMsg string) message.M {
	return message.Message3(
		message.Prefix(host),
		RPL_AWAY,
		message.ParamsT([]string{nick}, awayMsg))
}
Exemplo n.º 5
0
func WhoIsUser(host, nick, user, realName string) message.M {
	return message.Message3(
		message.Prefix(host),
		RPL_WHOISUSER,
		message.ParamsT([]string{nick, user, host, "*"}, realName))
}
Exemplo n.º 6
0
func Invite(nick, user, host, subject, channel string) message.M {
	return message.Message3(
		message.Prefix(nick, user, host),
		"INVITE",
		message.ParamsT([]string{subject}, channel))
}
Exemplo n.º 7
0
func WhoReply(host, me, subject, user, nick, realName string) message.M {
	return message.Message3(
		message.Prefix(host),
		RPL_WHOREPLY,
		message.ParamsT([]string{me, subject, user, host, host, nick, "H"}, "0 "+realName))
}
Exemplo n.º 8
0
func Join(nickName, userName, serverName, channelName string) message.M {
	return message.Message3(
		message.Prefix(nickName, userName, serverName),
		"JOIN",
		message.ParamsT([]string{}, channelName))
}
Exemplo n.º 9
0
func UserModeIs(host, nick string) message.M {
	return message.Message3(
		message.Prefix(host),
		RPL_UMODEIS,
		message.Params([]string{nick, "+"}))
}
Exemplo n.º 10
0
func NowAway(host string) message.M {
	return message.Message3(
		message.Prefix(host),
		"306",
		message.ParamsT([]string{}, "You have been marked as being away"))
}
Exemplo n.º 11
0
func UnAway(host string) message.M {
	return message.Message3(
		message.Prefix(host),
		"305",
		message.ParamsT([]string{}, "You are no longer marked as being away"))
}
Exemplo n.º 12
0
func Nick(oldName, newName string) message.M {
	return message.Message3(
		message.Prefix(oldName),
		"NICK",
		message.Params([]string{newName}))
}
Exemplo n.º 13
0
func Welcome(serverName, nickName string) message.M {
	return message.Message3(
		message.Prefix(serverName),
		RPL_WELCOME,
		message.Params([]string{nickName}))
}
Exemplo n.º 14
0
func EndOfNames(serverName, nickName, channelName string) message.M {
	return message.Message3(
		message.Prefix(serverName),
		RPL_ENDOFNAMES,
		message.ParamsT([]string{nickName, channelName}, "End of /NAMES list."))
}
Exemplo n.º 15
0
func EndOfWho(host, user, subject string) message.M {
	return message.Message3(
		message.Prefix(host),
		RPL_ENDOFWHO,
		message.Params([]string{user, subject}))
}
Exemplo n.º 16
0
func WhoIsChannels(host, nick string, channels []string) message.M {
	return message.Message3(
		message.Prefix(host),
		RPL_WHOISCHANNELS,
		message.ParamsT([]string{nick}, strings.Join(channels, " ")))
}
Exemplo n.º 17
0
func Topic(host, channel, topic string) message.M {
	return message.Message3(
		message.Prefix(host),
		RPL_TOPIC,
		message.ParamsT([]string{channel}, topic))
}
Exemplo n.º 18
0
func WhoIsIdle(host, nick string, seconds int) message.M {
	return message.Message3(
		message.Prefix(host),
		RPL_WHOISIDLE,
		message.ParamsT([]string{nick, strconv.Itoa(seconds)}, "seconds idle"))
}
Exemplo n.º 19
0
func Pong(host, address string) message.M {
	return message.Message3(
		message.Prefix(host),
		"PONG",
		message.Params([]string{address}))
}
Exemplo n.º 20
0
func Part(nickName, userName, serverName, channel string) message.M {
	return message.Message3(
		message.Prefix(nickName, userName, serverName),
		"PART",
		message.ParamsT([]string{channel}, nickName))
}
Exemplo n.º 21
0
func EndOfBanList(host, nick, channel string) message.M {
	return message.Message3(
		message.Prefix(host),
		RPL_ENDOFBANLIST,
		message.ParamsT([]string{nick, channel}, "End of Channel Ban List"))
}
Exemplo n.º 22
0
func WhoIsOperator(host, nick string) message.M {
	return message.Message3(
		message.Prefix(host),
		RPL_WHOISOPERATOR,
		message.ParamsT([]string{nick}, "is an IRC oeprator"))
}
Exemplo n.º 23
0
func Notice(nick, user, host, subject, msg string) message.M {
	return message.Message3(
		message.Prefix(nick, user, host),
		"NOTICE",
		message.ParamsT([]string{subject}, msg))
}
Exemplo n.º 24
0
func TopicChange(nickName, userName, serverName, channel, topic string) message.M {
	return message.Message3(
		message.Prefix(nickName, userName, serverName),
		"TOPIC",
		message.ParamsT([]string{channel}, topic))
}
Exemplo n.º 25
0
func err(host, code string, params []string, text string) message.M {
	return message.Message3(
		message.Prefix(host),
		code,
		message.ParamsT(params, text))
}
Exemplo n.º 26
0
func NameReply(serverName, nickName, channelName string, names []string) message.M {
	return message.Message3(
		message.Prefix(serverName),
		RPL_NAMREPLY,
		message.ParamsT([]string{nickName, "=", channelName}, strings.Join(names, " ")))
}
Exemplo n.º 27
0
func PrivMsg(nick, user, host, subject, msg string) message.M {
	return message.Message3(
		message.Prefix(nick, user, host),
		"PRIVMSG",
		message.ParamsT([]string{subject}, msg))
}