mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-24 02:54:05 +01:00
Merge remote-tracking branch 'upstream/testing' into channel/autorejoin-delay
Conflicts: plugins/Channel/config.py
This commit is contained in:
commit
e3079f82b2
@ -41,10 +41,6 @@ def configure(advanced):
|
||||
from supybot.questions import expect, anything, something, yn
|
||||
conf.registerPlugin('Admin', True)
|
||||
|
||||
|
||||
Admin = conf.registerPlugin('Admin')
|
||||
# This is where your configuration variables (if any) should go. For example:
|
||||
# conf.registerGlobalValue(Admin, 'someConfigVariableName',
|
||||
# registry.Boolean(False, """Help for someConfigVariableName."""))
|
||||
|
||||
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:
|
||||
|
@ -231,34 +231,6 @@ class Admin(callbacks.Plugin):
|
||||
irc.reply(irc.nick)
|
||||
nick = wrap(nick, [additional('nick'), additional('something')])
|
||||
|
||||
@internationalizeDocstring
|
||||
def part(self, irc, msg, args, channel, reason):
|
||||
"""[<channel>] [<reason>]
|
||||
|
||||
Tells the bot to part the list of channels you give it. <channel> is
|
||||
only necessary if you want the bot to part a channel other than the
|
||||
current channel. If <reason> is specified, use it as the part
|
||||
message.
|
||||
"""
|
||||
if channel is None:
|
||||
if irc.isChannel(msg.args[0]):
|
||||
channel = msg.args[0]
|
||||
else:
|
||||
irc.error(Raise=True)
|
||||
try:
|
||||
network = conf.supybot.networks.get(irc.network)
|
||||
network.channels().remove(channel)
|
||||
except KeyError:
|
||||
pass
|
||||
if channel not in irc.state.channels:
|
||||
irc.error(_('I\'m not in %s.') % channel, Raise=True)
|
||||
irc.queueMsg(ircmsgs.part(channel, reason or msg.nick))
|
||||
if msg.nick in irc.state.channels[channel].users:
|
||||
irc.noReply()
|
||||
else:
|
||||
irc.replySuccess()
|
||||
part = wrap(part, [optional('validChannel'), additional('text')])
|
||||
|
||||
class capability(callbacks.Commands):
|
||||
|
||||
@internationalizeDocstring
|
||||
|
@ -94,27 +94,6 @@ class AdminTestCase(PluginTestCase):
|
||||
self.assertEqual(m.args[0], '#foo')
|
||||
self.assertEqual(m.args[1], 'key')
|
||||
|
||||
def testPart(self):
|
||||
def getAfterJoinMessages():
|
||||
m = self.irc.takeMsg()
|
||||
self.assertEqual(m.command, 'MODE')
|
||||
m = self.irc.takeMsg()
|
||||
self.assertEqual(m.command, 'MODE')
|
||||
m = self.irc.takeMsg()
|
||||
self.assertEqual(m.command, 'WHO')
|
||||
self.assertError('part #foo')
|
||||
self.assertRegexp('part #foo', 'not in')
|
||||
self.irc.feedMsg(ircmsgs.join('#foo', prefix=self.prefix))
|
||||
getAfterJoinMessages()
|
||||
m = self.getMsg('part #foo')
|
||||
self.assertEqual(m.command, 'PART')
|
||||
self.irc.feedMsg(ircmsgs.join('#foo', prefix=self.prefix))
|
||||
getAfterJoinMessages()
|
||||
m = self.getMsg('part #foo reason')
|
||||
self.assertEqual(m.command, 'PART')
|
||||
self.assertEqual(m.args[0], '#foo')
|
||||
self.assertEqual(m.args[1], 'reason')
|
||||
|
||||
def testNick(self):
|
||||
original = conf.supybot.nick()
|
||||
try:
|
||||
|
@ -55,5 +55,11 @@ conf.registerChannelValue(Channel, 'rejoinDelay',
|
||||
registry.NonNegativeInteger(0, _("""Determines how many seconds the bot will wait
|
||||
before rejoining a channel if kicked and
|
||||
supybot.plugins.Channel.alwaysRejoin is on.""")))
|
||||
conf.registerChannelValue(Channel, 'partMsg',
|
||||
registry.String('$version', _("""Determines what part message should be
|
||||
used by default. If the part command is called without a part message,
|
||||
this will be used. If this value is empty, then no part message will
|
||||
be used (they are optional in the IRC protocol). The standard
|
||||
substitutions ($version, $nick, etc.) are all handled appropriately.""")))
|
||||
|
||||
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:
|
||||
|
@ -268,17 +268,22 @@ class Channel(callbacks.Plugin):
|
||||
any('nickInChannel')])
|
||||
|
||||
@internationalizeDocstring
|
||||
def cycle(self, irc, msg, args, channel):
|
||||
def cycle(self, irc, msg, args, channel, reason):
|
||||
"""[<channel>]
|
||||
|
||||
If you have the #channel,op capability, this will cause the bot to
|
||||
"cycle", or PART and then JOIN the channel. <channel> is only necessary
|
||||
if the message isn't sent in the channel itself.
|
||||
if the message isn't sent in the channel itself. If <reason> is not
|
||||
specified, the default part message specified in
|
||||
supybot.plugins.Channel.partMsg will be used. No part message will be
|
||||
used if neither a cycle reason nor a default part message is given.
|
||||
"""
|
||||
self._sendMsg(irc, ircmsgs.part(channel, msg.nick))
|
||||
reason = (reason or self.registryValue("partMsg", channel))
|
||||
reason = ircutils.standardSubstitute(irc, msg, reason)
|
||||
self._sendMsg(irc, ircmsgs.part(channel, reason))
|
||||
networkGroup = conf.supybot.networks.get(irc.network)
|
||||
self._sendMsg(irc, networkGroup.channels.join(channel))
|
||||
cycle = wrap(cycle, ['op'])
|
||||
cycle = wrap(cycle, ['op', additional('text')])
|
||||
|
||||
@internationalizeDocstring
|
||||
def kick(self, irc, msg, args, channel, nicks, reason):
|
||||
@ -951,6 +956,41 @@ class Channel(callbacks.Plugin):
|
||||
self.alertOps(irc, channel, text, frm=msg.nick)
|
||||
alert = wrap(alert, ['inChannel', 'text'])
|
||||
|
||||
@internationalizeDocstring
|
||||
def part(self, irc, msg, args, channel, reason):
|
||||
"""[<channel>] [<reason>]
|
||||
|
||||
Tells the bot to part the list of channels you give it. <channel> is
|
||||
only necessary if you want the bot to part a channel other than the
|
||||
current channel. If <reason> is specified, use it as the part
|
||||
message. Otherwise, the default part message specified in
|
||||
supybot.plugins.Channel.partMsg will be used. No part message will be
|
||||
used if no default is configured.
|
||||
"""
|
||||
if channel is None:
|
||||
if irc.isChannel(msg.args[0]):
|
||||
channel = msg.args[0]
|
||||
else:
|
||||
irc.error(Raise=True)
|
||||
capability = ircdb.makeChannelCapability(channel, 'op')
|
||||
hostmask = irc.state.nickToHostmask(msg.nick)
|
||||
if not ircdb.checkCapability(hostmask, capability):
|
||||
irc.errorNoCapability(capability, Raise=True)
|
||||
try:
|
||||
network = conf.supybot.networks.get(irc.network)
|
||||
network.channels().remove(channel)
|
||||
except KeyError:
|
||||
pass
|
||||
if channel not in irc.state.channels:
|
||||
irc.error(_('I\'m not in %s.') % channel, Raise=True)
|
||||
reason = (reason or self.registryValue("partMsg", channel))
|
||||
reason = ircutils.standardSubstitute(irc, msg, reason)
|
||||
irc.queueMsg(ircmsgs.part(channel, reason))
|
||||
if msg.nick in irc.state.channels[channel].users:
|
||||
irc.noReply()
|
||||
else:
|
||||
irc.replySuccess()
|
||||
part = wrap(part, [optional('validChannel'), additional('text')])
|
||||
|
||||
Class = Channel
|
||||
|
||||
|
@ -251,6 +251,27 @@ class ChannelTestCase(ChannelPluginTestCase):
|
||||
def testNicks(self):
|
||||
self.assertResponse('channel nicks', 'bar, foo, and test')
|
||||
self.assertResponse('channel nicks --count', '3')
|
||||
|
||||
|
||||
def testPart(self):
|
||||
def getAfterJoinMessages():
|
||||
m = self.irc.takeMsg()
|
||||
self.assertEqual(m.command, 'MODE')
|
||||
m = self.irc.takeMsg()
|
||||
self.assertEqual(m.command, 'MODE')
|
||||
m = self.irc.takeMsg()
|
||||
self.assertEqual(m.command, 'WHO')
|
||||
self.assertError('part #foo')
|
||||
self.assertRegexp('part #foo', 'not in')
|
||||
self.irc.feedMsg(ircmsgs.join('#foo', prefix=self.prefix))
|
||||
getAfterJoinMessages()
|
||||
m = self.getMsg('part #foo')
|
||||
self.assertEqual(m.command, 'PART')
|
||||
self.irc.feedMsg(ircmsgs.join('#foo', prefix=self.prefix))
|
||||
getAfterJoinMessages()
|
||||
m = self.getMsg('part #foo reason')
|
||||
self.assertEqual(m.command, 'PART')
|
||||
self.assertEqual(m.args[0], '#foo')
|
||||
self.assertEqual(m.args[1], 'reason')
|
||||
|
||||
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:
|
||||
|
||||
|
@ -46,10 +46,11 @@ conf.registerGlobalValue(Owner, 'public',
|
||||
registry.Boolean(True, """Determines whether this plugin is publicly
|
||||
visible."""))
|
||||
conf.registerGlobalValue(Owner, 'quitMsg',
|
||||
registry.String('', """Determines what quit message will be used by default.
|
||||
registry.String('$version', """Determines what quit message will be used by default.
|
||||
If the quit command is called without a quit message, this will be used. If
|
||||
this value is empty, the nick of the person giving the quit command will be
|
||||
used."""))
|
||||
used. The standard substitutions ($version, $nick, etc.) are all handled
|
||||
appropriately."""))
|
||||
|
||||
conf.registerGroup(conf.supybot.commands, 'renames', orderAlphabetically=True)
|
||||
|
||||
|
@ -344,9 +344,11 @@ class Owner(callbacks.Plugin):
|
||||
|
||||
Exits the bot with the QUIT message <text>. If <text> is not given,
|
||||
the default quit message (supybot.plugins.Owner.quitMsg) will be used.
|
||||
If there is no default quitMsg set, your nick will be used.
|
||||
If there is no default quitMsg set, your nick will be used. The standard
|
||||
substitutions ($version, $nick, etc.) are all handled appropriately.
|
||||
"""
|
||||
text = text or self.registryValue('quitMsg') or msg.nick
|
||||
text = ircutils.standardSubstitute(irc, msg, text)
|
||||
irc.noReply()
|
||||
m = ircmsgs.quit(text)
|
||||
world.upkeep()
|
||||
|
@ -69,6 +69,7 @@ import supybot.i18n as i18n
|
||||
import supybot.utils as utils
|
||||
import supybot.registry as registry
|
||||
import supybot.questions as questions
|
||||
import supybot.ircutils as ircutils
|
||||
|
||||
from supybot.version import version
|
||||
|
||||
@ -104,6 +105,7 @@ def main():
|
||||
for irc in world.ircs:
|
||||
quitmsg = conf.supybot.plugins.Owner.quitMsg() or \
|
||||
'Ctrl-C at console.'
|
||||
quitmsg = ircutils.standardSubstitute(irc, None, quitmsg)
|
||||
irc.queueMsg(ircmsgs.quit(quitmsg))
|
||||
irc.die()
|
||||
except SystemExit as e:
|
||||
|
@ -49,7 +49,7 @@ from cStringIO import StringIO as sio
|
||||
|
||||
from . import utils
|
||||
from . import minisix
|
||||
|
||||
from .version import version
|
||||
|
||||
def debug(s, *args):
|
||||
"""Prints a debug string. Most likely replaced by our logging debug."""
|
||||
@ -690,6 +690,7 @@ def standardSubstitute(irc, msg, text, env=None):
|
||||
'm': localtime[4], 'min': localtime[4], 'minute': localtime[4],
|
||||
's': localtime[5], 'sec': localtime[5], 'second': localtime[5],
|
||||
'tz': time.strftime('%Z', localtime),
|
||||
'version': 'Supybot %s' % version,
|
||||
})
|
||||
if irc:
|
||||
vars.update({
|
||||
|
Loading…
Reference in New Issue
Block a user