mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-23 11:09:23 +01:00
Moving action,reply,private,notice to new Reply plugin (for real)
This commit is contained in:
parent
739c9ceda7
commit
c998dfbebf
@ -441,36 +441,6 @@ class Misc(callbacks.Privmsg):
|
|||||||
irc.reply(s, to=target, private=True)
|
irc.reply(s, to=target, private=True)
|
||||||
tell = wrap(tell, ['something', 'text'])
|
tell = wrap(tell, ['something', 'text'])
|
||||||
|
|
||||||
def private(self, irc, msg, args, text):
|
|
||||||
"""<text>
|
|
||||||
|
|
||||||
Replies with <text> in private. Use nested commands to your benefit
|
|
||||||
here.
|
|
||||||
"""
|
|
||||||
irc.reply(text, private=True)
|
|
||||||
private = wrap(private, ['text'])
|
|
||||||
|
|
||||||
def action(self, irc, msg, args, text):
|
|
||||||
"""<text>
|
|
||||||
|
|
||||||
Replies with <text> as an action. use nested commands to your benefit
|
|
||||||
here.
|
|
||||||
"""
|
|
||||||
if text:
|
|
||||||
irc.reply(text, action=True)
|
|
||||||
else:
|
|
||||||
raise callbacks.ArgumentError
|
|
||||||
action = wrap(action, ['text'])
|
|
||||||
|
|
||||||
def notice(self, irc, msg, args, text):
|
|
||||||
"""<text>
|
|
||||||
|
|
||||||
Replies with <text> in a notice. Use nested commands to your benefit
|
|
||||||
here. If you want a private notice, nest the private command.
|
|
||||||
"""
|
|
||||||
irc.reply(text, notice=True)
|
|
||||||
notice = wrap(notice, ['text'])
|
|
||||||
|
|
||||||
def contributors(self, irc, msg, args, cb, nick):
|
def contributors(self, irc, msg, args, cb, nick):
|
||||||
"""<plugin> [<nick>]
|
"""<plugin> [<nick>]
|
||||||
|
|
||||||
|
@ -32,13 +32,6 @@ from supybot.test import *
|
|||||||
class MiscTestCase(ChannelPluginTestCase):
|
class MiscTestCase(ChannelPluginTestCase):
|
||||||
# plugins = ('Misc', 'Utilities', 'Gameknot', 'Anonymous', 'Dict', 'User')
|
# plugins = ('Misc', 'Utilities', 'Gameknot', 'Anonymous', 'Dict', 'User')
|
||||||
plugins = ('Misc', 'Utilities', 'Anonymous', 'Dict', 'User')
|
plugins = ('Misc', 'Utilities', 'Anonymous', 'Dict', 'User')
|
||||||
def testAction(self):
|
|
||||||
self.assertAction('action moos', 'moos')
|
|
||||||
|
|
||||||
def testActionDoesNotAllowEmptyString(self):
|
|
||||||
self.assertHelp('action')
|
|
||||||
self.assertHelp('action ""')
|
|
||||||
|
|
||||||
def testReplyWhenNotCommand(self):
|
def testReplyWhenNotCommand(self):
|
||||||
try:
|
try:
|
||||||
original = str(conf.supybot.reply.whenNotCommand)
|
original = str(conf.supybot.reply.whenNotCommand)
|
||||||
@ -227,22 +220,6 @@ class MiscTestCase(ChannelPluginTestCase):
|
|||||||
self.assertNotError('more %s' % nick.upper())
|
self.assertNotError('more %s' % nick.upper())
|
||||||
self.assertNotError('more %s' % nick.lower())
|
self.assertNotError('more %s' % nick.lower())
|
||||||
|
|
||||||
def testPrivate(self):
|
|
||||||
m = self.getMsg('private [list]')
|
|
||||||
self.failIf(ircutils.isChannel(m.args[0]))
|
|
||||||
|
|
||||||
def testNotice(self):
|
|
||||||
m = self.getMsg('notice [list]')
|
|
||||||
self.assertEqual(m.command, 'NOTICE')
|
|
||||||
|
|
||||||
def testNoticePrivate(self):
|
|
||||||
m = self.assertNotError('notice [private [list]]')
|
|
||||||
self.assertEqual(m.command, 'NOTICE')
|
|
||||||
self.assertEqual(m.args[0], self.nick)
|
|
||||||
m = self.assertNotError('private [notice [list]]')
|
|
||||||
self.assertEqual(m.command, 'NOTICE')
|
|
||||||
self.assertEqual(m.args[0], self.nick)
|
|
||||||
|
|
||||||
def testHostmask(self):
|
def testHostmask(self):
|
||||||
self.assertResponse('hostmask', self.prefix)
|
self.assertResponse('hostmask', self.prefix)
|
||||||
self.assertError('@hostmask asdf')
|
self.assertError('@hostmask asdf')
|
||||||
@ -273,14 +250,5 @@ class MiscTestCase(ChannelPluginTestCase):
|
|||||||
def testRevisionIsCaseInsensitive(self):
|
def testRevisionIsCaseInsensitive(self):
|
||||||
self.assertNotError('revision misc')
|
self.assertNotError('revision misc')
|
||||||
|
|
||||||
|
|
||||||
class MiscNonChannelTestCase(PluginTestCase):
|
|
||||||
plugins = ('Misc',)
|
|
||||||
def testAction(self):
|
|
||||||
self.prefix = 'something!else@somewhere.else'
|
|
||||||
self.nick = 'something'
|
|
||||||
m = self.assertAction('action foo', 'foo')
|
|
||||||
self.failIf(m.args[0] == self.irc.nick)
|
|
||||||
|
|
||||||
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
||||||
|
|
||||||
|
1
plugins/Reply/README.txt
Normal file
1
plugins/Reply/README.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
Insert a description of your plugin here, with any notes, etc. about using it.
|
62
plugins/Reply/__init__.py
Normal file
62
plugins/Reply/__init__.py
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
###
|
||||||
|
# Copyright (c) 2005, Daniel DiPaolo
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice,
|
||||||
|
# this list of conditions, and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
# this list of conditions, and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
# * Neither the name of the author of this software nor the name of
|
||||||
|
# contributors to this software may be used to endorse or promote products
|
||||||
|
# derived from this software without specific prior written consent.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||||
|
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
# POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
###
|
||||||
|
|
||||||
|
"""
|
||||||
|
This plugin contains various commands which elicit certain types of responses
|
||||||
|
from the bot.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import supybot
|
||||||
|
import supybot.world as world
|
||||||
|
|
||||||
|
# Use this for the version of this plugin. You may wish to put a CVS keyword
|
||||||
|
# in here if you're keeping the plugin in CVS or some similar system.
|
||||||
|
__version__ = "%%VERSION%%"
|
||||||
|
|
||||||
|
# XXX Replace this with an appropriate author or supybot.Author instance.
|
||||||
|
__author__ = supybot.authors.strike
|
||||||
|
|
||||||
|
# This is a dictionary mapping supybot.Author instances to lists of
|
||||||
|
# contributions.
|
||||||
|
__contributors__ = {}
|
||||||
|
|
||||||
|
import config
|
||||||
|
import plugin
|
||||||
|
reload(plugin) # In case we're being reloaded.
|
||||||
|
# Add more reloads here if you add third-party modules and want them to be
|
||||||
|
# reloaded when this plugin is reloaded. Don't forget to import them as well!
|
||||||
|
|
||||||
|
if world.testing:
|
||||||
|
import test
|
||||||
|
|
||||||
|
Class = plugin.Class
|
||||||
|
configure = config.configure
|
||||||
|
|
||||||
|
|
||||||
|
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
48
plugins/Reply/config.py
Normal file
48
plugins/Reply/config.py
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
###
|
||||||
|
# Copyright (c) 2005, Daniel DiPaolo
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice,
|
||||||
|
# this list of conditions, and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
# this list of conditions, and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
# * Neither the name of the author of this software nor the name of
|
||||||
|
# contributors to this software may be used to endorse or promote products
|
||||||
|
# derived from this software without specific prior written consent.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||||
|
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
# POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
###
|
||||||
|
|
||||||
|
import supybot.conf as conf
|
||||||
|
import supybot.registry as registry
|
||||||
|
|
||||||
|
def configure(advanced):
|
||||||
|
# This will be called by supybot to configure this module. advanced is
|
||||||
|
# a bool that specifies whether the user identified himself as an advanced
|
||||||
|
# user or not. You should effect your configuration by manipulating the
|
||||||
|
# registry as appropriate.
|
||||||
|
from supybot.questions import expect, anything, something, yn
|
||||||
|
conf.registerPlugin('Reply', True)
|
||||||
|
|
||||||
|
|
||||||
|
Reply = conf.registerPlugin('Reply')
|
||||||
|
# This is where your configuration variables (if any) should go. For example:
|
||||||
|
# conf.registerGlobalValue(Reply, 'someConfigVariableName',
|
||||||
|
# registry.Boolean(False, """Help for someConfigVariableName."""))
|
||||||
|
|
||||||
|
|
||||||
|
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78
|
80
plugins/Reply/plugin.py
Normal file
80
plugins/Reply/plugin.py
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
###
|
||||||
|
# Copyright (c) 2005, Daniel DiPaolo
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice,
|
||||||
|
# this list of conditions, and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
# this list of conditions, and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
# * Neither the name of the author of this software nor the name of
|
||||||
|
# contributors to this software may be used to endorse or promote products
|
||||||
|
# derived from this software without specific prior written consent.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||||
|
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
# POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
###
|
||||||
|
|
||||||
|
from supybot.commands import *
|
||||||
|
import supybot.callbacks as callbacks
|
||||||
|
|
||||||
|
|
||||||
|
class Reply(callbacks.Privmsg):
|
||||||
|
"""This plugins contains a few commands that construct various types of
|
||||||
|
replies. Some bot owners would be wise to not load this plugin because it
|
||||||
|
can be easily abused.
|
||||||
|
"""
|
||||||
|
def private(self, irc, msg, args, text):
|
||||||
|
"""<text>
|
||||||
|
|
||||||
|
Replies with <text> in private. Use nested commands to your benefit
|
||||||
|
here.
|
||||||
|
"""
|
||||||
|
irc.reply(text, private=True)
|
||||||
|
private = wrap(private, ['text'])
|
||||||
|
|
||||||
|
def action(self, irc, msg, args, text):
|
||||||
|
"""<text>
|
||||||
|
|
||||||
|
Replies with <text> as an action. use nested commands to your benefit
|
||||||
|
here.
|
||||||
|
"""
|
||||||
|
if text:
|
||||||
|
irc.reply(text, action=True)
|
||||||
|
else:
|
||||||
|
raise callbacks.ArgumentError
|
||||||
|
action = wrap(action, ['text'])
|
||||||
|
|
||||||
|
def notice(self, irc, msg, args, text):
|
||||||
|
"""<text>
|
||||||
|
|
||||||
|
Replies with <text> in a notice. Use nested commands to your benefit
|
||||||
|
here. If you want a private notice, nest the private command.
|
||||||
|
"""
|
||||||
|
irc.reply(text, notice=True)
|
||||||
|
notice = wrap(notice, ['text'])
|
||||||
|
|
||||||
|
def reply(self, irc, msg, args, text):
|
||||||
|
"""<text>
|
||||||
|
|
||||||
|
Replies with <text>. Equivalent to the alias, 'echo $nick: $1'.
|
||||||
|
"""
|
||||||
|
irc.reply(text, prefixName=True)
|
||||||
|
reply = wrap(reply, ['text'])
|
||||||
|
|
||||||
|
Class = Reply
|
||||||
|
|
||||||
|
|
||||||
|
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
59
plugins/Reply/test.py
Normal file
59
plugins/Reply/test.py
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
###
|
||||||
|
# Copyright (c) 2005, Daniel DiPaolo
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice,
|
||||||
|
# this list of conditions, and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
# this list of conditions, and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
# * Neither the name of the author of this software nor the name of
|
||||||
|
# contributors to this software may be used to endorse or promote products
|
||||||
|
# derived from this software without specific prior written consent.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||||
|
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
# POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
###
|
||||||
|
|
||||||
|
from supybot.test import *
|
||||||
|
import supybot.ircutils as ircutils
|
||||||
|
|
||||||
|
class ReplyTestCase(ChannelPluginTestCase):
|
||||||
|
plugins = ('Reply',)
|
||||||
|
def testPrivate(self):
|
||||||
|
m = self.getMsg('private [list]')
|
||||||
|
self.failIf(ircutils.isChannel(m.args[0]))
|
||||||
|
|
||||||
|
def testNotice(self):
|
||||||
|
m = self.getMsg('notice [list]')
|
||||||
|
self.assertEqual(m.command, 'NOTICE')
|
||||||
|
|
||||||
|
def testNoticePrivate(self):
|
||||||
|
m = self.assertNotError('notice [private [list]]')
|
||||||
|
self.assertEqual(m.command, 'NOTICE')
|
||||||
|
self.assertEqual(m.args[0], self.nick)
|
||||||
|
m = self.assertNotError('private [notice [list]]')
|
||||||
|
self.assertEqual(m.command, 'NOTICE')
|
||||||
|
self.assertEqual(m.args[0], self.nick)
|
||||||
|
|
||||||
|
class ReplyNonChannelTestCase(PluginTestCase):
|
||||||
|
plugins = ('Reply',)
|
||||||
|
def testAction(self):
|
||||||
|
self.prefix = 'something!else@somewhere.else'
|
||||||
|
self.nick = 'something'
|
||||||
|
m = self.assertAction('action foo', 'foo')
|
||||||
|
self.failIf(m.args[0] == self.irc.nick)
|
||||||
|
|
||||||
|
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
@ -46,14 +46,6 @@ class Utilities(callbacks.Privmsg):
|
|||||||
pass
|
pass
|
||||||
# Do be careful not to wrap this unless you do any('something').
|
# Do be careful not to wrap this unless you do any('something').
|
||||||
|
|
||||||
def reply(self, irc, msg, args, text):
|
|
||||||
"""<text>
|
|
||||||
|
|
||||||
Replies with <text>. Equivalent to the alias, 'echo $nick: $1'.
|
|
||||||
"""
|
|
||||||
irc.reply(text, prefixName=True)
|
|
||||||
reply = wrap(reply, ['text'])
|
|
||||||
|
|
||||||
def success(self, irc, msg, args, text):
|
def success(self, irc, msg, args, text):
|
||||||
"""[<text>]
|
"""[<text>]
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user