Skip to content

Commit df74db0

Browse files
committed
Remove hardcoded nick from handlers
1 parent bd52ece commit df74db0

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

handlers.go

+6-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"database/sql"
66
"errors"
7+
"fmt"
78
"goirc/bot"
89
"goirc/db/model"
910
"goirc/events"
@@ -23,13 +24,16 @@ import (
2324
"goirc/internal/ai"
2425
db "goirc/model"
2526
"goirc/web"
27+
"regexp"
2628
"time"
2729

2830
"github.com/robfig/cron"
2931
"github.com/sashabaranov/go-openai"
3032
)
3133

3234
func addHandlers(b *bot.Bot) {
35+
nick := regexp.QuoteMeta(b.Conn.GetNick())
36+
3337
b.Handle(`^!catchup`, handlers.Catchup)
3438
b.Handle(`^,(.+)$`, handlers.CreateNote)
3539
b.Handle(`^([^\s:]+): (.+)$`, handlers.DeferredDelivery)
@@ -70,8 +74,8 @@ func addHandlers(b *bot.Bot) {
7074
b.Handle(`^!deauth$`, web.HandleDeauth)
7175
b.Handle(`night`, bedtime.Handle)
7276
b.Handle(`^!election`, election.Handle)
73-
b.Handle(`^annie:?(.+)$`, annie.Handle)
74-
b.Handle(`^(.+),? annie.?$`, annie.Handle)
77+
b.Handle(fmt.Sprintf(`^%s:?(.+)$`, nick), annie.Handle)
78+
b.Handle(fmt.Sprintf(`^(.+),? %s.?$`, nick), annie.Handle)
7579
b.Handle(`^!bible (.+)$`, bible.Handle)
7680

7781
b.Repeat(10*time.Second, handlers.DoRemind)

0 commit comments

Comments
 (0)