@@ -61,20 +61,22 @@ def run(self):
61
61
except SystemExit :
62
62
self .bot .logger .error ('SystemExit: Shutting down.' )
63
63
self .stop ()
64
- raise
65
64
except :
66
65
self .bot .logger .error ('Other Exception: Shutting down.' )
67
66
self .stop ()
68
67
raise
69
68
70
69
if not self .bot .isTerminating :
71
- self .bot .logger .warning ('IRC connection was lost.' )
70
+ if not self .bot .isRestarting :
71
+ self .bot .logger .warning ('IRC connection was lost.' )
72
+ reconnect_attempts += 1
72
73
73
74
if time .time () - last_start > self .reset_attempt_secs :
74
75
reconnect_attempts = 0
75
76
76
- reconnect_attempts += 1
77
- restart = reconnect_attempts <= self .max_reconnects
77
+ restart = (reconnect_attempts <= self .max_reconnects ) or self .bot .isRestarting
78
+ else :
79
+ restart = False
78
80
79
81
80
82
class BotBase (object ):
@@ -147,8 +149,8 @@ def __init__(self, configfile=None, nspass=None, backupcfg=False):
147
149
for option in self .config .options ('BANLIST' ):
148
150
self .banList [option ] = set (self .config .get ('BANLIST' ,option ).lower ().split (';' ) if self .config .get ('BANLIST' ,option ).strip () else [])
149
151
150
- self .logger .info ("Users : %s" % self .authUsers )
151
- self .logger .info ("Groups : %s" % self .groups )
152
+ self .logger .info ("Users : %s" % self .authUsers )
153
+ self .logger .info ("Groups : %s" % self .groups )
152
154
self .txtcmds = {}
153
155
154
156
self .updateConfig ()
@@ -158,7 +160,8 @@ def __init__(self, configfile=None, nspass=None, backupcfg=False):
158
160
159
161
self .isIdentified = False #Turn to true when nick/ident commands are sent
160
162
self .isReady = False #Turn to true after RPL_ENDOFMOTD. Every join/nick etc commands should be sent once this is True.
161
- self .isTerminating = False #This is set to true by the stop command to bypass restarting
163
+ self .isTerminating = False #This is set to true by the stop command to bypass restarting
164
+ self .isRestarting = False
162
165
self .isRunning = False
163
166
164
167
self .socket = None
@@ -194,6 +197,7 @@ def __init__(self, configfile=None, nspass=None, backupcfg=False):
194
197
195
198
self .registerCommand ('sendraw' , self .sendRawCmd , ['admin' ], 0 , 999 , "<irccmd>" , "Send a raw IRC cmd." )
196
199
self .registerCommand ('shutdown' , self .killSelf , ['admin' ], 0 , 0 , "" , "Kills the bot." )
200
+ self .registerCommand ('restart' , self .restart , ['admin' ], 0 , 0 , '' , 'Restarts the bot.' )
197
201
198
202
self .registerCommand ('help' , self .helpcmd , ['any' ], 0 , 1 , "[<command>|*]" , "Lists available commands or help about a specific command." , allowpub = True )
199
203
@@ -255,6 +259,10 @@ def killSelf(self, bot, sender, dest, cmd, args):
255
259
self .logger .info ("Killing self." )
256
260
self .isTerminating = True
257
261
262
+ def restart (self , bot , sender , dest , cmd , args ):
263
+ self .logger .info ('Restarting...' )
264
+ self .isRestarting = True
265
+
258
266
# User handling commands
259
267
def useradd (self , bot , sender , dest , cmd , args ):
260
268
user = args [0 ].lower ()
0 commit comments