Fix getCommandHelp's use of dynamic.msg

Default chan to None so we can still retrieve a config value if dynamic.msg
isn't valid (e.g., when running supybot-plugin-doc).

Signed-off-by: James Vega <jamessan@users.sourceforge.net>
This commit is contained in:
James Vega 2009-04-28 08:03:21 -04:00
parent cedc4aaebe
commit 0615846ab3
2 changed files with 10 additions and 7 deletions

View File

@ -107,10 +107,12 @@ class Factoids(callbacks.Plugin, plugins.ChannelDBHandler):
def getCommandHelp(self, command): def getCommandHelp(self, command):
method = self.getCommandMethod(command) method = self.getCommandMethod(command)
if method.im_func.func_name == 'learn': if method.im_func.func_name == 'learn':
s = self.registryValue('learnSeparator', dynamic.msg.args[0]) chan = None
if dynamic.msg is not None:
chan = dynamic.msg.args[0]
s = self.registryValue('learnSeparator', chan)
help = callbacks.getHelp help = callbacks.getHelp
if conf.get(conf.supybot.reply.showSimpleSyntax, if conf.get(conf.supybot.reply.showSimpleSyntax, chan):
dynamic.msg.args[0]):
help = callbacks.getSyntax help = callbacks.getSyntax
return help(method, return help(method,
doc=method._fake__doc__ % (s, s), doc=method._fake__doc__ % (s, s),

View File

@ -1200,10 +1200,11 @@ class Commands(BasePlugin):
def getCommandHelp(self, command): def getCommandHelp(self, command):
method = self.getCommandMethod(command) method = self.getCommandMethod(command)
help = getHelp help = getHelp
m = dynamic.msg chan = None
if m is not None: if dynamic.msg is not None:
if conf.get(conf.supybot.reply.showSimpleSyntax, m.args[0]): chan = dynamic.msg.args[0]
help = getSyntax if conf.get(conf.supybot.reply.showSimpleSyntax, chan):
help = getSyntax
if hasattr(method, '__doc__'): if hasattr(method, '__doc__'):
return help(method, name=formatCommand(command)) return help(method, name=formatCommand(command))
else: else: