mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-12 21:22:36 +01:00
Config: Add @searchhelp, to search in the help string of config vars and groups.
This commit is contained in:
parent
ba0738c540
commit
4f027f2cbf
@ -206,6 +206,25 @@ class Config(callbacks.Plugin):
|
||||
irc.reply(_('There were no matching configuration variables.'))
|
||||
search = wrap(search, ['lowered']) # XXX compose with withoutSpaces?
|
||||
|
||||
@internationalizeDocstring
|
||||
def searchhelp(self, irc, msg, args, phrase):
|
||||
"""<phrase>
|
||||
|
||||
Searches for <phrase> in the help of current configuration variables.
|
||||
"""
|
||||
L = []
|
||||
for (name, x) in conf.supybot.getValues(getChildren=True):
|
||||
if phrase in x.help().lower():
|
||||
last_name_part = registry.split(name)[-1]
|
||||
if not irc.isChannel(last_name_part) \
|
||||
and not last_name_part.startswith(':'): # network
|
||||
L.append(name)
|
||||
if L:
|
||||
irc.reply(format('%L', L))
|
||||
else:
|
||||
irc.reply(_('There were no matching configuration variables.'))
|
||||
searchhelp = wrap(searchhelp, ['lowered'])
|
||||
|
||||
@internationalizeDocstring
|
||||
def searchvalues(self, irc, msg, args, word):
|
||||
"""<word>
|
||||
|
@ -88,6 +88,14 @@ class ConfigTestCase(ChannelPluginTestCase):
|
||||
self.assertNotError('config channel reply.whenAddressedBy.chars @')
|
||||
self.assertNotRegexp('config search chars', self.channel)
|
||||
|
||||
def testSearchHelp(self):
|
||||
self.assertRegexp(
|
||||
'config searchhelp "what prefix characters"',
|
||||
'supybot.reply.whenAddressedBy.chars')
|
||||
self.assertNotError('config channel reply.whenAddressedBy.chars @')
|
||||
self.assertNotRegexp(
|
||||
'config searchhelp "what prefix characters"', self.channel)
|
||||
|
||||
def testSearchValues(self):
|
||||
self.assertResponse(
|
||||
'config searchvalues @@@',
|
||||
|
Loading…
Reference in New Issue
Block a user