mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-23 19:22:45 +01:00
Moved the do376 joining stuff to Owner so Admin can be safely unloaded.
This commit is contained in:
parent
654ae4970a
commit
f44f5410f3
@ -661,11 +661,16 @@ def main():
|
|||||||
and tell us you're an advanced user. Some of those questions might be
|
and tell us you're an advanced user. Some of those questions might be
|
||||||
boring, but they'll really help you customize your bot :)""")
|
boring, but they'll really help you customize your bot :)""")
|
||||||
|
|
||||||
|
# Let's make sure that src/ plugins are loaded.
|
||||||
|
conf.registerPlugin('Admin', True)
|
||||||
|
conf.registerPlugin('Channel', True)
|
||||||
|
conf.registerPlugin('Config', True)
|
||||||
|
conf.registerPlugin('Misc', True)
|
||||||
|
conf.registerPlugin('User', True)
|
||||||
|
|
||||||
###
|
###
|
||||||
# Write the registry
|
# Write the registry
|
||||||
###
|
###
|
||||||
|
|
||||||
# Save the registry
|
|
||||||
if not filename:
|
if not filename:
|
||||||
filename = '%s.conf' % nick
|
filename = '%s.conf' % nick
|
||||||
registry.close(conf.supybot, filename)
|
registry.close(conf.supybot, filename)
|
||||||
|
19
src/Admin.py
19
src/Admin.py
@ -65,25 +65,6 @@ class Admin(privmsgs.CapabilityCheckingPrivmsg):
|
|||||||
self.joins = {}
|
self.joins = {}
|
||||||
self.pendingNickChanges = {}
|
self.pendingNickChanges = {}
|
||||||
|
|
||||||
def do376(self, irc, msg):
|
|
||||||
channels = ircutils.IrcSet(conf.supybot.channels())
|
|
||||||
channels |= conf.supybot.networks.get(irc.network).channels()
|
|
||||||
channels = list(channels)
|
|
||||||
if not channels:
|
|
||||||
return
|
|
||||||
utils.sortBy(lambda s: ',' not in s, channels)
|
|
||||||
keys = []
|
|
||||||
chans = []
|
|
||||||
for channel in channels:
|
|
||||||
if ',' in channel:
|
|
||||||
(channel, key) = channel.split(',', 1)
|
|
||||||
chans.append(channel)
|
|
||||||
keys.append(key)
|
|
||||||
else:
|
|
||||||
chans.append(channel)
|
|
||||||
irc.queueMsg(ircmsgs.joins(chans, keys))
|
|
||||||
do422 = do377 = do376
|
|
||||||
|
|
||||||
def do437(self, irc, msg):
|
def do437(self, irc, msg):
|
||||||
"""Nick/channel temporarily unavailable."""
|
"""Nick/channel temporarily unavailable."""
|
||||||
target = msg.args[0]
|
target = msg.args[0]
|
||||||
|
50
src/Owner.py
50
src/Owner.py
@ -53,9 +53,9 @@ import supybot.conf as conf
|
|||||||
import supybot.utils as utils
|
import supybot.utils as utils
|
||||||
import supybot.world as world
|
import supybot.world as world
|
||||||
import supybot.ircdb as ircdb
|
import supybot.ircdb as ircdb
|
||||||
import supybot.irclib as irclib
|
|
||||||
import supybot.ircmsgs as ircmsgs
|
import supybot.ircmsgs as ircmsgs
|
||||||
import supybot.drivers as drivers
|
import supybot.drivers as drivers
|
||||||
|
import supybot.ircutils as ircutils
|
||||||
import supybot.privmsgs as privmsgs
|
import supybot.privmsgs as privmsgs
|
||||||
import supybot.registry as registry
|
import supybot.registry as registry
|
||||||
import supybot.callbacks as callbacks
|
import supybot.callbacks as callbacks
|
||||||
@ -184,7 +184,8 @@ class Owner(privmsgs.CapabilityCheckingPrivmsg):
|
|||||||
# things will happen when adding callbacks.
|
# things will happen when adding callbacks.
|
||||||
priority = ~sys.maxint-1 # This must be first!
|
priority = ~sys.maxint-1 # This must be first!
|
||||||
capability = 'owner'
|
capability = 'owner'
|
||||||
_srcPlugins = ('Admin', 'Channel', 'Config', 'Misc', 'Owner', 'User')
|
_srcPlugins = ircutils.IrcSet(('Admin', 'Channel', 'Config',
|
||||||
|
'Misc', 'Owner', 'User'))
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
callbacks.Privmsg.__init__(self)
|
callbacks.Privmsg.__init__(self)
|
||||||
self.log = LogProxy(self.log)
|
self.log = LogProxy(self.log)
|
||||||
@ -215,20 +216,7 @@ class Owner(privmsgs.CapabilityCheckingPrivmsg):
|
|||||||
privmsgs.CapabilityCheckingPrivmsg.reset(self)
|
privmsgs.CapabilityCheckingPrivmsg.reset(self)
|
||||||
|
|
||||||
def do001(self, irc, msg):
|
def do001(self, irc, msg):
|
||||||
if len(irc.callbacks) < 6:
|
self.log.info('Loading plugins.')
|
||||||
self.log.info('Loading other src/ plugins.')
|
|
||||||
for s in ('Admin', 'Channel', 'Config', 'Misc', 'User'):
|
|
||||||
if irc.getCallback(s) is None:
|
|
||||||
self.log.info('Loading %s.' % s)
|
|
||||||
try:
|
|
||||||
m = loadPluginModule(s)
|
|
||||||
loadPluginClass(irc, m)
|
|
||||||
except Exception, e:
|
|
||||||
self.log.exception('Error loading %s:', s)
|
|
||||||
self.log.error('Error loading src/ plugin %s. '
|
|
||||||
'This is rather serious; these plugins '
|
|
||||||
'must always be loaded.', s)
|
|
||||||
self.log.info('Loading plugins/ plugins.')
|
|
||||||
for (name, value) in conf.supybot.plugins.getValues(fullNames=False):
|
for (name, value) in conf.supybot.plugins.getValues(fullNames=False):
|
||||||
if name.lower() == 'owner':
|
if name.lower() == 'owner':
|
||||||
continue # Just in case.
|
continue # Just in case.
|
||||||
@ -241,6 +229,13 @@ class Owner(privmsgs.CapabilityCheckingPrivmsg):
|
|||||||
loadPluginClass(irc, m)
|
loadPluginClass(irc, m)
|
||||||
except ImportError, e:
|
except ImportError, e:
|
||||||
log.warning('Failed to load %s: %s', name, e)
|
log.warning('Failed to load %s: %s', name, e)
|
||||||
|
if name in self._srcPlugins:
|
||||||
|
self.log.exception('Error loading %s:', name)
|
||||||
|
self.log.error('Error loading src/ plugin %s. '
|
||||||
|
'This is usually rather '
|
||||||
|
'serious; these plugins are '
|
||||||
|
'almost always be loaded.', s)
|
||||||
|
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
log.exception('Failed to load %s:', name)
|
log.exception('Failed to load %s:', name)
|
||||||
else:
|
else:
|
||||||
@ -306,6 +301,25 @@ class Owner(privmsgs.CapabilityCheckingPrivmsg):
|
|||||||
else:
|
else:
|
||||||
callbacks.IrcObjectProxy(irc, msg, tokens)
|
callbacks.IrcObjectProxy(irc, msg, tokens)
|
||||||
|
|
||||||
|
def do376(self, irc, msg):
|
||||||
|
channels = ircutils.IrcSet(conf.supybot.channels())
|
||||||
|
channels |= conf.supybot.networks.get(irc.network).channels()
|
||||||
|
channels = list(channels)
|
||||||
|
if not channels:
|
||||||
|
return
|
||||||
|
utils.sortBy(lambda s: ',' not in s, channels)
|
||||||
|
keys = []
|
||||||
|
chans = []
|
||||||
|
for channel in channels:
|
||||||
|
if ',' in channel:
|
||||||
|
(channel, key) = channel.split(',', 1)
|
||||||
|
chans.append(channel)
|
||||||
|
keys.append(key)
|
||||||
|
else:
|
||||||
|
chans.append(channel)
|
||||||
|
irc.queueMsg(ircmsgs.joins(chans, keys))
|
||||||
|
do422 = do377 = do376
|
||||||
|
|
||||||
def doPrivmsg(self, irc, msg):
|
def doPrivmsg(self, irc, msg):
|
||||||
callbacks.Privmsg.handled = False
|
callbacks.Privmsg.handled = False
|
||||||
callbacks.Privmsg.errored = False
|
callbacks.Privmsg.errored = False
|
||||||
@ -520,7 +534,7 @@ class Owner(privmsgs.CapabilityCheckingPrivmsg):
|
|||||||
for callback in callbacks:
|
for callback in callbacks:
|
||||||
callback.die()
|
callback.die()
|
||||||
del callback
|
del callback
|
||||||
gc.collect()
|
gc.collect() # This makes sure the callback is collected.
|
||||||
callback = loadPluginClass(irc, module)
|
callback = loadPluginClass(irc, module)
|
||||||
irc.replySuccess()
|
irc.replySuccess()
|
||||||
except ImportError:
|
except ImportError:
|
||||||
@ -539,7 +553,7 @@ class Owner(privmsgs.CapabilityCheckingPrivmsg):
|
|||||||
"""
|
"""
|
||||||
name = privmsgs.getArgs(args)
|
name = privmsgs.getArgs(args)
|
||||||
if ircutils.strEqual(name, self.name()):
|
if ircutils.strEqual(name, self.name()):
|
||||||
irc.error('You can\'t unload the %s plugin.' % self.name())
|
irc.error('You can\'t unload the %s plugin.' % name)
|
||||||
return
|
return
|
||||||
callbacks = irc.removeCallback(name)
|
callbacks = irc.removeCallback(name)
|
||||||
if callbacks:
|
if callbacks:
|
||||||
|
Loading…
Reference in New Issue
Block a user