From 77209f57b03565e880fb7d04cec91931dc5e9677 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Fri, 14 Apr 2017 11:37:11 +0200 Subject: [PATCH] authenticate at NickServ using IRC passwords related to issue #36, as it gets rid of a dynamic listener --- frank.go | 37 ++++--------------------------------- 1 file changed, 4 insertions(+), 33 deletions(-) diff --git a/frank.go b/frank.go index 2adcea5..b60c0c9 100644 --- a/frank.go +++ b/frank.go @@ -97,41 +97,12 @@ func kill() { } func boot() { + if *nickserv_password != "" { + Post(fmt.Sprintf("PASS nickserv=%s", *nickserv_password)) + } Post(fmt.Sprintf("NICK %s", *nick)) Post(fmt.Sprintf("USER bot 0 * :%s von Bötterich", *nick)) - - if *nickserv_password == "" { - setupJoinChannels() - return - } - - nickserv := make(chan bool, 1) - listener := ListenerAdd("nickserv auth detector", func(parsed *irc.Message) error { - // PREFIX=services.robustirc.net COMMAND=MODE PARAMS=[frank2] TRAILING=+r - is_me := Target(parsed) == *nick - is_plus_r := strings.HasPrefix(parsed.Trailing(), "+") && strings.Contains(parsed.Trailing(), "r") - - if parsed.Command == "MODE" && is_me && is_plus_r { - nickserv <- true - } - return nil - }) - - log.Printf("NICKSERV: Authenticating…") - Privmsg("nickserv", "identify "+*nickserv_password) - - go func() { - select { - case <-nickserv: - log.Printf("NICKSERV: auth successful") - - case <-time.After(10 * time.Second): - log.Printf("NICKSERV: auth failed. No response within 10s, joining channels anyway. Maybe check the password, i.e. “/msg frank msg nickserv identify ” and watch the logs.") - } - - listener.Remove() - setupJoinChannels() - }() + setupJoinChannels() } func main() {