3
0
mirror of https://github.com/jlu5/PyLink.git synced 2025-01-24 19:24:13 +01:00

relay: remove our persistent channels on unload

This commit is contained in:
James Lu 2018-05-30 12:43:59 -07:00
parent 5ac283f018
commit 08a7b5c837

View File

@ -13,6 +13,7 @@ from pylinkirc.coremods import permissions
TCONDITION_TIMEOUT = 2
CHANNEL_DELINKED_PARTMSG = 'Channel delinked.'
RELAY_UNLOADED_MSG = "Relay plugin unloaded."
### GLOBAL (statekeeping) VARIABLES
relayusers = defaultdict(dict)
@ -84,7 +85,7 @@ def die(irc=None):
# 1) SQUIT every relay subserver.
for server, sobj in ircobj.servers.copy().items():
if hasattr(sobj, 'remote'):
ircobj.squit(ircobj.sid, server, text="Relay plugin unloaded.")
ircobj.squit(ircobj.sid, server, text=RELAY_UNLOADED_MSG)
# 2) Clear our internal servers and users caches.
relayservers.clear()
@ -93,9 +94,16 @@ def die(irc=None):
# 3) Unload our permissions.
permissions.remove_default_permissions(default_permissions)
# 4) Save the database and quit.
# 4) Save the database.
datastore.die()
# 5) Clear all persistent channels set up by relay.
try:
world.services['pylink'].clear_persistent_channels(None, 'relay',
part_reason=RELAY_UNLOADED_MSG)
except KeyError:
log.debug('relay.die: failed to clear persistent channels:', exc_info=True)
allowed_chars = string.digits + string.ascii_letters + '/^|\\-_[]{}`'
fallback_separator = '|'
def normalize_nick(irc, netname, nick, times_tagged=0, uid=''):