Join +i-only channels on identification.

configurable-file-paths
Robert Gerus 2015-11-19 08:51:23 +01:00
parent 9fb64a8088
commit 058005a166
1 changed files with 34 additions and 0 deletions

View File

@ -46,6 +46,40 @@ func nickserv(output chan irc.Message, msg irc.Message) {
}
}
func joinsecuredchannels(output chan irc.Message, msg irc.Message) {
if msg.Prefix.String() != cfg.LookupString(msg.Context, "NickServPrefix") {
log.Println("Context:", msg.Context, "Someone is spoofing nickserv!")
return
}
regexStr := cfg.LookupString(msg.Context, "NickServRegexOK")
if regexStr == "" {
regexStr = "^You are now identified"
}
buffer := new(bytes.Buffer)
buffer.WriteString(msg.Trailing)
b, err := regexp.Match(regexStr, buffer.Bytes())
if err != nil {
log.Println("Context:", msg.Context, "NickServ regex error:", err)
return
}
if !b {
return
}
for _, channel := range cfg.LookupStringSlice(msg.Context, "SecuredChannels") {
log.Println(msg.Context["Network"], "joining channel", channel)
output <- irc.Message{
Command: "JOIN",
Params: []string{channel},
}
}
}
func init() {
addCallback("NOTICE", "nickserv", nickserv)
addCallback("NOTICE", "join +i-only channels", joinsecuredchannels)
}