Removed the ability to make regexp-based plugins.

This commit is contained in:
Jeremy Fincher 2005-02-09 18:28:21 +00:00
parent 88746764dd
commit a6973f681c

View File

@ -91,9 +91,9 @@ import supybot.ircutils as ircutils
import supybot.callbacks as callbacks
class %s(%s):
"""Add the help for "@help %s" here (assuming you don\'t implement a %s
command). This should describe *how* to use this plugin."""
class %s(Plugin):
"""Add the help for "@plugin help %s" here
This should describe *how* to use this plugin."""
%s
@ -186,8 +186,6 @@ def main():
global copyright
parser = optparse.OptionParser(usage='Usage: %prog [options]',
version='Supybot %s' % conf.version)
parser.add_option('-r', '--regexp', action='store_true', dest='regexp',
help='uses a regexp-based callback.')
parser.add_option('-n', '--name', action='store', dest='name',
help='sets the name for the plugin.')
parser.add_option('-t', '--thread', action='store_true', dest='threaded',
@ -198,10 +196,6 @@ def main():
(options, args) = parser.parse_args()
if options.name:
name = options.name
if options.regexp:
kind = 'regexp'
else:
kind = 'command'
if options.threaded:
threaded = True
else:
@ -213,7 +207,7 @@ def main():
if name.endswith('.py'):
name = name[:-3]
while name[0].islower():
print 'Plugin names must begin with a capital.'
print 'Plugin names must begin with a capital letter.'
name = something('What should the name of the plugin be?')
if name.endswith('.py'):
name = name[:-3]
@ -221,26 +215,6 @@ def main():
if os.path.exists(name):
error('A file or directory named %s already exists; remove or '
'rename it and run this program again.' % name)
print textwrap.dedent("""
Supybot offers two major types of plugins: command-based and
regexp-based. Command-based plugins are the kind of plugins
you've seen most when you've used supybot. They're also the most
featureful and easiest to write. Commands can be nested, for
instance, whereas regexp-based callbacks can't do nesting.
That doesn't mean that you'll never want regexp-based callbacks.
They offer a flexibility that command-based callbacks don't
offer; however, they don't tie into the whole system as well.
If you need to combine a command-based callback with some
regexp-based methods, you can do so by subclassing
callbacks.PrivmsgCommandAndRegexp and then adding a class-level
attribute "regexps" that is a sets.Set of methods that are
regexp-based. But you'll have to do that yourself after this
wizard is finished.)""").strip()
print
kind = expect('Do you want a command-based plugin' \
' or a regexp-based plugin?', ['command', 'regexp'])
print textwrap.fill(textwrap.dedent("""
Sometimes you'll want a callback to be threaded. If its methods
@ -259,10 +233,6 @@ def main():
threaded = 'threaded = True'
else:
threaded = 'pass'
if kind == 'command':
className = 'callbacks.Plugin'
else:
className = 'callbacks.PluginRegexp'
if name.endswith('.py'):
name = name[:-3]
while name[0].islower():
@ -282,8 +252,8 @@ def main():
finally:
fd.close()
writeFile('plugin.py', pluginTemplate % (copyright, name, className,
name, name, threaded, name))
writeFile('plugin.py', pluginTemplate % (copyright, name,
name, threaded, name))
writeFile('config.py', configTemplate % (copyright, name, name, name, name))
writeFile('__init__.py', __init__Template % copyright)
writeFile('test.py', testTemplate % (copyright, name, name))