summaryrefslogtreecommitdiff
path: root/go/acronym.go
diff options
context:
space:
mode:
Diffstat (limited to 'go/acronym.go')
-rw-r--r--go/acronym.go18
1 files changed, 4 insertions, 14 deletions
diff --git a/go/acronym.go b/go/acronym.go
index 955f256..ef92ef4 100644
--- a/go/acronym.go
+++ b/go/acronym.go
@@ -8,7 +8,7 @@ import(
"net"
"os"
"regexp"
- "strings"
+ //"strings"
"time"
)
@@ -26,19 +26,9 @@ func main() {
defer dictfile.Close()
scanner := bufio.NewScanner( dictfile )
scanner.Split(bufio.ScanLines)
- var clines []string
- var blines []string
- var klines []string
+ dict := make( map[string][]string )
for scanner.Scan() {
- if strings.HasPrefix( scanner.Text(), "c" ) {
- clines = append(clines, scanner.Text())
- }
- if strings.HasPrefix( scanner.Text(), "b" ) {
- blines = append(blines, scanner.Text())
- }
- if strings.HasPrefix( scanner.Text(), "k" ) {
- klines = append(klines, scanner.Text())
- }
+ dict[scanner.Text()[:1]] = append(dict[scanner.Text()[:1]], scanner.Text())
}
r := regexp.MustCompile( "^[0-9]{2}:[0-9]{2} <(.bungmonkey|.cornbugs|.wishapb|@[a-zA-Z0-9_]+)> +!cbk" )
@@ -52,7 +42,7 @@ func main() {
}
if r.MatchString( logline.Text ) {
var cbk string
- cbk = fmt.Sprintf( "%s %s %s\n", clines[ rand.Intn( len( clines ) ) ], blines[ rand.Intn( len( blines ) ) ], klines[ rand.Intn( len( klines ) ) ] )
+ cbk = fmt.Sprintf( "%s %s %s\n", dict["c"][ rand.Intn( len( dict["c"] ) ) ], dict["b"][ rand.Intn( len( dict["b"] ) ) ], dict["k"][ rand.Intn( len( dict["k"] ) ) ] )
fmt.Printf( "%v", cbk )
ircsocket, err := net.Dial( "unix", os.ExpandEnv( "${HOME}/.irssi/twitch-cornbugs-socket" ) )
check( err )