From f2d3e99346f33d14139d58648ff19acea29f17d3 Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Sat, 8 Nov 2003 08:12:25 +0000 Subject: [PATCH] Converted to Configurable. --- plugins/Python.py | 16 +++++++++------- test/test_Python.py | 7 ------- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/plugins/Python.py b/plugins/Python.py index b0ceb5854..5f80c5908 100644 --- a/plugins/Python.py +++ b/plugins/Python.py @@ -70,15 +70,16 @@ def configure(onStart, afterConnect, advanced): from questions import expect, anything, something, yn onStart.append('load Python') -class Python(callbacks.PrivmsgCommandAndRegexp, plugins.Toggleable): +class Python(callbacks.PrivmsgCommandAndRegexp, plugins.Configurable): modulechars = '%s%s%s' % (string.ascii_letters, string.digits, '_.') threaded = True regexps = ['aspnRecipes'] - toggles = plugins.ToggleDictionary({'ASPN' : True}) - - def __init__(self): - callbacks.PrivmsgCommandAndRegexp.__init__(self) - plugins.Toggleable.__init__(self) + configurables = plugins.ConfigurableDictionary( + [('aspn-snarfer', plugins.ConfigurableTypes.bool, True, + """Determines whether the ASPN Python recipe snarfer is enabled. If + so, it will message the channel with the name of the recipe when it + sees an ASPN Python recipe link on the channel.""")] + ) def pydoc(self, irc, msg, args): """ @@ -174,7 +175,7 @@ class Python(callbacks.PrivmsgCommandAndRegexp, plugins.Toggleable): _bold = lambda self, g: (ircutils.bold(g[0]),) + g[1:] def aspnRecipes(self, irc, msg, match): r"http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/\d+" - if not self.toggles.get('ASPN', channel=msg.args[0]): + if not self.configurables.get('aspn-snarfer', channel=msg.args[0]): return url = match.group(0) fd = urllib2.urlopen(url) @@ -188,6 +189,7 @@ class Python(callbacks.PrivmsgCommandAndRegexp, plugins.Toggleable): if resp: #debug.printf('; '.join(resp)) irc.reply(msg, '; '.join(resp), prefixName = False) + aspnRecipes = privmsgs.urlSnarfer(aspnRecipes) Class = Python diff --git a/test/test_Python.py b/test/test_Python.py index f2a533deb..013dcc659 100644 --- a/test/test_Python.py +++ b/test/test_Python.py @@ -59,13 +59,6 @@ class PythonTestCase(PluginTestCase, PluginDocumentation): def testAspnRecipes(self): self.assertRegexp('http://aspn.activestate.com/ASPN/Cookbook/Python/'\ 'Recipe/230113', 'Implementation of sets using sorted lists') - - def testToggle(self): - self.assertHelp('python toggle') - self.assertRegexp('python toggle aspn', '\(aspn: (?:Off|On)\)') - self.assertRegexp('python toggle aspn off', '\(aspn: Off\)') - self.assertRegexp('python toggle aspn off', '\(aspn: Off\)') - self.assertRegexp('python toggle aspn on', '\(aspn: On\)') # vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: