3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-11-01 09:19:23 +01:00

networks: support protocol module reloading

Closes #177.
This commit is contained in:
James Lu 2016-07-25 11:00:56 -07:00
parent fcf364f958
commit af027e2288

View File

@ -1,5 +1,5 @@
"""Networks plugin - allows you to manipulate connections to various configured networks.""" """Networks plugin - allows you to manipulate connections to various configured networks."""
import threading import importlib
from pylinkirc import utils, world, conf, classes from pylinkirc import utils, world, conf, classes
from pylinkirc.log import log from pylinkirc.log import log
@ -83,3 +83,20 @@ def remote(irc, source, args):
remoteirc.pseudoclient.identified = '' remoteirc.pseudoclient.identified = ''
irc.reply("Done.") irc.reply("Done.")
@utils.add_cmd
def reloadproto(irc, source, args):
"""<protocol module name>
Reloads the given protocol module without restart. You will have to manually disconnect and reconnect any network using the module for changes to apply."""
irc.checkAuthenticated(source)
try:
name = args[0]
except IndexError:
irc.reply('Error: Not enough arguments (needs 1: protocol module name)')
return
proto = utils.getProtocolModule(name)
importlib.reload(proto)
irc.reply("Done. You will have to manually disconnect and reconnect any network using the %r module for changes to apply." % name)