mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-02-18 22:51:01 +01:00
Add [<reason>] to Admin.part
This commit is contained in:
parent
5419ed05f4
commit
ef91ae1133
31
src/Admin.py
31
src/Admin.py
@ -232,18 +232,31 @@ class Admin(privmsgs.CapabilityCheckingPrivmsg):
|
|||||||
irc.error('That\'s not a valid nick.')
|
irc.error('That\'s not a valid nick.')
|
||||||
|
|
||||||
def part(self, irc, msg, args):
|
def part(self, irc, msg, args):
|
||||||
"""<channel> [<channel> ...]
|
"""<channel> [<channel> ...] [<reason>]
|
||||||
|
|
||||||
Tells the bot to part the whitespace-separated list of channels
|
Tells the bot to part the whitespace-separated list of channels
|
||||||
you give it.
|
you give it. If <reason> is specified, use it as the part message.
|
||||||
"""
|
"""
|
||||||
if not args:
|
if not args:
|
||||||
args = [msg.args[0]]
|
args = [msg.args[0]]
|
||||||
for arg in args:
|
channels = []
|
||||||
if arg not in irc.state.channels:
|
reason = ''
|
||||||
irc.error('I\'m not currently in %s' % arg)
|
for (i, arg) in enumerate(args):
|
||||||
|
if ircutils.isChannel(arg):
|
||||||
|
channels.append(args[i])
|
||||||
|
args[i] = None
|
||||||
|
else:
|
||||||
|
break
|
||||||
|
args = filter(None, args)
|
||||||
|
if not channels:
|
||||||
|
channels.append(msg.args[0])
|
||||||
|
if args:
|
||||||
|
reason = ' '.join(args)
|
||||||
|
for chan in channels:
|
||||||
|
if chan not in irc.state.channels:
|
||||||
|
irc.error('I\'m not currently in %s' % chan)
|
||||||
return
|
return
|
||||||
for arg in args:
|
for chan in channels:
|
||||||
L = []
|
L = []
|
||||||
for channelWithPass in conf.supybot.channels():
|
for channelWithPass in conf.supybot.channels():
|
||||||
channel = channelWithPass.split(',')[0]
|
channel = channelWithPass.split(',')[0]
|
||||||
@ -252,10 +265,10 @@ class Admin(privmsgs.CapabilityCheckingPrivmsg):
|
|||||||
# This is necessary so the set doesn't change size while iterating.
|
# This is necessary so the set doesn't change size while iterating.
|
||||||
for channel in L:
|
for channel in L:
|
||||||
conf.supybot.channels().remove(channel)
|
conf.supybot.channels().remove(channel)
|
||||||
irc.queueMsg(ircmsgs.parts(args, msg.nick))
|
irc.queueMsg(ircmsgs.parts(channels, reason or msg.nick))
|
||||||
inAtLeastOneChannel = False
|
inAtLeastOneChannel = False
|
||||||
for channel in args:
|
for chan in channels:
|
||||||
if msg.nick in irc.state.channels[arg].users:
|
if msg.nick in irc.state.channels[chan].users:
|
||||||
inAtLeastOneChannel = True
|
inAtLeastOneChannel = True
|
||||||
if not inAtLeastOneChannel:
|
if not inAtLeastOneChannel:
|
||||||
irc.replySuccess()
|
irc.replySuccess()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user