From 659601e7c0cbaa2494c6c09c3ef15f6d98da30f6 Mon Sep 17 00:00:00 2001 From: blackbeard420 Date: Wed, 27 Oct 2021 21:25:41 -0400 Subject: [PATCH] LUSERCHANNEL/LUSERCLIENT handling --- irc_replies.go | 7 ++++--- irc_test.go | 23 ++++++++++++++++++++++- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/irc_replies.go b/irc_replies.go index 644a60c..6880746 100644 --- a/irc_replies.go +++ b/irc_replies.go @@ -1,9 +1,10 @@ package irc const ( - RPL_LUSERCLIENT = 251 - RPL_NAMREPLY = 353 - RPL_ENDOFMOTD = 376 + RPL_LUSERCLIENT = 251 + RPL_LUSERCHANNELS = 254 + RPL_NAMREPLY = 353 + RPL_ENDOFMOTD = 376 ERR_NOSUCHNICK = 401 ) diff --git a/irc_test.go b/irc_test.go index 4beff36..bf323b2 100644 --- a/irc_test.go +++ b/irc_test.go @@ -3,6 +3,7 @@ package irc import ( "fmt" "log" + "strconv" "strings" "testing" "time" @@ -40,7 +41,6 @@ func TestLusers(t *testing.T) { con.NumericCallback = func(from string, i int, args string) { if i == RPL_LUSERCLIENT { - log.Printf("luser reply: %s\n", args) con.SendJoin(channel) s := strings.Split(args, ":") @@ -58,6 +58,27 @@ func TestLusers(t *testing.T) { con.Run() } +func TestLusersChannels(t *testing.T) { + con := NewConnection("irc.ouch.chat:6667", "irc-go", "irc-go", nil, []string{channel}) + + con.NumericCallback = func(from string, i int, args string) { + if i == RPL_LUSERCHANNELS { + con.SendJoin(channel) + + s := strings.TrimSpace(strings.Split(args, " ")[1]) + val, err := strconv.Atoi(s) + if err == nil { + con.SendPrivmsg(channel, fmt.Sprintf("There are %d channels formed", val)) + } else { + t.Fatal(err.Error()) + } + con.SendQuit("scan complete") + } + } + + con.Run() +} + func TestParser(t *testing.T) { log.Printf("testing %s\n", t.Name()) }