From 1d20f5afd511b45f165f268346ee8e4bc598556b Mon Sep 17 00:00:00 2001 From: James Lu Date: Fri, 23 Feb 2018 18:55:50 -0500 Subject: [PATCH] OperUp: unset _oper_tried_oper on disconnect Closes #67. --- OperUp/plugin.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/OperUp/plugin.py b/OperUp/plugin.py index 3ca0eb3..35bb8a3 100644 --- a/OperUp/plugin.py +++ b/OperUp/plugin.py @@ -1,5 +1,5 @@ ### -# Copyright (c) 2014, James Lu (GLolol) +# Copyright (c) 2014,2018 James Lu # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -55,7 +55,7 @@ class OperUp(callbacks.Plugin): # Don't try to oper more than once per network: otherwise we can hit # infinite loops if OPERMOTDs also use the regular MOTD numerics # (e.g. InspIRCd) - if hasattr(irc.state, '_operup_tried_oper'): + if hasattr(irc.state, '_operup_tried_oper') and irc.state._operup_tried_oper: return if irc.network in self.registryValue('operNets'): if self.registryValue("operName") and \ @@ -70,6 +70,23 @@ class OperUp(callbacks.Plugin): do422 = do376 + # Unset irc.state_operup_tried_oper on disconnection. + def doError(self, irc, msg): + irc.state._operup_tried_oper = False + + def doQuit(self, irc, msg): + if ircutils.strEqual(msg.nick, irc.nick): + irc.state._operup_tried_oper = False + + def outFilter(self, irc, msg): + try: + if msg.command == 'QUIT' and ircutils.strEqual(msg.nick, irc.nick): + irc.state._operup_tried_oper = False + except: + self.log.exception('OperUp: caught error from outFilter on %s', irc.name) + finally: + return msg + def do381(self, irc, msg): self.log.info("OperUp: Received 381 (successfully opered up) from " "network %s.", irc.network)