mirror of
https://github.com/progval/Limnoria.git
synced 2025-05-05 09:50:52 -05:00
Move 'part' command from Admin to Channel and require #channel,op instead of admin
Closes #79.
This commit is contained in:
parent
a59784a366
commit
a67fb94875
@ -41,10 +41,6 @@ def configure(advanced):
|
|||||||
from supybot.questions import expect, anything, something, yn
|
from supybot.questions import expect, anything, something, yn
|
||||||
conf.registerPlugin('Admin', True)
|
conf.registerPlugin('Admin', True)
|
||||||
|
|
||||||
|
|
||||||
Admin = conf.registerPlugin('Admin')
|
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:
|
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:
|
||||||
|
@ -232,33 +232,6 @@ class Admin(callbacks.Plugin):
|
|||||||
nick = wrap(nick, [additional('nick'), additional('something')])
|
nick = wrap(nick, [additional('nick'), additional('something')])
|
||||||
|
|
||||||
@internationalizeDocstring
|
@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):
|
class capability(callbacks.Commands):
|
||||||
|
|
||||||
@internationalizeDocstring
|
@internationalizeDocstring
|
||||||
|
@ -94,27 +94,6 @@ class AdminTestCase(PluginTestCase):
|
|||||||
self.assertEqual(m.args[0], '#foo')
|
self.assertEqual(m.args[0], '#foo')
|
||||||
self.assertEqual(m.args[1], 'key')
|
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):
|
def testNick(self):
|
||||||
original = conf.supybot.nick()
|
original = conf.supybot.nick()
|
||||||
try:
|
try:
|
||||||
|
@ -51,6 +51,11 @@ conf.registerChannelValue(Channel, 'nicksInPrivate',
|
|||||||
registry.Boolean(True, _("""Determines whether the output of 'nicks' will
|
registry.Boolean(True, _("""Determines whether the output of 'nicks' will
|
||||||
be sent in private. This prevents mass-highlights of a channel's users,
|
be sent in private. This prevents mass-highlights of a channel's users,
|
||||||
accidental or on purpose.""")))
|
accidental or on purpose.""")))
|
||||||
|
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:
|
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:
|
||||||
|
@ -941,6 +941,41 @@ class Channel(callbacks.Plugin):
|
|||||||
self.alertOps(irc, channel, text, frm=msg.nick)
|
self.alertOps(irc, channel, text, frm=msg.nick)
|
||||||
alert = wrap(alert, ['inChannel', 'text'])
|
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
|
Class = Channel
|
||||||
|
|
||||||
|
@ -251,6 +251,27 @@ class ChannelTestCase(ChannelPluginTestCase):
|
|||||||
def testNicks(self):
|
def testNicks(self):
|
||||||
self.assertResponse('channel nicks', 'bar, foo, and test')
|
self.assertResponse('channel nicks', 'bar, foo, and test')
|
||||||
self.assertResponse('channel nicks --count', '3')
|
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:
|
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user