Actually fix restarting on excess flood
This commit is contained in:
parent
3649c82174
commit
130a859458
@ -516,6 +516,18 @@ def forced_exit(cli, nick, chan, rest):
|
|||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
|
|
||||||
|
def _restart_program(cli, mode=None):
|
||||||
|
plog("RESTARTING")
|
||||||
|
|
||||||
|
python = sys.executable
|
||||||
|
|
||||||
|
if mode:
|
||||||
|
assert mode in ("normal", "verbose", "debug")
|
||||||
|
os.execl(python, python, sys.argv[0], "--{0}".format(mode))
|
||||||
|
else:
|
||||||
|
os.execl(python, python, *sys.argv)
|
||||||
|
|
||||||
|
|
||||||
@cmd("frestart", admin_only=True, pm=True)
|
@cmd("frestart", admin_only=True, pm=True)
|
||||||
def restart_program(cli, nick, chan, rest):
|
def restart_program(cli, nick, chan, rest):
|
||||||
"""Restarts the bot."""
|
"""Restarts the bot."""
|
||||||
@ -588,14 +600,7 @@ def restart_program(cli, nick, chan, rest):
|
|||||||
# restart the bot once our quit message goes though to ensure entire IRC queue is sent
|
# restart the bot once our quit message goes though to ensure entire IRC queue is sent
|
||||||
# if the bot is using a nick that isn't botconfig.NICK, then stop breaking things and fdie
|
# if the bot is using a nick that isn't botconfig.NICK, then stop breaking things and fdie
|
||||||
if nick == botconfig.NICK:
|
if nick == botconfig.NICK:
|
||||||
plog("RESTARTING")
|
_restart_program(cli, mode)
|
||||||
|
|
||||||
python = sys.executable
|
|
||||||
|
|
||||||
if mode:
|
|
||||||
os.execl(python, python, sys.argv[0], "--{0}".format(mode))
|
|
||||||
else:
|
|
||||||
os.execl(python, python, *sys.argv)
|
|
||||||
|
|
||||||
|
|
||||||
@cmd("ping", chan=False, pm=True)
|
@cmd("ping", chan=False, pm=True)
|
||||||
@ -6213,7 +6218,7 @@ def start(cli, nick, chan, forced = False, restart = ""):
|
|||||||
@hook("error")
|
@hook("error")
|
||||||
def on_error(cli, pfx, msg):
|
def on_error(cli, pfx, msg):
|
||||||
if msg.endswith("(Excess Flood)"):
|
if msg.endswith("(Excess Flood)"):
|
||||||
restart_program.func(cli, "<console>", botconfig.CHANNEL, "")
|
_restart_program(cli)
|
||||||
elif msg.startswith("Closing Link:"):
|
elif msg.startswith("Closing Link:"):
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user