Fix Nickserv logic (irc) #602

This commit is contained in:
Wim 2018-11-22 22:46:38 +01:00
parent 757657f29c
commit a2b45bc799

View File

@ -287,7 +287,6 @@ func (b *Birc) handleNewConnection(client *girc.Client, event girc.Event) {
i := b.i i := b.i
b.Nick = event.Params[0] b.Nick = event.Params[0]
i.Handlers.Add(girc.RPL_ENDOFMOTD, b.handleOtherAuth)
i.Handlers.Add("PRIVMSG", b.handlePrivMsg) i.Handlers.Add("PRIVMSG", b.handlePrivMsg)
i.Handlers.Add("CTCP_ACTION", b.handlePrivMsg) i.Handlers.Add("CTCP_ACTION", b.handlePrivMsg)
i.Handlers.Add(girc.RPL_TOPICWHOTIME, b.handleTopicWhoTime) 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("PART", b.handleJoinPart)
i.Handlers.Add("QUIT", b.handleJoinPart) i.Handlers.Add("QUIT", b.handleJoinPart)
i.Handlers.Add("KICK", 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) { 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) { 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") { 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.handleNickServ()
b.i.Cmd.Message(b.GetString("NickServNick"), "IDENTIFY "+b.GetString("NickServPassword"))
} else { } else {
b.handlePrivMsg(client, event) 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) { func (b *Birc) handleOtherAuth(client *girc.Client, event girc.Event) {
if strings.EqualFold(b.GetString("NickServNick"), "Q@CServe.quakenet.org") { b.handleNickServ()
b.Log.Debugf("Authenticating %s against %s", b.GetString("NickServUsername"), b.GetString("NickServNick")) // give nickserv some slack
b.i.Cmd.Message(b.GetString("NickServNick"), "AUTH "+b.GetString("NickServUsername")+" "+b.GetString("NickServPassword")) time.Sleep(time.Second * 5)
} // we are now fully connected
b.connected <- struct{}{}
} }
func (b *Birc) skipPrivMsg(event girc.Event) bool { 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 { func (b *Birc) formatnicks(nicks []string) string {
return strings.Join(nicks, ", ") + " currently on IRC" 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"))
}
}