forked from External/ergo
rudimentary (broken) invite support
This commit is contained in:
parent
55f7c89468
commit
d7d6263e35
5 changed files with 244 additions and 46 deletions
|
|
@ -49,6 +49,15 @@ func RplNick(client *Client, newNick string) Reply {
|
|||
return NewReply(client, RPL_NICK, ":"+newNick)
|
||||
}
|
||||
|
||||
func RplInviteMsg(channel *Channel, inviter *Client) Reply {
|
||||
return NewReply(inviter, RPL_INVITE, channel.name)
|
||||
}
|
||||
|
||||
func RplInvitingMsg(channel *Channel, invitee *Client) Reply {
|
||||
return NewReply(channel.server, RPL_INVITING,
|
||||
fmt.Sprintf("%s %s", channel.name, invitee.Nick()))
|
||||
}
|
||||
|
||||
func RplPrivMsgChannel(channel *Channel, source *Client, message string) Reply {
|
||||
return &ChannelReply{NewReply(source, RPL_PRIVMSG, ":"+message), channel}
|
||||
}
|
||||
|
|
@ -64,19 +73,23 @@ func RplPart(channel *Channel, client *Client, message string) Reply {
|
|||
// Server Info
|
||||
|
||||
func RplWelcome(source Identifier, client *Client) Reply {
|
||||
return NewReply(source, RPL_WELCOME, "Welcome to the Internet Relay Network "+client.Id())
|
||||
return NewReply(source, RPL_WELCOME,
|
||||
"Welcome to the Internet Relay Network "+client.Id())
|
||||
}
|
||||
|
||||
func RplYourHost(server *Server, target *Client) Reply {
|
||||
return NewReply(server, RPL_YOURHOST, fmt.Sprintf("Your host is %s, running version %s", server.hostname, VERSION))
|
||||
return NewReply(server, RPL_YOURHOST,
|
||||
fmt.Sprintf("Your host is %s, running version %s", server.hostname, VERSION))
|
||||
}
|
||||
|
||||
func RplCreated(server *Server) Reply {
|
||||
return NewReply(server, RPL_CREATED, "This server was created "+server.ctime.Format(time.RFC1123))
|
||||
return NewReply(server, RPL_CREATED,
|
||||
"This server was created "+server.ctime.Format(time.RFC1123))
|
||||
}
|
||||
|
||||
func RplMyInfo(server *Server) Reply {
|
||||
return NewReply(server, RPL_MYINFO, fmt.Sprintf("%s %s i ik", server.name, VERSION))
|
||||
return NewReply(server, RPL_MYINFO,
|
||||
fmt.Sprintf("%s %s i ik", server.name, VERSION))
|
||||
}
|
||||
|
||||
func RplUModeIs(server *Server, client *Client) Reply {
|
||||
|
|
@ -86,20 +99,24 @@ func RplUModeIs(server *Server, client *Client) Reply {
|
|||
// channel operations
|
||||
|
||||
func RplNoTopic(channel *Channel) Reply {
|
||||
return &ChannelReply{NewReply(channel.server, RPL_NOTOPIC, channel.name+" :No topic is set"), channel}
|
||||
return &ChannelReply{NewReply(channel.server, RPL_NOTOPIC,
|
||||
channel.name+" :No topic is set"), channel}
|
||||
}
|
||||
|
||||
func RplTopic(channel *Channel) Reply {
|
||||
return &ChannelReply{NewReply(channel.server, RPL_TOPIC, fmt.Sprintf("%s :%s", channel.name, channel.topic)), channel}
|
||||
return &ChannelReply{NewReply(channel.server, RPL_TOPIC,
|
||||
fmt.Sprintf("%s :%s", channel.name, channel.topic)), channel}
|
||||
}
|
||||
|
||||
func RplNamReply(channel *Channel) Reply {
|
||||
// TODO multiple names and splitting based on message size
|
||||
return NewReply(channel.server, RPL_NAMREPLY, fmt.Sprintf("= %s :%s", channel.name, strings.Join(channel.Nicks(), " ")))
|
||||
return NewReply(channel.server, RPL_NAMREPLY,
|
||||
fmt.Sprintf("= %s :%s", channel.name, strings.Join(channel.Nicks(), " ")))
|
||||
}
|
||||
|
||||
func RplEndOfNames(source Identifier) Reply {
|
||||
return NewReply(source, RPL_ENDOFNAMES, ":End of NAMES list")
|
||||
return NewReply(source, RPL_ENDOFNAMES,
|
||||
":End of NAMES list")
|
||||
}
|
||||
|
||||
func RplPong(server *Server) Reply {
|
||||
|
|
@ -109,41 +126,56 @@ func RplPong(server *Server) Reply {
|
|||
// errors
|
||||
|
||||
func ErrAlreadyRegistered(source Identifier) Reply {
|
||||
return NewReply(source, ERR_ALREADYREGISTRED, ":You may not reregister")
|
||||
return NewReply(source, ERR_ALREADYREGISTRED,
|
||||
":You may not reregister")
|
||||
}
|
||||
|
||||
func ErrNickNameInUse(source Identifier, nick string) Reply {
|
||||
return NewReply(source, ERR_NICKNAMEINUSE, nick+" :Nickname is already in use")
|
||||
return NewReply(source, ERR_NICKNAMEINUSE,
|
||||
nick+" :Nickname is already in use")
|
||||
}
|
||||
|
||||
func ErrUnknownCommand(source Identifier, command string) Reply {
|
||||
return NewReply(source, ERR_UNKNOWNCOMMAND, command+" :Unknown command")
|
||||
return NewReply(source, ERR_UNKNOWNCOMMAND,
|
||||
command+" :Unknown command")
|
||||
}
|
||||
|
||||
func ErrUsersDontMatch(source Identifier) Reply {
|
||||
return NewReply(source, ERR_USERSDONTMATCH, ":Cannot change mode for other users")
|
||||
return NewReply(source, ERR_USERSDONTMATCH,
|
||||
":Cannot change mode for other users")
|
||||
}
|
||||
|
||||
func ErrNeedMoreParams(source Identifier, command string) Reply {
|
||||
return NewReply(source, ERR_NEEDMOREPARAMS, command+"%s :Not enough parameters")
|
||||
return NewReply(source, ERR_NEEDMOREPARAMS,
|
||||
command+"%s :Not enough parameters")
|
||||
}
|
||||
|
||||
func ErrNoSuchChannel(source Identifier, channel string) Reply {
|
||||
return NewReply(source, ERR_NOSUCHCHANNEL, channel+" :No such channel")
|
||||
return NewReply(source, ERR_NOSUCHCHANNEL,
|
||||
channel+" :No such channel")
|
||||
}
|
||||
|
||||
func ErrUserOnChannel(channel *Channel, member *Client) Reply {
|
||||
return NewReply(channel.server, ERR_USERONCHANNEL,
|
||||
fmt.Sprintf("%s %s :is already on channel", member.nick, channel.name))
|
||||
}
|
||||
|
||||
func ErrNotOnChannel(channel *Channel) Reply {
|
||||
return NewReply(channel.server, ERR_NOTONCHANNEL, channel.name+" :You're not on that channel")
|
||||
return NewReply(channel.server, ERR_NOTONCHANNEL,
|
||||
channel.name+" :You're not on that channel")
|
||||
}
|
||||
|
||||
func ErrInviteOnlyChannel(channel *Channel) Reply {
|
||||
return NewReply(channel.server, ERR_INVITEONLYCHANNEL, channel.name+" :Cannot join channel (+i)")
|
||||
return NewReply(channel.server, ERR_INVITEONLYCHAN,
|
||||
channel.name+" :Cannot join channel (+i)")
|
||||
}
|
||||
|
||||
func ErrBadChannelKey(channel *Channel) Reply {
|
||||
return NewReply(channel.server, ERR_BADCHANNELKEY, channel.name+" :Cannot join channel (+k)")
|
||||
return NewReply(channel.server, ERR_BADCHANNELKEY,
|
||||
channel.name+" :Cannot join channel (+k)")
|
||||
}
|
||||
|
||||
func ErrNoSuchNick(source Identifier, nick string) Reply {
|
||||
return NewReply(source, ERR_NOSUCHNICK, nick+" :No such nick/channel")
|
||||
return NewReply(source, ERR_NOSUCHNICK,
|
||||
nick+" :No such nick/channel")
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue