<commit_before>package main

import (
	"irc"
	"fmt"
	"os"
	"bufio"
	"strings"
)

func main() {
	// create new IRC connection
	c := irc.New("GoTest", "gotest", "GoBot")
	c.AddHandler("connected",
		func(conn *irc.Conn, line *irc.Line) { conn.Join("#go-nuts") })

	// connect to server
	if err := c.Connect("irc.freenode.net", ""); err != nil {
		fmt.Printf("Connection error: %s\n", err)
		return
	}

	// set up a goroutine to read commands from stdin
	in := make(chan string, 4)
	reallyquit := false
	go func() {
		con := bufio.NewReader(os.Stdin)
		for {
			s, err := con.ReadString('\n')
			if err != nil {
				// wha?, maybe ctrl-D...
				close(in)
				break
			}
			// no point in sending empty lines down the channel
			if len(s) > 2 {
				in <- s[0:len(s)-1]
			}
		}
	}()

	// set up a goroutine to do parsey things with the stuff from stdin
	go func() {
		for cmd := range in {
			if cmd[0] == ':' {
				switch idx := strings.Index(cmd, " "); {
				case idx == -1:
					continue
				case cmd[1] == 'q':
					reallyquit = true
					c.Quit(cmd[idx+1 : len(cmd)])
				case cmd[1] == 'j':
					c.Join(cmd[idx+1 : len(cmd)])
				case cmd[1] == 'p':
					c.Part(cmd[idx+1 : len(cmd)])
				case cmd[1] == 'd':
					fmt.Printf(c.String())
				}
			} else {
				c.Raw(cmd)
			}
		}
	}()

	// stall here waiting for asplode on error channel
	for {
		for err := range c.Err {
			fmt.Printf("goirc error: %s\n", err)
		}
		if reallyquit {
			break
		}
		fmt.Println("Reconnecting...")<commit_msg>add flood testing capability to test client<commit_after>package main

import (
	"irc"
	"fmt"
	"os"
	"bufio"
	"strings"
)

func main() {
	// create new IRC connection
	c := irc.New("GoTest", "gotest", "GoBot")
	c.AddHandler("connected",
		func(conn *irc.Conn, line *irc.Line) { conn.Join("#go-nuts") })

	// connect to server
	if err := c.Connect("irc.freenode.net", ""); err != nil {
		fmt.Printf("Connection error: %s\n", err)
		return
	}

	// set up a goroutine to read commands from stdin
	in := make(chan string, 4)
	reallyquit := false
	go func() {
		con := bufio.NewReader(os.Stdin)
		for {
			s, err := con.ReadString('\n')
			if err != nil {
				// wha?, maybe ctrl-D...
				close(in)
				break
			}
			// no point in sending empty lines down the channel
			if len(s) > 2 {
				in <- s[0:len(s)-1]
			}
		}
	}()

	// set up a goroutine to do parsey things with the stuff from stdin
	go func() {
		for cmd := range in {
			if cmd[0] == ':' {
				switch idx := strings.Index(cmd, " "); {
				case cmd[1] == 'd':
					fmt.Printf(c.String())
				case cmd[1] == 'f':
					if len(cmd) > 2 && cmd[2] == 'e' {
						// enable flooding
						c.Flood = true
					} else if len(cmd) > 2 && cmd[2] == 'd' {
						// disable flooding
						c.Flood = false
					}
					for i := 0; i < 20; i++ {
						c.Privmsg("#", "flood test!")
					}
				case idx == -1:
					continue
				case cmd[1] == 'q':
					reallyquit = true
					c.Quit(cmd[idx+1 : len(cmd)])
				case cmd[1] == 'j':
					c.Join(cmd[idx+1 : len(cmd)])
				case cmd[1] == 'p':
					c.Part(cmd[idx+1 : len(cmd)])
				}
			} else {
				c.Raw(cmd)
			}
		}
	}()

	// stall here waiting for asplode on error channel
	for {
		for err := range c.Err {
			fmt.Printf("goirc error: %s\n", err)
		}
		if reallyquit {
			break
		}
		fmt.Println("Reconnecting...")
{'fraction_non_alphanumeric': 0.18424242424242424, 'fraction_numerical': 0.010303030303030303, 'mean_word_length': 2.351269035532995, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1000472', 'n_tokens_mistral': 1576, 'n_tokens_neox': 1296, 'n_words': 344}