reorder registration to comply with rfc2812/section-2.3
This commit is contained in:
parent
3c49159982
commit
87867c7352
22
irc.go
22
irc.go
@ -93,6 +93,16 @@ func (c *Connection) SendNames(channel string) {
|
|||||||
c.Sock.Write([]byte(fmt.Sprintf("NAMES %s\n", channel)))
|
c.Sock.Write([]byte(fmt.Sprintf("NAMES %s\n", channel)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//SendPass sends a PASS for network
|
||||||
|
func (c *Connection) SendPass(pass string) {
|
||||||
|
c.Sock.Write([]byte(fmt.Sprintf("PASS %s\n", pass)))
|
||||||
|
}
|
||||||
|
|
||||||
|
//SendUser sends a USER command for the network
|
||||||
|
func (c *Connection) SendUser(user, realname string) {
|
||||||
|
c.Sock.Write([]byte(fmt.Sprintf("USER %s * * :%s\n", user, realname)))
|
||||||
|
}
|
||||||
|
|
||||||
//DelayedSend sends a privmsg AFTER the specified delay
|
//DelayedSend sends a privmsg AFTER the specified delay
|
||||||
func (c *Connection) DelayedSend(sock net.Conn, dur time.Duration, channel, msg string) {
|
func (c *Connection) DelayedSend(sock net.Conn, dur time.Duration, channel, msg string) {
|
||||||
time.Sleep(dur)
|
time.Sleep(dur)
|
||||||
@ -108,12 +118,16 @@ func NewConnection(server, nick, user string, pass *string, chans []string) *Con
|
|||||||
log.Fatalln(err.Error())
|
log.Fatalln(err.Error())
|
||||||
}
|
}
|
||||||
irc.Sock = sock
|
irc.Sock = sock
|
||||||
irc.Sock.Write([]byte(fmt.Sprintf("USER %s * * :%s\n", user, user)))
|
|
||||||
|
if pass != nil {
|
||||||
|
irc.SendPass(*pass)
|
||||||
|
}
|
||||||
|
|
||||||
irc.SendNick(nick)
|
irc.SendNick(nick)
|
||||||
irc.curNick = nick
|
irc.curNick = nick
|
||||||
if pass != nil {
|
|
||||||
irc.Sock.Write([]byte(fmt.Sprintf("PASS %s\n", *pass)))
|
irc.SendUser(user, user)
|
||||||
}
|
|
||||||
return irc
|
return irc
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ func TestSimpleIrc(t *testing.T) {
|
|||||||
|
|
||||||
go con.Run()
|
go con.Run()
|
||||||
|
|
||||||
time.Sleep(30 * time.Second)
|
time.Sleep(10 * time.Second)
|
||||||
|
|
||||||
con.SendPrivmsg("#freedom", "\x0356 FUCK YALL BITCHES")
|
con.SendPrivmsg("#freedom", "\x0356 FUCK YALL BITCHES")
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user