summaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'main.go')
-rw-r--r--main.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/main.go b/main.go
index 7f3ddb8..53bfa20 100644
--- a/main.go
+++ b/main.go
@@ -4,6 +4,7 @@ import (
"flag"
"fmt"
"log"
+ "strings"
irc "github.com/fluffle/goirc/client"
)
@@ -29,6 +30,7 @@ func (n *Notify) Write(p []byte) (int, error) {
}
func privmsg(room string) irc.HandlerFunc {
+ last := make(map[string]string)
return func(conn *irc.Conn, line *irc.Line) {
switch t := line.Text(); {
case isFlood(t):
@@ -36,6 +38,15 @@ func privmsg(room string) irc.HandlerFunc {
log.Println("kick", line.Nick)
conn.Kick(room, line.Nick)
}
+ case strings.HasPrefix(t, "s"):
+ global := strings.HasSuffix(t, "g")
+ if tofix, ok := last[line.Nick]; ok {
+ fixed := re(tofix, t[1:], global)
+ if fixed != "" && fixed != tofix {
+ fmt.Fprintf(NewNotify(conn, line.Target()), "%v meant to say: %q", line.Nick, fixed)
+ last[line.Nick] = fixed
+ }
+ }
default:
for _, v := range getLinks(t) {
title, err := getTitle(v)
@@ -46,6 +57,7 @@ func privmsg(room string) irc.HandlerFunc {
fmt.Fprintf(NewNotify(conn, line.Target()), "Title: %v", title)
}
}
+ last[line.Nick] = t
}
}
}