Scrape horse doc constants, handle all nick collision error types
This commit is contained in:
parent
e937f5d8b9
commit
be8b785813
@ -208,25 +208,25 @@ func (c *Client) recv() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch msg.Command {
|
switch msg.Command {
|
||||||
case Ping:
|
case PING:
|
||||||
go c.write("PONG :" + msg.LastParam())
|
go c.write("PONG :" + msg.LastParam())
|
||||||
|
|
||||||
case Join:
|
case JOIN:
|
||||||
if c.EqualFold(msg.Nick, c.GetNick()) {
|
if c.EqualFold(msg.Nick, c.GetNick()) {
|
||||||
c.addChannel(msg.Params[0])
|
c.addChannel(msg.Params[0])
|
||||||
}
|
}
|
||||||
|
|
||||||
case Nick:
|
case NICK:
|
||||||
if c.EqualFold(msg.Nick, c.GetNick()) {
|
if c.EqualFold(msg.Nick, c.GetNick()) {
|
||||||
c.setNick(msg.LastParam())
|
c.setNick(msg.LastParam())
|
||||||
}
|
}
|
||||||
|
|
||||||
case Privmsg:
|
case PRIVMSG:
|
||||||
if ctcp := msg.ToCTCP(); ctcp != nil {
|
if ctcp := msg.ToCTCP(); ctcp != nil {
|
||||||
c.handleCTCP(ctcp, msg)
|
c.handleCTCP(ctcp, msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
case ReplyWelcome:
|
case RPL_WELCOME:
|
||||||
c.setNick(msg.Params[0])
|
c.setNick(msg.Params[0])
|
||||||
c.setRegistered(true)
|
c.setRegistered(true)
|
||||||
c.flushChannels()
|
c.flushChannels()
|
||||||
@ -235,15 +235,15 @@ func (c *Client) recv() {
|
|||||||
c.sendRecv.Add(1)
|
c.sendRecv.Add(1)
|
||||||
go c.send()
|
go c.send()
|
||||||
|
|
||||||
case ReplyISupport:
|
case RPL_ISUPPORT:
|
||||||
c.Features.Parse(msg.Params)
|
c.Features.Parse(msg.Params)
|
||||||
|
|
||||||
case ErrNicknameInUse:
|
case ERR_NICKNAMEINUSE, ERR_NICKCOLLISION, ERR_UNAVAILRESOURCE:
|
||||||
if c.HandleNickInUse != nil {
|
if c.HandleNickInUse != nil {
|
||||||
go c.writeNick(c.HandleNickInUse(msg.Params[1]))
|
go c.writeNick(c.HandleNickInUse(msg.Params[1]))
|
||||||
}
|
}
|
||||||
|
|
||||||
case Error:
|
case ERROR:
|
||||||
c.Messages <- msg
|
c.Messages <- msg
|
||||||
c.connChange(false, nil)
|
c.connChange(false, nil)
|
||||||
time.Sleep(5 * time.Second)
|
time.Sleep(5 * time.Second)
|
||||||
|
@ -136,8 +136,8 @@ func TestRecv(t *testing.T) {
|
|||||||
|
|
||||||
assert.Equal(t, "PONG :test\r\n", <-conn.hook)
|
assert.Equal(t, "PONG :test\r\n", <-conn.hook)
|
||||||
assert.Equal(t, &Message{Command: "CMD"}, <-c.Messages)
|
assert.Equal(t, &Message{Command: "CMD"}, <-c.Messages)
|
||||||
assert.Equal(t, &Message{Command: Ping, Params: []string{"test"}}, <-c.Messages)
|
assert.Equal(t, &Message{Command: PING, Params: []string{"test"}}, <-c.Messages)
|
||||||
assert.Equal(t, &Message{Command: ReplyWelcome, Params: []string{"foo"}}, <-c.Messages)
|
assert.Equal(t, &Message{Command: RPL_WELCOME, Params: []string{"foo"}}, <-c.Messages)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRecvTriggersReconnect(t *testing.T) {
|
func TestRecvTriggersReconnect(t *testing.T) {
|
||||||
|
166
pkg/irc/const.go
166
pkg/irc/const.go
@ -1,43 +1,133 @@
|
|||||||
package irc
|
package irc
|
||||||
|
|
||||||
const (
|
const (
|
||||||
Error = "ERROR"
|
CAP = "CAP"
|
||||||
Join = "JOIN"
|
AUTHENTICATE = "AUTHENTICATE"
|
||||||
Mode = "MODE"
|
PASS = "PASS"
|
||||||
Nick = "NICK"
|
NICK = "NICK"
|
||||||
Notice = "NOTICE"
|
USER = "USER"
|
||||||
Part = "PART"
|
OPER = "OPER"
|
||||||
Ping = "PING"
|
QUIT = "QUIT"
|
||||||
Privmsg = "PRIVMSG"
|
JOIN = "JOIN"
|
||||||
Quit = "QUIT"
|
PART = "PART"
|
||||||
Topic = "TOPIC"
|
TOPIC = "TOPIC"
|
||||||
|
NAMES = "NAMES"
|
||||||
|
LIST = "LIST"
|
||||||
|
MOTD = "MOTD"
|
||||||
|
VERSION = "VERSION"
|
||||||
|
ADMIN = "ADMIN"
|
||||||
|
CONNECT = "CONNECT"
|
||||||
|
TIME = "TIME"
|
||||||
|
STATS = "STATS"
|
||||||
|
INFO = "INFO"
|
||||||
|
MODE = "MODE"
|
||||||
|
PRIVMSG = "PRIVMSG"
|
||||||
|
NOTICE = "NOTICE"
|
||||||
|
USERHOST = "USERHOST"
|
||||||
|
KILL = "KILL"
|
||||||
|
ERROR = "ERROR"
|
||||||
|
PING = "PING"
|
||||||
|
PONG = "PONG"
|
||||||
|
|
||||||
ReplyWelcome = "001"
|
RPL_WELCOME = "001"
|
||||||
ReplyYourHost = "002"
|
RPL_YOURHOST = "002"
|
||||||
ReplyCreated = "003"
|
RPL_CREATED = "003"
|
||||||
ReplyISupport = "005"
|
RPL_MYINFO = "004"
|
||||||
ReplyLUserClient = "251"
|
RPL_ISUPPORT = "005"
|
||||||
ReplyLUserOp = "252"
|
RPL_BOUNCE = "010"
|
||||||
ReplyLUserUnknown = "253"
|
RPL_UMODEIS = "221"
|
||||||
ReplyLUserChannels = "254"
|
RPL_LUSERCLIENT = "251"
|
||||||
ReplyLUserMe = "255"
|
RPL_LUSEROP = "252"
|
||||||
ReplyAway = "301"
|
RPL_LUSERUNKNOWN = "253"
|
||||||
ReplyWhoisUser = "311"
|
RPL_LUSERCHANNELS = "254"
|
||||||
ReplyWhoisServer = "312"
|
RPL_LUSERME = "255"
|
||||||
ReplyWhoisOperator = "313"
|
RPL_ADMINME = "256"
|
||||||
ReplyWhoisIdle = "317"
|
RPL_ADMINLOC1 = "257"
|
||||||
ReplyEndOfWhois = "318"
|
RPL_ADMINLOC2 = "258"
|
||||||
ReplyWhoisChannels = "319"
|
RPL_ADMINEMAIL = "259"
|
||||||
ReplyList = "322"
|
RPL_TRYAGAIN = "263"
|
||||||
ReplyListEnd = "323"
|
RPL_LOCALUSERS = "265"
|
||||||
ReplyNoTopic = "331"
|
RPL_GLOBALUSERS = "266"
|
||||||
ReplyTopic = "332"
|
RPL_WHOISCERTFP = "276"
|
||||||
ReplyNamReply = "353"
|
RPL_NONE = "300"
|
||||||
ReplyEndOfNames = "366"
|
RPL_AWAY = "301"
|
||||||
ReplyMotd = "372"
|
RPL_USERHOST = "302"
|
||||||
ReplyMotdStart = "375"
|
RPL_ISON = "303"
|
||||||
ReplyEndOfMotd = "376"
|
RPL_UNAWAY = "305"
|
||||||
ErrErroneousNickname = "432"
|
RPL_NOWAWAY = "306"
|
||||||
ErrNicknameInUse = "433"
|
RPL_WHOISUSER = "311"
|
||||||
ErrForward = "470"
|
RPL_WHOISSERVER = "312"
|
||||||
|
RPL_WHOISOPERATOR = "313"
|
||||||
|
RPL_WHOWASUSER = "314"
|
||||||
|
RPL_WHOISIDLE = "317"
|
||||||
|
RPL_ENDOFWHOIS = "318"
|
||||||
|
RPL_WHOISCHANNELS = "319"
|
||||||
|
RPL_LISTSTART = "321"
|
||||||
|
RPL_LIST = "322"
|
||||||
|
RPL_LISTEND = "323"
|
||||||
|
RPL_CHANNELMODEIS = "324"
|
||||||
|
RPL_CREATIONTIME = "329"
|
||||||
|
RPL_NOTOPIC = "331"
|
||||||
|
RPL_TOPIC = "332"
|
||||||
|
RPL_TOPICWHOTIME = "333"
|
||||||
|
RPL_INVITING = "341"
|
||||||
|
RPL_INVITELIST = "346"
|
||||||
|
RPL_ENDOFINVITELIST = "347"
|
||||||
|
RPL_EXCEPTLIST = "348"
|
||||||
|
RPL_ENDOFEXCEPTLIST = "349"
|
||||||
|
RPL_VERSION = "351"
|
||||||
|
RPL_NAMREPLY = "353"
|
||||||
|
RPL_ENDOFNAMES = "366"
|
||||||
|
RPL_BANLIST = "367"
|
||||||
|
RPL_ENDOFBANLIST = "368"
|
||||||
|
RPL_ENDOFWHOWAS = "369"
|
||||||
|
RPL_MOTDSTART = "375"
|
||||||
|
RPL_MOTD = "372"
|
||||||
|
RPL_ENDOFMOTD = "376"
|
||||||
|
RPL_YOUREOPER = "381"
|
||||||
|
RPL_REHASHING = "382"
|
||||||
|
ERR_UNKNOWNERROR = "400"
|
||||||
|
ERR_NOSUCHNICK = "401"
|
||||||
|
ERR_NOSUCHSERVER = "402"
|
||||||
|
ERR_NOSUCHCHANNEL = "403"
|
||||||
|
ERR_CANNOTSENDTOCHAN = "404"
|
||||||
|
ERR_TOOMANYCHANNELS = "405"
|
||||||
|
ERR_UNKNOWNCOMMAND = "421"
|
||||||
|
ERR_NOMOTD = "422"
|
||||||
|
ERR_ERRONEUSNICKNAME = "432"
|
||||||
|
ERR_NICKNAMEINUSE = "433"
|
||||||
|
ERR_NICKCOLLISION = "436"
|
||||||
|
ERR_UNAVAILRESOURCE = "437"
|
||||||
|
ERR_USERNOTINCHANNEL = "441"
|
||||||
|
ERR_NOTONCHANNEL = "442"
|
||||||
|
ERR_USERONCHANNEL = "443"
|
||||||
|
ERR_NOTREGISTERED = "451"
|
||||||
|
ERR_NEEDMOREPARAMS = "461"
|
||||||
|
ERR_ALREADYREGISTERED = "462"
|
||||||
|
ERR_PASSWDMISMATCH = "464"
|
||||||
|
ERR_YOUREBANNEDCREEP = "465"
|
||||||
|
ERR_FORWARD = "470"
|
||||||
|
ERR_CHANNELISFULL = "471"
|
||||||
|
ERR_UNKNOWNMODE = "472"
|
||||||
|
ERR_INVITEONLYCHAN = "473"
|
||||||
|
ERR_BANNEDFROMCHAN = "474"
|
||||||
|
ERR_BADCHANNELKEY = "475"
|
||||||
|
ERR_NOPRIVILEGES = "481"
|
||||||
|
ERR_CHANOPRIVSNEEDED = "482"
|
||||||
|
ERR_CANTKILLSERVER = "483"
|
||||||
|
ERR_NOOPERHOST = "491"
|
||||||
|
ERR_UMODEUNKNOWNFLAG = "501"
|
||||||
|
ERR_USERSDONTMATCH = "502"
|
||||||
|
RPL_STARTTLS = "670"
|
||||||
|
ERR_STARTTLS = "691"
|
||||||
|
ERR_NOPRIVS = "723"
|
||||||
|
RPL_LOGGEDIN = "900"
|
||||||
|
RPL_LOGGEDOUT = "901"
|
||||||
|
ERR_NICKLOCKED = "902"
|
||||||
|
RPL_SASLSUCCESS = "903"
|
||||||
|
ERR_SASLFAIL = "904"
|
||||||
|
ERR_SASLTOOLONG = "905"
|
||||||
|
ERR_SASLABORTED = "906"
|
||||||
|
ERR_SASLALREADY = "907"
|
||||||
|
RPL_SASLMECHS = "908"
|
||||||
)
|
)
|
||||||
|
@ -23,7 +23,7 @@ func createNickInUseHandler(i *irc.Client, state *State) func(string) string {
|
|||||||
|
|
||||||
state.sendJSON("error", IRCError{
|
state.sendJSON("error", IRCError{
|
||||||
Server: i.Host,
|
Server: i.Host,
|
||||||
Message: fmt.Sprintf("Nickname %s is already in use, using %s instead", nick, newNick),
|
Message: fmt.Sprintf("Nickname %s is unavailable, trying %s instead", nick, newNick),
|
||||||
})
|
})
|
||||||
|
|
||||||
return newNick
|
return newNick
|
||||||
|
@ -16,8 +16,10 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var excludedErrors = []string{
|
var excludedErrors = []string{
|
||||||
irc.ErrNicknameInUse,
|
irc.ERR_NICKNAMEINUSE,
|
||||||
irc.ErrForward,
|
irc.ERR_NICKCOLLISION,
|
||||||
|
irc.ERR_UNAVAILRESOURCE,
|
||||||
|
irc.ERR_FORWARD,
|
||||||
}
|
}
|
||||||
|
|
||||||
type ircHandler struct {
|
type ircHandler struct {
|
||||||
@ -229,7 +231,7 @@ func (i *ircHandler) quit(msg *irc.Message) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (i *ircHandler) info(msg *irc.Message) {
|
func (i *ircHandler) info(msg *irc.Message) {
|
||||||
if msg.Command == irc.ReplyWelcome {
|
if msg.Command == irc.RPL_WELCOME {
|
||||||
i.state.sendJSON("nick", Nick{
|
i.state.sendJSON("nick", Nick{
|
||||||
Server: i.client.Host,
|
Server: i.client.Host,
|
||||||
New: msg.Params[0],
|
New: msg.Params[0],
|
||||||
@ -293,7 +295,7 @@ func (i *ircHandler) topic(msg *irc.Message) {
|
|||||||
var channel string
|
var channel string
|
||||||
var nick string
|
var nick string
|
||||||
|
|
||||||
if msg.Command == irc.Topic {
|
if msg.Command == irc.TOPIC {
|
||||||
channel = msg.Params[0]
|
channel = msg.Params[0]
|
||||||
nick = msg.Nick
|
nick = msg.Nick
|
||||||
} else {
|
} else {
|
||||||
@ -437,39 +439,39 @@ func (i *ircHandler) receiveDCCSend(pack *irc.DCCSend, msg *irc.Message) {
|
|||||||
|
|
||||||
func (i *ircHandler) initHandlers() {
|
func (i *ircHandler) initHandlers() {
|
||||||
i.handlers = map[string]func(*irc.Message){
|
i.handlers = map[string]func(*irc.Message){
|
||||||
irc.Nick: i.nick,
|
irc.NICK: i.nick,
|
||||||
irc.Join: i.join,
|
irc.JOIN: i.join,
|
||||||
irc.Part: i.part,
|
irc.PART: i.part,
|
||||||
irc.Mode: i.mode,
|
irc.MODE: i.mode,
|
||||||
irc.Privmsg: i.message,
|
irc.PRIVMSG: i.message,
|
||||||
irc.Notice: i.message,
|
irc.NOTICE: i.message,
|
||||||
irc.Quit: i.quit,
|
irc.QUIT: i.quit,
|
||||||
irc.Topic: i.topic,
|
irc.TOPIC: i.topic,
|
||||||
irc.Error: i.error,
|
irc.ERROR: i.error,
|
||||||
irc.ReplyWelcome: i.info,
|
irc.RPL_WELCOME: i.info,
|
||||||
irc.ReplyYourHost: i.info,
|
irc.RPL_YOURHOST: i.info,
|
||||||
irc.ReplyCreated: i.info,
|
irc.RPL_CREATED: i.info,
|
||||||
irc.ReplyISupport: i.features,
|
irc.RPL_ISUPPORT: i.features,
|
||||||
irc.ReplyLUserClient: i.info,
|
irc.RPL_LUSERCLIENT: i.info,
|
||||||
irc.ReplyLUserOp: i.info,
|
irc.RPL_LUSEROP: i.info,
|
||||||
irc.ReplyLUserUnknown: i.info,
|
irc.RPL_LUSERUNKNOWN: i.info,
|
||||||
irc.ReplyLUserChannels: i.info,
|
irc.RPL_LUSERCHANNELS: i.info,
|
||||||
irc.ReplyLUserMe: i.info,
|
irc.RPL_LUSERME: i.info,
|
||||||
irc.ReplyWhoisUser: i.whoisUser,
|
irc.RPL_WHOISUSER: i.whoisUser,
|
||||||
irc.ReplyWhoisServer: i.whoisServer,
|
irc.RPL_WHOISSERVER: i.whoisServer,
|
||||||
irc.ReplyWhoisChannels: i.whoisChannels,
|
irc.RPL_WHOISCHANNELS: i.whoisChannels,
|
||||||
irc.ReplyEndOfWhois: i.whoisEnd,
|
irc.RPL_ENDOFWHOIS: i.whoisEnd,
|
||||||
irc.ReplyNoTopic: i.noTopic,
|
irc.RPL_NOTOPIC: i.noTopic,
|
||||||
irc.ReplyTopic: i.topic,
|
irc.RPL_TOPIC: i.topic,
|
||||||
irc.ReplyNamReply: i.names,
|
irc.RPL_NAMREPLY: i.names,
|
||||||
irc.ReplyEndOfNames: i.namesEnd,
|
irc.RPL_ENDOFNAMES: i.namesEnd,
|
||||||
irc.ReplyMotdStart: i.motdStart,
|
irc.RPL_MOTDSTART: i.motdStart,
|
||||||
irc.ReplyMotd: i.motd,
|
irc.RPL_MOTD: i.motd,
|
||||||
irc.ReplyEndOfMotd: i.motdEnd,
|
irc.RPL_ENDOFMOTD: i.motdEnd,
|
||||||
irc.ReplyList: i.list,
|
irc.RPL_LIST: i.list,
|
||||||
irc.ReplyListEnd: i.listEnd,
|
irc.RPL_LISTEND: i.listEnd,
|
||||||
irc.ErrErroneousNickname: i.badNick,
|
irc.ERR_ERRONEUSNICKNAME: i.badNick,
|
||||||
irc.ErrForward: i.forward,
|
irc.ERR_FORWARD: i.forward,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ func checkResponse(t *testing.T, expectedType string, expectedData interface{},
|
|||||||
|
|
||||||
func TestHandleIRCNick(t *testing.T) {
|
func TestHandleIRCNick(t *testing.T) {
|
||||||
res := dispatchMessage(&irc.Message{
|
res := dispatchMessage(&irc.Message{
|
||||||
Command: irc.Nick,
|
Command: irc.NICK,
|
||||||
Nick: "old",
|
Nick: "old",
|
||||||
Params: []string{"new"},
|
Params: []string{"new"},
|
||||||
})
|
})
|
||||||
@ -84,7 +84,7 @@ func TestHandleIRCNick(t *testing.T) {
|
|||||||
|
|
||||||
func TestHandleIRCJoin(t *testing.T) {
|
func TestHandleIRCJoin(t *testing.T) {
|
||||||
res := dispatchMessage(&irc.Message{
|
res := dispatchMessage(&irc.Message{
|
||||||
Command: irc.Join,
|
Command: irc.JOIN,
|
||||||
Nick: "joining",
|
Nick: "joining",
|
||||||
Params: []string{"#chan"},
|
Params: []string{"#chan"},
|
||||||
})
|
})
|
||||||
@ -98,7 +98,7 @@ func TestHandleIRCJoin(t *testing.T) {
|
|||||||
|
|
||||||
func TestHandleIRCPart(t *testing.T) {
|
func TestHandleIRCPart(t *testing.T) {
|
||||||
res := dispatchMessage(&irc.Message{
|
res := dispatchMessage(&irc.Message{
|
||||||
Command: irc.Part,
|
Command: irc.PART,
|
||||||
Nick: "parting",
|
Nick: "parting",
|
||||||
Params: []string{"#chan", "the reason"},
|
Params: []string{"#chan", "the reason"},
|
||||||
})
|
})
|
||||||
@ -111,7 +111,7 @@ func TestHandleIRCPart(t *testing.T) {
|
|||||||
}, res)
|
}, res)
|
||||||
|
|
||||||
res = dispatchMessage(&irc.Message{
|
res = dispatchMessage(&irc.Message{
|
||||||
Command: irc.Part,
|
Command: irc.PART,
|
||||||
Nick: "parting",
|
Nick: "parting",
|
||||||
Params: []string{"#chan"},
|
Params: []string{"#chan"},
|
||||||
})
|
})
|
||||||
@ -125,7 +125,7 @@ func TestHandleIRCPart(t *testing.T) {
|
|||||||
|
|
||||||
func TestHandleIRCMode(t *testing.T) {
|
func TestHandleIRCMode(t *testing.T) {
|
||||||
res := dispatchMessage(&irc.Message{
|
res := dispatchMessage(&irc.Message{
|
||||||
Command: irc.Mode,
|
Command: irc.MODE,
|
||||||
Params: []string{"#chan", "+o-v", "nick"},
|
Params: []string{"#chan", "+o-v", "nick"},
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -140,7 +140,7 @@ func TestHandleIRCMode(t *testing.T) {
|
|||||||
|
|
||||||
func TestHandleIRCMessage(t *testing.T) {
|
func TestHandleIRCMessage(t *testing.T) {
|
||||||
res := dispatchMessage(&irc.Message{
|
res := dispatchMessage(&irc.Message{
|
||||||
Command: irc.Privmsg,
|
Command: irc.PRIVMSG,
|
||||||
Nick: "nick",
|
Nick: "nick",
|
||||||
Params: []string{"#chan", "the message"},
|
Params: []string{"#chan", "the message"},
|
||||||
})
|
})
|
||||||
@ -153,7 +153,7 @@ func TestHandleIRCMessage(t *testing.T) {
|
|||||||
assert.Equal(t, "the message", msg.Content)
|
assert.Equal(t, "the message", msg.Content)
|
||||||
|
|
||||||
res = dispatchMessage(&irc.Message{
|
res = dispatchMessage(&irc.Message{
|
||||||
Command: irc.Privmsg,
|
Command: irc.PRIVMSG,
|
||||||
Nick: "someone",
|
Nick: "someone",
|
||||||
Params: []string{"nick", "the message"},
|
Params: []string{"nick", "the message"},
|
||||||
})
|
})
|
||||||
@ -168,7 +168,7 @@ func TestHandleIRCMessage(t *testing.T) {
|
|||||||
|
|
||||||
func TestHandleIRCQuit(t *testing.T) {
|
func TestHandleIRCQuit(t *testing.T) {
|
||||||
res := dispatchMessage(&irc.Message{
|
res := dispatchMessage(&irc.Message{
|
||||||
Command: irc.Quit,
|
Command: irc.QUIT,
|
||||||
Nick: "nick",
|
Nick: "nick",
|
||||||
Params: []string{"the reason"},
|
Params: []string{"the reason"},
|
||||||
})
|
})
|
||||||
@ -182,7 +182,7 @@ func TestHandleIRCQuit(t *testing.T) {
|
|||||||
|
|
||||||
func TestHandleIRCWelcome(t *testing.T) {
|
func TestHandleIRCWelcome(t *testing.T) {
|
||||||
res := dispatchMessageMulti(&irc.Message{
|
res := dispatchMessageMulti(&irc.Message{
|
||||||
Command: irc.ReplyWelcome,
|
Command: irc.RPL_WELCOME,
|
||||||
Nick: "nick",
|
Nick: "nick",
|
||||||
Params: []string{"nick", "some", "text"},
|
Params: []string{"nick", "some", "text"},
|
||||||
})
|
})
|
||||||
@ -206,18 +206,18 @@ func TestHandleIRCWhois(t *testing.T) {
|
|||||||
i := newIRCHandler(c, s)
|
i := newIRCHandler(c, s)
|
||||||
|
|
||||||
i.dispatchMessage(&irc.Message{
|
i.dispatchMessage(&irc.Message{
|
||||||
Command: irc.ReplyWhoisUser,
|
Command: irc.RPL_WHOISUSER,
|
||||||
Params: []string{"", "nick", "user", "host", "", "realname"},
|
Params: []string{"", "nick", "user", "host", "", "realname"},
|
||||||
})
|
})
|
||||||
i.dispatchMessage(&irc.Message{
|
i.dispatchMessage(&irc.Message{
|
||||||
Command: irc.ReplyWhoisServer,
|
Command: irc.RPL_WHOISSERVER,
|
||||||
Params: []string{"", "", "srv.com"},
|
Params: []string{"", "", "srv.com"},
|
||||||
})
|
})
|
||||||
i.dispatchMessage(&irc.Message{
|
i.dispatchMessage(&irc.Message{
|
||||||
Command: irc.ReplyWhoisChannels,
|
Command: irc.RPL_WHOISCHANNELS,
|
||||||
Params: []string{"#chan #chan1"},
|
Params: []string{"#chan #chan1"},
|
||||||
})
|
})
|
||||||
i.dispatchMessage(&irc.Message{Command: irc.ReplyEndOfWhois})
|
i.dispatchMessage(&irc.Message{Command: irc.RPL_ENDOFWHOIS})
|
||||||
|
|
||||||
checkResponse(t, "whois", WhoisReply{
|
checkResponse(t, "whois", WhoisReply{
|
||||||
Nick: "nick",
|
Nick: "nick",
|
||||||
@ -231,7 +231,7 @@ func TestHandleIRCWhois(t *testing.T) {
|
|||||||
|
|
||||||
func TestHandleIRCTopic(t *testing.T) {
|
func TestHandleIRCTopic(t *testing.T) {
|
||||||
res := dispatchMessage(&irc.Message{
|
res := dispatchMessage(&irc.Message{
|
||||||
Command: irc.ReplyTopic,
|
Command: irc.RPL_TOPIC,
|
||||||
Params: []string{"target", "#chan", "the topic"},
|
Params: []string{"target", "#chan", "the topic"},
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -242,7 +242,7 @@ func TestHandleIRCTopic(t *testing.T) {
|
|||||||
}, res)
|
}, res)
|
||||||
|
|
||||||
res = dispatchMessage(&irc.Message{
|
res = dispatchMessage(&irc.Message{
|
||||||
Command: irc.Topic,
|
Command: irc.TOPIC,
|
||||||
Params: []string{"#chan", "the topic"},
|
Params: []string{"#chan", "the topic"},
|
||||||
Nick: "bob",
|
Nick: "bob",
|
||||||
})
|
})
|
||||||
@ -257,7 +257,7 @@ func TestHandleIRCTopic(t *testing.T) {
|
|||||||
|
|
||||||
func TestHandleIRCNoTopic(t *testing.T) {
|
func TestHandleIRCNoTopic(t *testing.T) {
|
||||||
res := dispatchMessage(&irc.Message{
|
res := dispatchMessage(&irc.Message{
|
||||||
Command: irc.ReplyNoTopic,
|
Command: irc.RPL_NOTOPIC,
|
||||||
Params: []string{"target", "#chan", "No topic set."},
|
Params: []string{"target", "#chan", "No topic set."},
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -274,15 +274,15 @@ func TestHandleIRCNames(t *testing.T) {
|
|||||||
i := newIRCHandler(c, s)
|
i := newIRCHandler(c, s)
|
||||||
|
|
||||||
i.dispatchMessage(&irc.Message{
|
i.dispatchMessage(&irc.Message{
|
||||||
Command: irc.ReplyNamReply,
|
Command: irc.RPL_NAMREPLY,
|
||||||
Params: []string{"", "", "#chan", "a b c"},
|
Params: []string{"", "", "#chan", "a b c"},
|
||||||
})
|
})
|
||||||
i.dispatchMessage(&irc.Message{
|
i.dispatchMessage(&irc.Message{
|
||||||
Command: irc.ReplyNamReply,
|
Command: irc.RPL_NAMREPLY,
|
||||||
Params: []string{"", "", "#chan", "d"},
|
Params: []string{"", "", "#chan", "d"},
|
||||||
})
|
})
|
||||||
i.dispatchMessage(&irc.Message{
|
i.dispatchMessage(&irc.Message{
|
||||||
Command: irc.ReplyEndOfNames,
|
Command: irc.RPL_ENDOFNAMES,
|
||||||
Params: []string{"", "#chan"},
|
Params: []string{"", "#chan"},
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -300,18 +300,18 @@ func TestHandleIRCMotd(t *testing.T) {
|
|||||||
i := newIRCHandler(c, s)
|
i := newIRCHandler(c, s)
|
||||||
|
|
||||||
i.dispatchMessage(&irc.Message{
|
i.dispatchMessage(&irc.Message{
|
||||||
Command: irc.ReplyMotdStart,
|
Command: irc.RPL_MOTDSTART,
|
||||||
Params: []string{"motd title"},
|
Params: []string{"motd title"},
|
||||||
})
|
})
|
||||||
i.dispatchMessage(&irc.Message{
|
i.dispatchMessage(&irc.Message{
|
||||||
Command: irc.ReplyMotd,
|
Command: irc.RPL_MOTD,
|
||||||
Params: []string{"line 1"},
|
Params: []string{"line 1"},
|
||||||
})
|
})
|
||||||
i.dispatchMessage(&irc.Message{
|
i.dispatchMessage(&irc.Message{
|
||||||
Command: irc.ReplyMotd,
|
Command: irc.RPL_MOTD,
|
||||||
Params: []string{"line 2"},
|
Params: []string{"line 2"},
|
||||||
})
|
})
|
||||||
i.dispatchMessage(&irc.Message{Command: irc.ReplyEndOfMotd})
|
i.dispatchMessage(&irc.Message{Command: irc.RPL_ENDOFMOTD})
|
||||||
|
|
||||||
checkResponse(t, "motd", MOTD{
|
checkResponse(t, "motd", MOTD{
|
||||||
Server: "host.com",
|
Server: "host.com",
|
||||||
@ -327,7 +327,7 @@ func TestHandleIRCBadNick(t *testing.T) {
|
|||||||
i := newIRCHandler(c, s)
|
i := newIRCHandler(c, s)
|
||||||
|
|
||||||
i.dispatchMessage(&irc.Message{
|
i.dispatchMessage(&irc.Message{
|
||||||
Command: irc.ErrErroneousNickname,
|
Command: irc.ERR_ERRONEUSNICKNAME,
|
||||||
})
|
})
|
||||||
|
|
||||||
// It should print the error message first
|
// It should print the error message first
|
||||||
|
Loading…
Reference in New Issue
Block a user