From 1236d44bfc9eaac99e078577214b8c40bb3b221e Mon Sep 17 00:00:00 2001 From: Amanda Cameron Date: Sat, 13 Dec 2014 09:48:56 -0500 Subject: [PATCH 1/2] Fix the IRC notification plugin. --- plugin/notify/irc/irc.go | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/plugin/notify/irc/irc.go b/plugin/notify/irc/irc.go index 7e232677..3d935e10 100644 --- a/plugin/notify/irc/irc.go +++ b/plugin/notify/irc/irc.go @@ -53,11 +53,23 @@ func (i *IRC) sendSuccess(req *model.Request) error { // to the connected IRC client func (i *IRC) send(channel string, message string) error { client := irc.IRC(i.Nick, i.Nick) - if client != nil { + + if client == nil { return fmt.Errorf("Error creating IRC client") } - defer client.Disconnect() - client.Connect(i.Server) - client.Notice(channel, message) + + err := client.Connect(i.Server) + + if err != nil { + return fmt.Errorf("Error connecting to IRC server: %v", err) + } + + client.AddCallback("001", func(_ *irc.Event) { + client.Notice(channel, message) + client.Disconnect() + }) + + go client.Loop() + return nil } From 74f574f864ea9d71a04a11ebcc61a537247db82a Mon Sep 17 00:00:00 2001 From: Amanda Cameron Date: Sat, 13 Dec 2014 10:23:44 -0500 Subject: [PATCH 2/2] Fix IRC notification to use .Quit() instead of .Disconnect() --- plugin/notify/irc/irc.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/notify/irc/irc.go b/plugin/notify/irc/irc.go index 3d935e10..33fa0266 100644 --- a/plugin/notify/irc/irc.go +++ b/plugin/notify/irc/irc.go @@ -66,7 +66,7 @@ func (i *IRC) send(channel string, message string) error { client.AddCallback("001", func(_ *irc.Event) { client.Notice(channel, message) - client.Disconnect() + client.Quit() }) go client.Loop()