mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-05 09:42:33 +01:00
Removed the ability to make regexp-based plugins.
This commit is contained in:
parent
88746764dd
commit
a6973f681c
@ -91,9 +91,9 @@ import supybot.ircutils as ircutils
|
|||||||
import supybot.callbacks as callbacks
|
import supybot.callbacks as callbacks
|
||||||
|
|
||||||
|
|
||||||
class %s(%s):
|
class %s(Plugin):
|
||||||
"""Add the help for "@help %s" here (assuming you don\'t implement a %s
|
"""Add the help for "@plugin help %s" here
|
||||||
command). This should describe *how* to use this plugin."""
|
This should describe *how* to use this plugin."""
|
||||||
%s
|
%s
|
||||||
|
|
||||||
|
|
||||||
@ -186,8 +186,6 @@ def main():
|
|||||||
global copyright
|
global copyright
|
||||||
parser = optparse.OptionParser(usage='Usage: %prog [options]',
|
parser = optparse.OptionParser(usage='Usage: %prog [options]',
|
||||||
version='Supybot %s' % conf.version)
|
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',
|
parser.add_option('-n', '--name', action='store', dest='name',
|
||||||
help='sets the name for the plugin.')
|
help='sets the name for the plugin.')
|
||||||
parser.add_option('-t', '--thread', action='store_true', dest='threaded',
|
parser.add_option('-t', '--thread', action='store_true', dest='threaded',
|
||||||
@ -198,10 +196,6 @@ def main():
|
|||||||
(options, args) = parser.parse_args()
|
(options, args) = parser.parse_args()
|
||||||
if options.name:
|
if options.name:
|
||||||
name = options.name
|
name = options.name
|
||||||
if options.regexp:
|
|
||||||
kind = 'regexp'
|
|
||||||
else:
|
|
||||||
kind = 'command'
|
|
||||||
if options.threaded:
|
if options.threaded:
|
||||||
threaded = True
|
threaded = True
|
||||||
else:
|
else:
|
||||||
@ -213,7 +207,7 @@ def main():
|
|||||||
if name.endswith('.py'):
|
if name.endswith('.py'):
|
||||||
name = name[:-3]
|
name = name[:-3]
|
||||||
while name[0].islower():
|
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?')
|
name = something('What should the name of the plugin be?')
|
||||||
if name.endswith('.py'):
|
if name.endswith('.py'):
|
||||||
name = name[:-3]
|
name = name[:-3]
|
||||||
@ -221,26 +215,6 @@ def main():
|
|||||||
if os.path.exists(name):
|
if os.path.exists(name):
|
||||||
error('A file or directory named %s already exists; remove or '
|
error('A file or directory named %s already exists; remove or '
|
||||||
'rename it and run this program again.' % name)
|
'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("""
|
print textwrap.fill(textwrap.dedent("""
|
||||||
Sometimes you'll want a callback to be threaded. If its methods
|
Sometimes you'll want a callback to be threaded. If its methods
|
||||||
@ -259,10 +233,6 @@ def main():
|
|||||||
threaded = 'threaded = True'
|
threaded = 'threaded = True'
|
||||||
else:
|
else:
|
||||||
threaded = 'pass'
|
threaded = 'pass'
|
||||||
if kind == 'command':
|
|
||||||
className = 'callbacks.Plugin'
|
|
||||||
else:
|
|
||||||
className = 'callbacks.PluginRegexp'
|
|
||||||
if name.endswith('.py'):
|
if name.endswith('.py'):
|
||||||
name = name[:-3]
|
name = name[:-3]
|
||||||
while name[0].islower():
|
while name[0].islower():
|
||||||
@ -282,8 +252,8 @@ def main():
|
|||||||
finally:
|
finally:
|
||||||
fd.close()
|
fd.close()
|
||||||
|
|
||||||
writeFile('plugin.py', pluginTemplate % (copyright, name, className,
|
writeFile('plugin.py', pluginTemplate % (copyright, name,
|
||||||
name, name, threaded, name))
|
name, threaded, name))
|
||||||
writeFile('config.py', configTemplate % (copyright, name, name, name, name))
|
writeFile('config.py', configTemplate % (copyright, name, name, name, name))
|
||||||
writeFile('__init__.py', __init__Template % copyright)
|
writeFile('__init__.py', __init__Template % copyright)
|
||||||
writeFile('test.py', testTemplate % (copyright, name, name))
|
writeFile('test.py', testTemplate % (copyright, name, name))
|
||||||
|
Loading…
Reference in New Issue
Block a user