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)
|
conf.registerPlugin('Misc', True)
|
||||||
|
|
||||||
Misc = conf.registerPlugin('Misc')
|
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',
|
conf.registerGlobalValue(Misc, 'listPrivatePlugins',
|
||||||
registry.Boolean(True, _("""Determines whether the bot will list private
|
registry.Boolean(True, _("""Determines whether the bot will list private
|
||||||
plugins with the list command if given the --private switch. If this is
|
plugins with the list command if given the --private switch. If this is
|
||||||
|
@ -346,14 +346,15 @@ class Misc(callbacks.Plugin):
|
|||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
L = irc._mores[userHostmask]
|
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 L:
|
||||||
if len(L) < 2:
|
if len(L) < 2:
|
||||||
more = _('more message')
|
more = _('more message')
|
||||||
else:
|
else:
|
||||||
more = _('more messages')
|
more = _('more messages')
|
||||||
chunk += format(' \x02(%s)\x0F', more)
|
chunks[-1] += format(' \x02(%s)\x0F', more)
|
||||||
irc.reply(chunk, True)
|
irc.replies(chunks, noLengthCheck=True, oneToOne=False)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
irc.error(_('You haven\'t asked me a command; perhaps you want '
|
irc.error(_('You haven\'t asked me a command; perhaps you want '
|
||||||
'to see someone else\'s more. To do so, call this '
|
'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('echo %s' % ('abc'*300), 'more')
|
||||||
self.assertRegexp('more', 'more')
|
self.assertRegexp('more', 'more')
|
||||||
self.assertNotRegexp('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):
|
def testInvalidCommand(self):
|
||||||
self.assertError('echo []')
|
self.assertError('echo []')
|
||||||
|
@ -465,7 +465,8 @@ class RichReplyMethods(object):
|
|||||||
return self.reply(s, **kwargs)
|
return self.reply(s, **kwargs)
|
||||||
|
|
||||||
def replies(self, L, prefixer=None, joiner=None,
|
def replies(self, L, prefixer=None, joiner=None,
|
||||||
onlyPrefixFirst=False, to=None, **kwargs):
|
onlyPrefixFirst=False, to=None,
|
||||||
|
oneToOne=None, **kwargs):
|
||||||
if prefixer is None:
|
if prefixer is None:
|
||||||
prefixer = ''
|
prefixer = ''
|
||||||
if joiner is None:
|
if joiner is None:
|
||||||
@ -474,10 +475,11 @@ class RichReplyMethods(object):
|
|||||||
prefixer = prefixer.__add__
|
prefixer = prefixer.__add__
|
||||||
if isinstance(joiner, basestring):
|
if isinstance(joiner, basestring):
|
||||||
joiner = joiner.join
|
joiner = joiner.join
|
||||||
if ircutils.isChannel(to):
|
if oneToOne is None: # Can be True, False, or None
|
||||||
oneToOne = conf.get(conf.supybot.reply.oneToOne, to)
|
if ircutils.isChannel(to):
|
||||||
else:
|
oneToOne = conf.get(conf.supybot.reply.oneToOne, to)
|
||||||
oneToOne = conf.supybot.reply.oneToOne()
|
else:
|
||||||
|
oneToOne = conf.supybot.reply.oneToOne()
|
||||||
if oneToOne:
|
if oneToOne:
|
||||||
return self.reply(prefixer(joiner(L)), to=to, **kwargs)
|
return self.reply(prefixer(joiner(L)), to=to, **kwargs)
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user