2020-01-22 09:53:44 -05:00
|
|
|
package irc
|
|
|
|
|
|
|
|
import (
|
2021-10-27 21:10:18 -04:00
|
|
|
"fmt"
|
2020-01-22 09:53:44 -05:00
|
|
|
"log"
|
2021-10-27 21:10:18 -04:00
|
|
|
"strings"
|
2020-01-22 09:53:44 -05:00
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
2021-10-27 19:51:18 -04:00
|
|
|
const (
|
|
|
|
channel = "#warez"
|
|
|
|
)
|
|
|
|
|
2021-10-27 20:09:03 -04:00
|
|
|
func TestJoinChannel(t *testing.T) {
|
2021-10-27 19:51:18 -04:00
|
|
|
con := NewConnection("irc.ouch.chat:6667", "irc-go", "irc-go", nil, []string{channel})
|
2020-01-22 09:53:44 -05:00
|
|
|
|
|
|
|
go con.Run()
|
|
|
|
|
2021-10-27 20:09:03 -04:00
|
|
|
time.Sleep(5 * time.Second)
|
2021-10-27 19:51:18 -04:00
|
|
|
log.Printf("%d users in channel %s\n", len(con.userList[channel]), channel)
|
2021-10-27 20:09:03 -04:00
|
|
|
con.SendQuit("scan complete")
|
2021-10-27 19:51:18 -04:00
|
|
|
|
|
|
|
//con.SendPrivmsg("#warez", fmt.Sprintf("\x0356 FUCK YALL BITCHES %d", len(con.userList["#warez"])))
|
2020-09-01 22:18:43 -04:00
|
|
|
|
2021-10-27 19:51:18 -04:00
|
|
|
/*
|
|
|
|
i := 0
|
|
|
|
for _, v := range con.userList[channel] {
|
|
|
|
con.SendPrivmsg(channel, fmt.Sprintf("yo %s fuck you", v))
|
|
|
|
if i >= 5 {
|
|
|
|
time.Sleep(1000 * time.Millisecond)
|
|
|
|
i = 0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*/
|
2020-01-22 09:53:44 -05:00
|
|
|
}
|
|
|
|
|
2021-10-27 20:09:03 -04:00
|
|
|
func TestLusers(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_LUSERCLIENT {
|
|
|
|
log.Printf("luser reply: %s\n", args)
|
2021-10-27 21:10:18 -04:00
|
|
|
con.SendJoin(channel)
|
|
|
|
|
|
|
|
s := strings.Split(args, ":")
|
|
|
|
if len(s) > 1 {
|
|
|
|
users := 0
|
|
|
|
invis := 0
|
|
|
|
servers := 0
|
|
|
|
fmt.Sscanf(s[1], "There are %d users and %d invisible on %d servers", &users, &invis, &servers)
|
|
|
|
con.SendPrivmsg(channel, fmt.Sprintf("total users on network: %d, invisible %d, servers %d", users, invis, servers))
|
|
|
|
}
|
2021-10-27 20:09:03 -04:00
|
|
|
con.SendQuit("scan complete")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
con.Run()
|
|
|
|
}
|
|
|
|
|
2020-01-22 09:53:44 -05:00
|
|
|
func TestParser(t *testing.T) {
|
|
|
|
log.Printf("testing %s\n", t.Name())
|
|
|
|
}
|