summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWim <wim@42.be>2018-11-22 22:46:38 +0100
committerWim <wim@42.be>2018-11-22 22:46:38 +0100
commita2b45bc799de77aa278212271709201336e9e796 (patch)
tree46702440e95d47978aaaefd55ccf3bc83509deb9
parent757657f29ca00fd000e113c29ebe55c5fccecd54 (diff)
downloadmatterbridge-msglm-a2b45bc799de77aa278212271709201336e9e796.tar.gz
matterbridge-msglm-a2b45bc799de77aa278212271709201336e9e796.tar.bz2
matterbridge-msglm-a2b45bc799de77aa278212271709201336e9e796.zip
Fix Nickserv logic (irc) #602
-rw-r--r--bridge/irc/irc.go27
1 files changed, 18 insertions, 9 deletions
diff --git a/bridge/irc/irc.go b/bridge/irc/irc.go
index 36c1cfd8..538f8829 100644
--- a/bridge/irc/irc.go
+++ b/bridge/irc/irc.go
@@ -287,7 +287,6 @@ func (b *Birc) handleNewConnection(client *girc.Client, event girc.Event) {
i := b.i
b.Nick = event.Params[0]
- i.Handlers.Add(girc.RPL_ENDOFMOTD, b.handleOtherAuth)
i.Handlers.Add("PRIVMSG", b.handlePrivMsg)
i.Handlers.Add("CTCP_ACTION", b.handlePrivMsg)
i.Handlers.Add(girc.RPL_TOPICWHOTIME, b.handleTopicWhoTime)
@@ -296,8 +295,6 @@ func (b *Birc) handleNewConnection(client *girc.Client, event girc.Event) {
i.Handlers.Add("PART", b.handleJoinPart)
i.Handlers.Add("QUIT", b.handleJoinPart)
i.Handlers.Add("KICK", b.handleJoinPart)
- // we are now fully connected
- b.connected <- struct{}{}
}
func (b *Birc) handleJoinPart(client *girc.Client, event girc.Event) {
@@ -334,8 +331,7 @@ func (b *Birc) handleJoinPart(client *girc.Client, event girc.Event) {
func (b *Birc) handleNotice(client *girc.Client, event girc.Event) {
if strings.Contains(event.String(), "This nickname is registered") && event.Source.Name == b.GetString("NickServNick") {
- b.Log.Debugf("Sending identify to nickserv %s", b.GetString("NickServNick"))
- b.i.Cmd.Message(b.GetString("NickServNick"), "IDENTIFY "+b.GetString("NickServPassword"))
+ b.handleNickServ()
} else {
b.handlePrivMsg(client, event)
}
@@ -357,10 +353,11 @@ func (b *Birc) handleOther(client *girc.Client, event girc.Event) {
}
func (b *Birc) handleOtherAuth(client *girc.Client, event girc.Event) {
- if strings.EqualFold(b.GetString("NickServNick"), "Q@CServe.quakenet.org") {
- b.Log.Debugf("Authenticating %s against %s", b.GetString("NickServUsername"), b.GetString("NickServNick"))
- b.i.Cmd.Message(b.GetString("NickServNick"), "AUTH "+b.GetString("NickServUsername")+" "+b.GetString("NickServPassword"))
- }
+ b.handleNickServ()
+ // give nickserv some slack
+ time.Sleep(time.Second * 5)
+ // we are now fully connected
+ b.connected <- struct{}{}
}
func (b *Birc) skipPrivMsg(event girc.Event) bool {
@@ -464,3 +461,15 @@ func (b *Birc) storeNames(client *girc.Client, event girc.Event) {
func (b *Birc) formatnicks(nicks []string) string {
return strings.Join(nicks, ", ") + " currently on IRC"
}
+
+func (b *Birc) handleNickServ() {
+ if !b.GetBool("UseSASL") && b.GetString("NickServNick") != "" && b.GetString("NickServPassword") != "" {
+ b.Log.Debugf("Sending identify to nickserv %s", b.GetString("NickServNick"))
+ b.i.Cmd.Message(b.GetString("NickServNick"), "IDENTIFY "+b.GetString("NickServPassword"))
+ }
+ if strings.EqualFold(b.GetString("NickServNick"), "Q@CServe.quakenet.org") {
+ b.Log.Debugf("Authenticating %s against %s", b.GetString("NickServUsername"), b.GetString("NickServNick"))
+ b.i.Cmd.Message(b.GetString("NickServNick"), "AUTH "+b.GetString("NickServUsername")+" "+b.GetString("NickServPassword"))
+ }
+
+}