summaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'main.go')
-rw-r--r--main.go13
1 files changed, 8 insertions, 5 deletions
diff --git a/main.go b/main.go
index 09a2d92..41b124c 100644
--- a/main.go
+++ b/main.go
@@ -46,7 +46,8 @@ func privmsg(room string) irc.HandlerFunc {
log.Println("panic", r)
}
}()
- switch t := line.Text(); {
+ t := line.Text()
+ switch {
case line.Nick == conn.Me().Nick:
// ignore self
case isFlood(t):
@@ -58,15 +59,17 @@ func privmsg(room string) irc.HandlerFunc {
case t == lastRe[line.Nick]:
log.Println("ignore", t)
case strings.HasPrefix(t, "s"):
- log.Println("regexp", t)
global := strings.HasSuffix(t, "g")
if tofix, ok := last[line.Nick]; ok {
- fixed := re(tofix, t[1:], global)
- if fixed != "" && fixed != tofix {
+ fixed, err := re(tofix, t[1:], global)
+ if err == nil && fixed != tofix {
+ log.Println("regexp", t)
fmt.Fprintf(NewNotify(conn, line.Target()), "%v meant to say: %s", line.Nick, fixed)
+ lastRe[line.Nick] = t
+ return
}
}
- lastRe[line.Nick] = t
+ fallthrough
default:
for _, v := range getLinks(t) {
title, err := getTitle(v)