mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-11 04:32:36 +01:00
Misc: Add supybot.plugins.Misc.mores.
This commit is contained in:
parent
61eb0fd3f8
commit
7a71ecb9f9
@ -41,6 +41,9 @@ def configure(advanced):
|
||||
conf.registerPlugin('Misc', True)
|
||||
|
||||
Misc = conf.registerPlugin('Misc')
|
||||
conf.registerChannelValue(Misc, 'mores',
|
||||
registry.PositiveInteger(1, _("""Determines how many messages the bot
|
||||
will issue when using the 'more' command.""")))
|
||||
conf.registerGlobalValue(Misc, 'listPrivatePlugins',
|
||||
registry.Boolean(True, _("""Determines whether the bot will list private
|
||||
plugins with the list command if given the --private switch. If this is
|
||||
|
@ -346,14 +346,15 @@ class Misc(callbacks.Plugin):
|
||||
return
|
||||
try:
|
||||
L = irc._mores[userHostmask]
|
||||
chunk = L.pop()
|
||||
number = self.registryValue('mores', msg.args[0])
|
||||
chunks = [L.pop() for x in xrange(0, number)]
|
||||
if L:
|
||||
if len(L) < 2:
|
||||
more = _('more message')
|
||||
else:
|
||||
more = _('more messages')
|
||||
chunk += format(' \x02(%s)\x0F', more)
|
||||
irc.reply(chunk, True)
|
||||
chunks[-1] += format(' \x02(%s)\x0F', more)
|
||||
irc.replies(chunks, noLengthCheck=True, oneToOne=False)
|
||||
except KeyError:
|
||||
irc.error(_('You haven\'t asked me a command; perhaps you want '
|
||||
'to see someone else\'s more. To do so, call this '
|
||||
|
@ -211,6 +211,18 @@ class MiscTestCase(ChannelPluginTestCase):
|
||||
self.assertRegexp('echo %s' % ('abc'*300), 'more')
|
||||
self.assertRegexp('more', 'more')
|
||||
self.assertNotRegexp('more', 'more')
|
||||
with conf.supybot.plugins.Misc.mores.context(2):
|
||||
self.assertRegexp('echo %s' % ('abc'*600), 'more')
|
||||
|
||||
self.assertNotRegexp('more', 'more')
|
||||
m = self.irc.takeMsg()
|
||||
self.assertIsNot(m, None)
|
||||
self.assertIn('more', m.args[1])
|
||||
|
||||
self.assertNotRegexp('more', 'more')
|
||||
m = self.irc.takeMsg()
|
||||
self.assertIsNot(m, None)
|
||||
self.assertNotIn('more', m.args[1])
|
||||
|
||||
def testInvalidCommand(self):
|
||||
self.assertError('echo []')
|
||||
|
@ -465,7 +465,8 @@ class RichReplyMethods(object):
|
||||
return self.reply(s, **kwargs)
|
||||
|
||||
def replies(self, L, prefixer=None, joiner=None,
|
||||
onlyPrefixFirst=False, to=None, **kwargs):
|
||||
onlyPrefixFirst=False, to=None,
|
||||
oneToOne=None, **kwargs):
|
||||
if prefixer is None:
|
||||
prefixer = ''
|
||||
if joiner is None:
|
||||
@ -474,6 +475,7 @@ class RichReplyMethods(object):
|
||||
prefixer = prefixer.__add__
|
||||
if isinstance(joiner, basestring):
|
||||
joiner = joiner.join
|
||||
if oneToOne is None: # Can be True, False, or None
|
||||
if ircutils.isChannel(to):
|
||||
oneToOne = conf.get(conf.supybot.reply.oneToOne, to)
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user