This using `msg` instead of `target` in the JoinCallback(Ex) seems to
work correctly
This commit is contained in:
blackbeard420 2025-03-06 13:12:40 -05:00
parent d363768965
commit 820f2b96a2
2 changed files with 32 additions and 2 deletions

4
irc.go
View File

@ -274,9 +274,9 @@ func (c *Connection) parseMessage(line string) {
}
}
case "join":
c.addNick(target, GetNick(from))
c.addNick(msg, GetNick(from))
if c.JoinCallback != nil {
c.JoinCallback(from, target)
c.JoinCallback(from, msg)
}
if c.JoinCallbackEx != nil {

View File

@ -37,6 +37,36 @@ func TestJoinChannel(t *testing.T) {
con.SendQuit("go-irc: Test Join Channel")
}
func TestJoinCallback(t *testing.T) {
con := NewConnection("irc.ouch.chat:6667", "irc-go", "irc-go", nil, []string{channel})
i := 0
con.JoinCallback = func(from, target string) {
i++
for _, x := range con.userList[channel] {
con.SendPrivmsg(channel, x)
}
if i == 3 {
con.SendQuit("")
}
}
go con.Run()
time.Sleep(10 * time.Second)
t1 := NewConnection("irc.ouch.chat:6667", "abc", "abc", nil, []string{channel})
t2 := NewConnection("irc.ouch.chat:6667", "def", "def", nil, []string{channel})
go t1.Run()
time.Sleep(5 * time.Second)
go t2.Run()
time.Sleep(10 * time.Second)
}
func TestLusers(t *testing.T) {
con := NewConnection("irc.ouch.chat:6667", "irc-go", "irc-go", nil, []string{channel})