2003-03-27 07:28:13 +01:00
|
|
|
###
|
2004-08-23 15:14:06 +02:00
|
|
|
# Copyright (c) 2002-2004, Jeremiah Fincher
|
2003-03-27 07:28:13 +01:00
|
|
|
# All rights reserved.
|
|
|
|
#
|
|
|
|
# Redistribution and use in source and binary forms, with or without
|
|
|
|
# modification, are permitted provided that the following conditions are met:
|
|
|
|
#
|
|
|
|
# * Redistributions of source code must retain the above copyright notice,
|
|
|
|
# this list of conditions, and the following disclaimer.
|
|
|
|
# * Redistributions in binary form must reproduce the above copyright notice,
|
|
|
|
# this list of conditions, and the following disclaimer in the
|
|
|
|
# documentation and/or other materials provided with the distribution.
|
|
|
|
# * Neither the name of the author of this software nor the name of
|
|
|
|
# contributors to this software may be used to endorse or promote products
|
|
|
|
# derived from this software without specific prior written consent.
|
|
|
|
#
|
|
|
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
|
|
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
|
|
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
# POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
###
|
|
|
|
|
|
|
|
"""
|
2003-09-03 11:50:04 +02:00
|
|
|
Basic channel management commands. Many of these commands require their caller
|
|
|
|
to have the <channel>.op capability. This plugin is loaded by default.
|
2003-03-27 07:28:13 +01:00
|
|
|
"""
|
|
|
|
|
2004-09-01 08:06:54 +02:00
|
|
|
import supybot
|
|
|
|
|
2003-11-25 18:33:58 +01:00
|
|
|
__revision__ = "$Id$"
|
2004-09-01 08:06:54 +02:00
|
|
|
__author__ = supybot.authors.jemfinch
|
2003-11-25 18:33:58 +01:00
|
|
|
|
2004-07-24 07:18:26 +02:00
|
|
|
import supybot.fix as fix
|
2003-11-25 18:33:58 +01:00
|
|
|
|
2004-08-27 11:14:13 +02:00
|
|
|
import sys
|
2003-03-27 07:28:13 +01:00
|
|
|
import time
|
2004-01-01 21:17:55 +01:00
|
|
|
import getopt
|
2004-09-23 18:13:00 +02:00
|
|
|
|
2003-11-15 05:37:04 +01:00
|
|
|
from itertools import imap
|
2003-03-27 07:28:13 +01:00
|
|
|
|
2004-07-24 07:18:26 +02:00
|
|
|
import supybot.conf as conf
|
|
|
|
import supybot.ircdb as ircdb
|
|
|
|
import supybot.utils as utils
|
|
|
|
import supybot.ircmsgs as ircmsgs
|
2004-10-02 04:36:10 +02:00
|
|
|
from supybot.commands import wrap
|
2004-07-24 07:18:26 +02:00
|
|
|
import supybot.schedule as schedule
|
|
|
|
import supybot.ircutils as ircutils
|
|
|
|
import supybot.registry as registry
|
|
|
|
import supybot.callbacks as callbacks
|
2003-03-27 07:28:13 +01:00
|
|
|
|
2004-04-05 12:03:13 +02:00
|
|
|
conf.registerPlugin('Channel')
|
|
|
|
conf.registerChannelValue(conf.supybot.plugins.Channel, 'alwaysRejoin',
|
2004-04-05 18:01:49 +02:00
|
|
|
registry.Boolean(True, """Determines whether the bot will always try to
|
2004-04-05 12:03:13 +02:00
|
|
|
rejoin a channel whenever it's kicked from the channel."""))
|
|
|
|
|
2004-09-30 07:25:38 +02:00
|
|
|
# XXX We need a lot of noReply calls in here; otherwise, we should add a
|
|
|
|
# wrapper of some sort to handle that for us. Perhaps we can abstract out
|
|
|
|
# the very repetitive commands.wrap calls in here while we're at it.
|
2003-10-21 08:03:57 +02:00
|
|
|
class Channel(callbacks.Privmsg):
|
2004-04-05 12:03:13 +02:00
|
|
|
def doKick(self, irc, msg):
|
|
|
|
channel = msg.args[0]
|
|
|
|
if msg.args[1] == irc.nick:
|
|
|
|
if self.registryValue('alwaysRejoin', channel):
|
|
|
|
irc.sendMsg(ircmsgs.join(channel)) # Fix for keys.
|
|
|
|
|
2004-09-28 09:10:27 +02:00
|
|
|
def mode(self, irc, msg, args, channel):
|
2004-07-23 03:01:29 +02:00
|
|
|
"""[<channel>] <mode> [<arg> ...]
|
|
|
|
|
|
|
|
Sets the mode in <channel> to <mode>, sending the arguments given.
|
2004-07-23 03:19:30 +02:00
|
|
|
<channel> is only necessary if the message isn't sent in the channel
|
|
|
|
itself.
|
2004-07-23 03:01:29 +02:00
|
|
|
"""
|
2004-09-28 09:10:27 +02:00
|
|
|
irc.queueMsg(ircmsgs.mode(channel, args))
|
2004-10-02 04:36:10 +02:00
|
|
|
mode = wrap(mode,
|
|
|
|
[('checkChannelCapability', 'op'),
|
|
|
|
('haveOp', 'change the mode')],
|
|
|
|
requireExtra=True)
|
2004-07-23 03:01:29 +02:00
|
|
|
|
2004-09-23 18:13:00 +02:00
|
|
|
def limit(self, irc, msg, args, channel, limit):
|
2004-09-28 09:10:27 +02:00
|
|
|
"""[<channel>] [<limit>]
|
2004-07-23 03:19:30 +02:00
|
|
|
|
2004-09-28 09:10:27 +02:00
|
|
|
Sets the channel limit to <limit>. If <limit> is 0, or isn't given,
|
|
|
|
removes the channel limit. <channel> is only necessary if the message
|
|
|
|
isn't sent in the channel itself.
|
2004-07-23 03:19:30 +02:00
|
|
|
"""
|
|
|
|
if limit:
|
2004-09-28 09:10:27 +02:00
|
|
|
irc.queueMsg(ircmsgs.mode(channel, ['+l', limit]))
|
2004-07-23 03:19:30 +02:00
|
|
|
else:
|
2004-09-28 09:10:27 +02:00
|
|
|
irc.queueMsg(ircmsgs.mode(channel, ['-l']))
|
2004-10-02 04:36:10 +02:00
|
|
|
limit = wrap(mode, [('checkChannelCapability', 'op'),
|
|
|
|
('haveOp', 'change the limit'),
|
|
|
|
('?nonNegativeInt', 0)])
|
2004-07-23 06:07:50 +02:00
|
|
|
|
|
|
|
def moderate(self, irc, msg, args, channel):
|
|
|
|
"""[<channel>]
|
|
|
|
|
|
|
|
Sets +m on <channel>, making it so only ops and voiced users can
|
|
|
|
send messages to the channel. <channel> is only necessary if the
|
|
|
|
message isn't sent in the channel itself.
|
|
|
|
"""
|
2004-09-28 09:10:27 +02:00
|
|
|
irc.queueMsg(ircmsgs.mode(channel, ['+m']))
|
2004-10-02 04:36:10 +02:00
|
|
|
moderate = wrap(moderate, [('checkChannelCapability', 'op'),
|
|
|
|
('haveOp', 'moderate the channel')])
|
2004-08-11 14:57:52 +02:00
|
|
|
|
2004-07-23 06:07:50 +02:00
|
|
|
def unmoderate(self, irc, msg, args, channel):
|
|
|
|
"""[<channel>]
|
|
|
|
|
|
|
|
Sets -m on <channel>, making it so everyone can
|
|
|
|
send messages to the channel. <channel> is only necessary if the
|
|
|
|
message isn't sent in the channel itself.
|
|
|
|
"""
|
2004-09-28 09:10:27 +02:00
|
|
|
irc.queueMsg(ircmsgs.mode(channel, ['-m']))
|
2004-10-02 04:36:10 +02:00
|
|
|
unmoderate = wrap(unmoderate, [('checkChannelCapability', 'op'),
|
|
|
|
('haveOp', 'unmoderate the channel')])
|
2004-07-23 06:07:50 +02:00
|
|
|
|
2004-09-23 18:13:00 +02:00
|
|
|
def key(self, irc, msg, args, channel, key):
|
2004-07-23 06:07:50 +02:00
|
|
|
"""[<channel>] [<key>]
|
|
|
|
|
|
|
|
Sets the keyword in <channel> to <key>. If <key> is not given, removes
|
|
|
|
the keyword requirement to join <channel>. <channel> is only necessary
|
|
|
|
if the message isn't sent in the channel itself.
|
|
|
|
"""
|
|
|
|
if key:
|
2004-09-28 09:10:27 +02:00
|
|
|
irc.queueMsg(ircmsgs.mode(channel, ['+k', key]))
|
2004-07-23 06:07:50 +02:00
|
|
|
else:
|
2004-09-28 09:10:27 +02:00
|
|
|
irc.queueMsg(ircmsgs.mode(channel, ['-k']))
|
2004-10-02 04:36:10 +02:00
|
|
|
key = wrap(key, [('checkChannelCapability', 'op'),
|
|
|
|
('haveOp', 'change the keyword'), '?capability'])
|
2004-08-11 14:57:52 +02:00
|
|
|
|
2003-09-29 07:01:41 +02:00
|
|
|
def op(self, irc, msg, args, channel):
|
2004-02-09 19:23:21 +01:00
|
|
|
"""[<channel>] [<nick> ...]
|
2003-03-27 07:28:13 +01:00
|
|
|
|
2004-02-17 14:28:40 +01:00
|
|
|
If you have the #channel,op capability, this will give all the <nick>s
|
2004-02-09 19:23:21 +01:00
|
|
|
you provide ops. If you don't provide any <nick>s, this will op you.
|
2003-11-19 09:13:19 +01:00
|
|
|
<channel> is only necessary if the message isn't sent in the channel
|
|
|
|
itself.
|
2003-03-27 07:28:13 +01:00
|
|
|
"""
|
2004-02-09 19:23:21 +01:00
|
|
|
if not args:
|
|
|
|
args = [msg.nick]
|
2004-09-28 09:10:27 +02:00
|
|
|
irc.queueMsg(ircmsgs.ops(channel, args))
|
2004-10-02 04:36:10 +02:00
|
|
|
op = wrap(op, [('checkChannelCapability', 'op'), ('haveOp', 'op someone')])
|
2003-03-27 07:28:13 +01:00
|
|
|
|
2003-09-29 07:01:41 +02:00
|
|
|
def halfop(self, irc, msg, args, channel):
|
2003-03-27 07:28:13 +01:00
|
|
|
"""[<channel>]
|
|
|
|
|
2004-02-17 14:28:40 +01:00
|
|
|
If you have the #channel,halfop capability, this will give all the
|
2004-02-09 19:23:21 +01:00
|
|
|
<nick>s you provide halfops. If you don't provide any <nick>s, this
|
|
|
|
will give you halfops. <channel> is only necessary if the message isn't
|
|
|
|
sent in the channel itself.
|
2003-03-27 07:28:13 +01:00
|
|
|
"""
|
2004-02-09 19:23:21 +01:00
|
|
|
if not args:
|
|
|
|
args = [msg.nick]
|
2004-09-28 09:10:27 +02:00
|
|
|
irc.queueMsg(ircmsgs.halfops(channel, args))
|
2004-10-02 04:36:10 +02:00
|
|
|
halfop = wrap(halfop, [('checkChannelCapability', 'halfop'),
|
|
|
|
('haveOp', 'halfop someone')])
|
2003-03-27 07:28:13 +01:00
|
|
|
|
2003-09-29 07:01:41 +02:00
|
|
|
def voice(self, irc, msg, args, channel):
|
2003-03-27 07:28:13 +01:00
|
|
|
"""[<channel>]
|
|
|
|
|
2004-02-17 14:28:40 +01:00
|
|
|
If you have the #channel,voice capability, this will voice all the
|
2004-02-09 19:23:21 +01:00
|
|
|
<nick>s you provide. If you don't provide any <nick>s, this will
|
|
|
|
voice you. <channel> is only necessary if the message isn't sent in the
|
|
|
|
channel itself.
|
2003-03-27 07:28:13 +01:00
|
|
|
"""
|
2004-02-09 19:23:21 +01:00
|
|
|
if not args:
|
|
|
|
args = [msg.nick]
|
2004-09-28 09:10:27 +02:00
|
|
|
irc.queueMsg(ircmsgs.voices(channel, args))
|
2004-10-02 04:36:10 +02:00
|
|
|
voice = wrap(voice, [('checkChannelCapability', 'voice'),
|
|
|
|
('haveOp', 'voice someone')])
|
2003-12-03 21:27:42 +01:00
|
|
|
|
|
|
|
def deop(self, irc, msg, args, channel):
|
2003-12-04 17:27:03 +01:00
|
|
|
"""[<channel>] [<nick> ...]
|
2003-12-03 21:27:42 +01:00
|
|
|
|
2004-02-17 14:28:40 +01:00
|
|
|
If you have the #channel,op capability, this will remove operator
|
2003-12-04 17:27:03 +01:00
|
|
|
privileges from all the nicks given. If no nicks are given, removes
|
|
|
|
operator privileges from the person sending the message.
|
2003-12-03 21:27:42 +01:00
|
|
|
"""
|
2003-12-03 21:49:51 +01:00
|
|
|
if not args:
|
2003-12-04 17:27:03 +01:00
|
|
|
args.append(msg.nick)
|
2004-02-07 07:24:45 +01:00
|
|
|
if irc.nick in args:
|
|
|
|
irc.error('I cowardly refuse to deop myself. If you really want '
|
|
|
|
'me deopped, tell me to op you and then deop me '
|
|
|
|
'yourself.')
|
2004-09-28 09:10:27 +02:00
|
|
|
else:
|
2003-12-03 21:27:42 +01:00
|
|
|
irc.queueMsg(ircmsgs.deops(channel, args))
|
2004-10-02 04:36:10 +02:00
|
|
|
deop = wrap(deop, [('checkChannelCapability', 'op'),
|
|
|
|
('haveOp', 'deop someone')])
|
2004-06-19 04:06:44 +02:00
|
|
|
|
2003-12-03 21:27:42 +01:00
|
|
|
def dehalfop(self, irc, msg, args, channel):
|
2003-12-04 17:27:03 +01:00
|
|
|
"""[<channel>] [<nick> ...]
|
2003-12-03 21:27:42 +01:00
|
|
|
|
2004-02-17 14:28:40 +01:00
|
|
|
If you have the #channel,op capability, this will remove half-operator
|
2003-12-04 17:27:03 +01:00
|
|
|
privileges from all the nicks given. If no nicks are given, removes
|
|
|
|
half-operator privileges from the person sending the message.
|
2003-12-03 21:27:42 +01:00
|
|
|
"""
|
2003-12-03 21:49:51 +01:00
|
|
|
if not args:
|
2003-12-04 17:27:03 +01:00
|
|
|
args.append(msg.nick)
|
2004-02-07 07:24:45 +01:00
|
|
|
if irc.nick in args:
|
|
|
|
irc.error('I cowardly refuse to dehalfop myself. If you really '
|
|
|
|
'want me dehalfopped, tell me to op you and then '
|
|
|
|
'dehalfop me yourself.')
|
2004-09-28 09:10:27 +02:00
|
|
|
else:
|
2003-12-03 21:27:42 +01:00
|
|
|
irc.queueMsg(ircmsgs.dehalfops(channel, args))
|
2004-10-02 04:36:10 +02:00
|
|
|
dehalfop = wrap(dehalfop, [('checkChannelCapability', 'halfop'),
|
|
|
|
('haveOp', 'dehalfop someone')])
|
2004-06-19 04:06:44 +02:00
|
|
|
|
2003-12-03 21:27:42 +01:00
|
|
|
def devoice(self, irc, msg, args, channel):
|
2003-12-04 17:27:03 +01:00
|
|
|
"""[<channel>] [<nick> ...]
|
2003-12-03 21:27:42 +01:00
|
|
|
|
2004-02-17 14:28:40 +01:00
|
|
|
If you have the #channel,op capability, this will remove voice from all
|
2003-12-04 17:27:03 +01:00
|
|
|
the nicks given. If no nicks are given, removes voice from the person
|
|
|
|
sending the message.
|
2003-12-03 21:27:42 +01:00
|
|
|
"""
|
2003-12-03 21:49:51 +01:00
|
|
|
if not args:
|
2003-12-04 17:27:03 +01:00
|
|
|
args.append(msg.nick)
|
2004-02-07 07:24:45 +01:00
|
|
|
if irc.nick in args:
|
|
|
|
irc.error('I cowardly refuse to devoice myself. If you really '
|
|
|
|
'want me devoiced, tell me to op you and then devoice '
|
|
|
|
'me yourself.')
|
2004-09-28 09:10:27 +02:00
|
|
|
else:
|
2003-12-03 21:27:42 +01:00
|
|
|
irc.queueMsg(ircmsgs.devoices(channel, args))
|
2004-10-02 04:36:10 +02:00
|
|
|
devoice = wrap(devoice, [('checkChannelCapability', 'voice'),
|
|
|
|
('haveOp', 'devoice someone')])
|
2004-06-19 04:06:44 +02:00
|
|
|
|
2004-09-23 18:13:00 +02:00
|
|
|
def cycle(self, irc, msg, args, channel, key):
|
2003-10-13 05:58:37 +02:00
|
|
|
"""[<channel>] [<key>]
|
2003-03-27 07:28:13 +01:00
|
|
|
|
2004-02-17 14:28:40 +01:00
|
|
|
If you have the #channel,op capability, this will cause the bot to
|
2003-11-19 09:13:19 +01:00
|
|
|
"cycle", or PART and then JOIN the channel. If <key> is given, join
|
|
|
|
the channel using that key. <channel> is only necessary if the message
|
|
|
|
isn't sent in the channel itself.
|
2003-03-27 07:28:13 +01:00
|
|
|
"""
|
2003-10-13 05:58:37 +02:00
|
|
|
if not key:
|
|
|
|
key = None
|
2003-09-29 07:01:41 +02:00
|
|
|
irc.queueMsg(ircmsgs.part(channel))
|
2003-10-13 05:58:37 +02:00
|
|
|
irc.queueMsg(ircmsgs.join(channel, key))
|
2004-09-30 07:25:38 +02:00
|
|
|
irc.noReply()
|
2004-10-02 04:36:10 +02:00
|
|
|
cycle = wrap(cycle, [('checkChannelCapability','op'),'?anything'])
|
2003-03-27 07:28:13 +01:00
|
|
|
|
2004-09-23 18:13:00 +02:00
|
|
|
def kick(self, irc, msg, args, channel, nick, reason):
|
2003-12-03 21:49:51 +01:00
|
|
|
"""[<channel>] <nick> [<reason>]
|
|
|
|
|
|
|
|
Kicks <nick> from <channel> for <reason>. If <reason> isn't given,
|
|
|
|
uses the nick of the person making the command as the reason.
|
|
|
|
<channel> is only necessary if the message isn't sent in the channel
|
|
|
|
itself.
|
|
|
|
"""
|
2004-09-28 09:10:27 +02:00
|
|
|
if nick not in irc.state.channels[channel].users:
|
|
|
|
irc.error('%s isn\'t in %s.' % (nick, channel))
|
|
|
|
return
|
|
|
|
if not reason:
|
|
|
|
reason = msg.nick
|
|
|
|
kicklen = irc.state.supported.get('kicklen', sys.maxint)
|
|
|
|
if len(reason) > kicklen:
|
|
|
|
irc.error('The reason you gave is longer than the allowed '
|
|
|
|
'length for a KICK reason on this server.')
|
|
|
|
return
|
|
|
|
irc.queueMsg(ircmsgs.kick(channel, nick, reason))
|
2004-09-30 07:25:38 +02:00
|
|
|
irc.noReply()
|
2004-10-02 04:36:10 +02:00
|
|
|
kick = wrap(kick, [('checkChannelCapability', 'op'),
|
|
|
|
('haveOp', 'kick someone'), 'nick', '?anything'])
|
2004-09-28 09:10:27 +02:00
|
|
|
|
|
|
|
def kban(self, irc, msg, args,
|
|
|
|
optlist, channel, bannedNick, length, reason):
|
2004-04-30 09:44:48 +02:00
|
|
|
"""[<channel>] [--{exact,nick,user,host}] <nick> [<seconds>] [<reason>]
|
2003-03-27 07:28:13 +01:00
|
|
|
|
2004-02-17 14:28:40 +01:00
|
|
|
If you have the #channel,op capability, this will kickban <nick> for
|
2003-11-19 09:13:19 +01:00
|
|
|
as many seconds as you specify, or else (if you specify 0 seconds or
|
|
|
|
don't specify a number of seconds) it will ban the person indefinitely.
|
2004-01-01 21:17:55 +01:00
|
|
|
--exact bans only the exact hostmask; --nick bans just the nick;
|
|
|
|
--user bans just the user, and --host bans just the host. You can
|
2004-04-30 09:44:48 +02:00
|
|
|
combine these options as you choose. <reason> is a reason to give for
|
|
|
|
the kick.
|
2003-11-19 09:13:19 +01:00
|
|
|
<channel> is only necessary if the message isn't sent in the channel
|
|
|
|
itself.
|
2003-03-27 07:28:13 +01:00
|
|
|
"""
|
2003-12-04 09:12:09 +01:00
|
|
|
# Check that they're not trying to make us kickban ourself.
|
2004-09-28 09:10:27 +02:00
|
|
|
self.log.debug('In kban')
|
2004-01-01 21:17:55 +01:00
|
|
|
if not ircutils.isNick(bannedNick):
|
|
|
|
self.log.warning('%r tried to kban a non nick: %r',
|
|
|
|
msg.prefix, bannedNick)
|
|
|
|
raise callbacks.ArgumentError
|
|
|
|
elif bannedNick == irc.nick:
|
2003-12-04 09:12:09 +01:00
|
|
|
self.log.warning('%r tried to make me kban myself.', msg.prefix)
|
2004-01-08 04:12:14 +01:00
|
|
|
irc.error('I cowardly refuse to kickban myself.')
|
2003-11-13 20:35:24 +01:00
|
|
|
return
|
2004-04-30 09:44:48 +02:00
|
|
|
if not reason:
|
|
|
|
reason = msg.nick
|
2003-11-13 20:01:40 +01:00
|
|
|
try:
|
|
|
|
bannedHostmask = irc.state.nickToHostmask(bannedNick)
|
|
|
|
except KeyError:
|
2004-10-02 04:36:10 +02:00
|
|
|
irc.error('I haven\'t seen %s.' % bannedNick, Raise=True)
|
2003-03-27 07:28:13 +01:00
|
|
|
capability = ircdb.makeChannelCapability(channel, 'op')
|
2004-01-01 21:17:55 +01:00
|
|
|
if optlist:
|
|
|
|
(nick, user, host) = ircutils.splitHostmask(bannedHostmask)
|
2004-07-23 06:07:50 +02:00
|
|
|
self.log.debug('*** nick: %s' % nick)
|
|
|
|
self.log.debug('*** user: %s' % user)
|
|
|
|
self.log.debug('*** host: %s' % host)
|
2004-01-01 21:17:55 +01:00
|
|
|
bnick = '*'
|
|
|
|
buser = '*'
|
|
|
|
bhost = '*'
|
|
|
|
for (option, _) in optlist:
|
2004-09-23 18:13:00 +02:00
|
|
|
if option == 'nick':
|
2004-01-01 21:17:55 +01:00
|
|
|
bnick = nick
|
2004-09-23 18:13:00 +02:00
|
|
|
elif option == 'user':
|
2004-01-01 21:17:55 +01:00
|
|
|
buser = user
|
2004-09-23 18:13:00 +02:00
|
|
|
elif option == 'host':
|
2004-01-01 21:17:55 +01:00
|
|
|
bhost = host
|
2004-09-23 18:13:00 +02:00
|
|
|
elif option == 'exact':
|
2004-01-01 21:17:55 +01:00
|
|
|
(bnick, buser, bhost) = \
|
|
|
|
ircutils.splitHostmask(bannedHostmask)
|
|
|
|
banmask = ircutils.joinHostmask(bnick, buser, bhost)
|
|
|
|
else:
|
|
|
|
banmask = ircutils.banmask(bannedHostmask)
|
2003-12-04 09:12:09 +01:00
|
|
|
# Check (again) that they're not trying to make us kickban ourself.
|
2003-11-13 20:35:24 +01:00
|
|
|
if ircutils.hostmaskPatternEqual(banmask, irc.prefix):
|
2003-12-04 09:12:09 +01:00
|
|
|
if ircutils.hostmaskPatternEqual(banmask, irc.prefix):
|
|
|
|
self.log.warning('%r tried to make me kban myself.',msg.prefix)
|
2004-01-08 04:12:14 +01:00
|
|
|
irc.error('I cowardly refuse to ban myself.')
|
2003-12-04 09:12:09 +01:00
|
|
|
return
|
2003-09-25 09:52:03 +02:00
|
|
|
else:
|
2003-12-04 09:12:09 +01:00
|
|
|
banmask = bannedHostmask
|
|
|
|
# Now, let's actually get to it. Check to make sure they have
|
2004-02-17 07:51:07 +01:00
|
|
|
# #channel,op and the bannee doesn't have #channel,op; or that the
|
2003-12-04 09:12:09 +01:00
|
|
|
# bannee and the banner are both the same person.
|
|
|
|
def doBan():
|
2004-04-30 09:44:48 +02:00
|
|
|
if bannedNick in irc.state.channels[channel].ops:
|
|
|
|
irc.queueMsg(ircmsgs.deop(channel, bannedNick))
|
2003-12-04 09:12:09 +01:00
|
|
|
irc.queueMsg(ircmsgs.ban(channel, banmask))
|
2004-04-30 09:44:48 +02:00
|
|
|
irc.queueMsg(ircmsgs.kick(channel, bannedNick, reason))
|
2003-12-04 09:12:09 +01:00
|
|
|
if length > 0:
|
|
|
|
def f():
|
|
|
|
irc.queueMsg(ircmsgs.unban(channel, banmask))
|
|
|
|
schedule.addEvent(f, time.time() + length)
|
|
|
|
if bannedNick == msg.nick:
|
2004-09-28 09:10:27 +02:00
|
|
|
doBan()
|
2003-12-04 09:12:09 +01:00
|
|
|
elif ircdb.checkCapability(msg.prefix, capability):
|
|
|
|
if ircdb.checkCapability(bannedHostmask, capability):
|
2004-09-28 09:10:27 +02:00
|
|
|
self.log.warning('%s tried to ban %r, but both have %s',
|
2003-12-04 09:12:09 +01:00
|
|
|
msg.prefix, bannedHostmask, capability)
|
2004-01-08 04:12:14 +01:00
|
|
|
irc.error('%s has %s too, you can\'t ban him/her/it.' %
|
2004-02-09 19:23:21 +01:00
|
|
|
(bannedNick, capability))
|
2004-09-28 09:10:27 +02:00
|
|
|
else:
|
2003-12-04 09:12:09 +01:00
|
|
|
doBan()
|
2003-03-27 07:28:13 +01:00
|
|
|
else:
|
2003-12-04 09:12:09 +01:00
|
|
|
self.log.warning('%r attempted kban without %s',
|
|
|
|
msg.prefix, capability)
|
2004-01-08 16:24:56 +01:00
|
|
|
irc.errorNoCapability(capability)
|
2004-09-23 18:13:00 +02:00
|
|
|
exact,nick,user,host
|
2004-10-02 04:36:10 +02:00
|
|
|
kban = wrap(kban,
|
|
|
|
[('checkChannelCapability', 'op'),
|
|
|
|
('haveOp', 'kick or ban someone'),
|
|
|
|
'nick', ('expiry?', 0), '?anything'],
|
|
|
|
getopts={'exact': None,
|
|
|
|
'nick': None,
|
|
|
|
'user': None,
|
|
|
|
'host': None})
|
2004-09-28 09:10:27 +02:00
|
|
|
|
2004-09-23 18:13:00 +02:00
|
|
|
def unban(self, irc, msg, args, channel, hostmask):
|
2003-10-15 06:46:19 +02:00
|
|
|
"""[<channel>] <hostmask>
|
|
|
|
|
|
|
|
Unbans <hostmask> on <channel>. Especially useful for unbanning
|
|
|
|
yourself when you get unexpectedly (or accidentally) banned from
|
|
|
|
the channel. <channel> is only necessary if the message isn't sent
|
|
|
|
in the channel itself.
|
|
|
|
"""
|
2004-09-28 09:10:27 +02:00
|
|
|
irc.queueMsg(ircmsgs.unban(channel, hostmask))
|
2004-10-02 04:36:10 +02:00
|
|
|
unban = wrap(unban, [('checkChannelCapability', 'op'),
|
|
|
|
('haveOp', 'unban someone'), 'hostmask'])
|
2004-06-19 04:06:44 +02:00
|
|
|
|
2004-09-23 18:13:00 +02:00
|
|
|
def invite(self, irc, msg, args, channel, nick):
|
2004-02-17 14:28:40 +01:00
|
|
|
"""[<channel>] <nick>
|
2004-06-19 04:06:44 +02:00
|
|
|
|
2004-02-17 14:28:40 +01:00
|
|
|
If you have the #channel,op capability, this will invite <nick>
|
|
|
|
to join <channel>. <channel> is only necessary if the message isn't
|
|
|
|
sent in the channel itself.
|
|
|
|
"""
|
2004-09-28 09:10:27 +02:00
|
|
|
irc.queueMsg(ircmsgs.invite(nick, channel))
|
2004-10-02 04:36:10 +02:00
|
|
|
invite = wrap(invite, [('checkChannelCapability', 'op'),
|
|
|
|
('haveOp', 'invite someone'), 'nick'])
|
2003-10-15 06:46:19 +02:00
|
|
|
|
2003-09-29 07:01:41 +02:00
|
|
|
def lobotomize(self, irc, msg, args, channel):
|
2003-03-27 07:28:13 +01:00
|
|
|
"""[<channel>]
|
|
|
|
|
2004-02-17 14:28:40 +01:00
|
|
|
If you have the #channel,op capability, this will "lobotomize" the
|
2003-11-19 09:13:19 +01:00
|
|
|
bot, making it silent and unanswering to all requests made in the
|
|
|
|
channel. <channel> is only necessary if the message isn't sent in the
|
|
|
|
channel itself.
|
2003-03-27 07:28:13 +01:00
|
|
|
"""
|
2003-12-09 05:49:39 +01:00
|
|
|
c = ircdb.channels.getChannel(channel)
|
|
|
|
c.lobotomized = True
|
|
|
|
ircdb.channels.setChannel(channel, c)
|
2004-01-08 04:12:14 +01:00
|
|
|
irc.replySuccess()
|
2004-10-02 04:36:10 +02:00
|
|
|
lobotomize = wrap(lobotomize, [('checkChannelCapability', 'op')])
|
2003-03-27 07:28:13 +01:00
|
|
|
|
2003-09-29 07:01:41 +02:00
|
|
|
def unlobotomize(self, irc, msg, args, channel):
|
2003-03-27 07:28:13 +01:00
|
|
|
"""[<channel>]
|
|
|
|
|
2004-02-17 14:28:40 +01:00
|
|
|
If you have the #channel,op capability, this will unlobotomize the bot,
|
2003-11-19 09:13:19 +01:00
|
|
|
making it respond to requests made in the channel again.
|
|
|
|
<channel> is only necessary if the message isn't sent in the channel
|
|
|
|
itself.
|
2003-03-27 07:28:13 +01:00
|
|
|
"""
|
2003-12-09 05:49:39 +01:00
|
|
|
c = ircdb.channels.getChannel(channel)
|
|
|
|
c.lobotomized = False
|
|
|
|
ircdb.channels.setChannel(channel, c)
|
2004-01-08 04:12:14 +01:00
|
|
|
irc.replySuccess()
|
2004-10-02 04:36:10 +02:00
|
|
|
unlobotomize = wrap(unlobotomize, [('checkChannelCapability', 'op')])
|
2003-03-27 07:28:13 +01:00
|
|
|
|
2004-09-23 18:13:00 +02:00
|
|
|
def permban(self, irc, msg, args, channel, banmask, expires):
|
2004-09-09 01:34:48 +02:00
|
|
|
"""[<channel>] <nick|hostmask> [<expires>]
|
2003-03-27 07:28:13 +01:00
|
|
|
|
2004-02-17 14:28:40 +01:00
|
|
|
If you have the #channel,op capability, this will effect a permanent
|
2004-06-19 02:42:52 +02:00
|
|
|
(persistent) ban from interacting with the bot on the given <hostmask>
|
2004-09-09 01:34:48 +02:00
|
|
|
(or the current hostmask associated with <nick>. Other plugins may
|
|
|
|
enforce this ban by actually banning users with matching hostmasks when
|
|
|
|
they join. <expires> is an optional argument specifying when (in
|
|
|
|
"seconds from now") the ban should expire; if none is given, the ban
|
|
|
|
will never automatically expire. <channel> is only necessary if the
|
|
|
|
message isn't sent in the channel itself.
|
2003-03-27 07:28:13 +01:00
|
|
|
"""
|
2003-09-29 07:01:41 +02:00
|
|
|
c = ircdb.channels.getChannel(channel)
|
2004-09-09 01:34:48 +02:00
|
|
|
c.addBan(banmask, expires)
|
2003-09-29 07:01:41 +02:00
|
|
|
ircdb.channels.setChannel(channel, c)
|
2004-01-08 04:12:14 +01:00
|
|
|
irc.replySuccess()
|
2004-10-02 04:36:10 +02:00
|
|
|
permban = wrap(permban, [('checkChannelCapability', 'op'),
|
|
|
|
'hostmask', ('?expiry', 0)])
|
2003-03-27 07:28:13 +01:00
|
|
|
|
2004-09-23 18:13:00 +02:00
|
|
|
def unpermban(self, irc, msg, args, channel, banmask):
|
2003-03-27 07:28:13 +01:00
|
|
|
"""[<channel>] <hostmask>
|
|
|
|
|
2004-02-17 14:28:40 +01:00
|
|
|
If you have the #channel,op capability, this will remove the permanent
|
2003-11-19 09:13:19 +01:00
|
|
|
ban on <hostmask>. <channel> is only necessary if the message isn't
|
|
|
|
sent in the channel itself.
|
2003-03-27 07:28:13 +01:00
|
|
|
"""
|
2003-09-29 07:01:41 +02:00
|
|
|
c = ircdb.channels.getChannel(channel)
|
|
|
|
c.removeBan(banmask)
|
|
|
|
ircdb.channels.setChannel(channel, c)
|
2004-01-08 04:12:14 +01:00
|
|
|
irc.replySuccess()
|
2004-10-02 04:36:10 +02:00
|
|
|
unpermban = wrap(unpermban, [('checkChannelCapability', 'op'), 'hostmask'])
|
2003-03-27 07:28:13 +01:00
|
|
|
|
2004-08-26 16:28:37 +02:00
|
|
|
def permbans(self, irc, msg, args, channel):
|
2004-07-01 19:55:29 +02:00
|
|
|
"""[<channel>]
|
|
|
|
|
|
|
|
If you have the #channel,op capability, this will show you the
|
2004-08-05 06:34:19 +02:00
|
|
|
current bans on #channel.
|
2004-07-01 19:55:29 +02:00
|
|
|
"""
|
2004-09-09 01:34:48 +02:00
|
|
|
# XXX Add the expirations.
|
2004-07-01 19:55:29 +02:00
|
|
|
c = ircdb.channels.getChannel(channel)
|
|
|
|
if c.bans:
|
|
|
|
irc.reply(utils.commaAndify(map(utils.dqrepr, c.bans)))
|
|
|
|
else:
|
2004-08-05 06:34:19 +02:00
|
|
|
irc.reply('There are currently no permanent bans on %s' % channel)
|
2004-10-02 04:36:10 +02:00
|
|
|
permbans = wrap(permbans, [('checkChannelCapability', 'op')])
|
2004-07-01 19:55:29 +02:00
|
|
|
|
2004-09-23 18:13:00 +02:00
|
|
|
def ignore(self, irc, msg, args, channel, banmask, expires):
|
2004-09-09 01:34:48 +02:00
|
|
|
"""[<channel>] <nick|hostmask> [<expires>]
|
2003-03-27 07:28:13 +01:00
|
|
|
|
2004-02-17 14:28:40 +01:00
|
|
|
If you have the #channel,op capability, this will set a permanent
|
2003-11-19 09:13:19 +01:00
|
|
|
(persistent) ignore on <hostmask> or the hostmask currently associated
|
2004-09-09 01:34:48 +02:00
|
|
|
with <nick>. <expires> is an optional argument specifying when (in
|
|
|
|
"seconds from now") the ignore will expire; if it isn't given, the
|
|
|
|
ignore will never automatically expire. <channel> is only necessary
|
|
|
|
if the message isn't sent in the channel itself.
|
2003-03-27 07:28:13 +01:00
|
|
|
"""
|
2003-09-29 07:01:41 +02:00
|
|
|
c = ircdb.channels.getChannel(channel)
|
2004-09-09 01:34:48 +02:00
|
|
|
c.addIgnore(banmask, expires)
|
2003-09-29 07:01:41 +02:00
|
|
|
ircdb.channels.setChannel(channel, c)
|
2004-01-08 04:12:14 +01:00
|
|
|
irc.replySuccess()
|
2004-10-02 04:36:10 +02:00
|
|
|
ignore = wrap(ignore, [('checkChannelCapability', 'op'),
|
|
|
|
'hostmask', ('?expiry', 0)])
|
2003-03-27 07:28:13 +01:00
|
|
|
|
2004-09-23 18:13:00 +02:00
|
|
|
def unignore(self, irc, msg, args, channel, banmask):
|
2003-03-27 07:28:13 +01:00
|
|
|
"""[<channel>] <hostmask>
|
|
|
|
|
2004-02-17 14:28:40 +01:00
|
|
|
If you have the #channel,op capability, this will remove the permanent
|
2003-11-19 09:13:19 +01:00
|
|
|
ignore on <hostmask> in the channel. <channel> is only necessary if the
|
|
|
|
message isn't sent in the channel itself.
|
2003-03-27 07:28:13 +01:00
|
|
|
"""
|
2003-09-29 07:01:41 +02:00
|
|
|
c = ircdb.channels.getChannel(channel)
|
|
|
|
c.removeIgnore(banmask)
|
|
|
|
ircdb.channels.setChannel(channel, c)
|
2004-01-08 04:12:14 +01:00
|
|
|
irc.replySuccess()
|
2004-10-02 04:36:10 +02:00
|
|
|
unignore = wrap(unignore, [('checkChannelCapability', 'op'), 'hostmask'])
|
2003-03-27 07:28:13 +01:00
|
|
|
|
2003-11-09 15:11:15 +01:00
|
|
|
def ignores(self, irc, msg, args, channel):
|
2003-11-05 18:22:38 +01:00
|
|
|
"""[<channel>]
|
|
|
|
|
|
|
|
Lists the hostmasks that the bot is ignoring on the given channel.
|
2003-11-19 09:13:19 +01:00
|
|
|
<channel> is only necessary if the message isn't sent in the channel
|
|
|
|
itself.
|
2003-11-05 18:22:38 +01:00
|
|
|
"""
|
2004-09-09 01:34:48 +02:00
|
|
|
# XXX Add the expirations.
|
2003-11-05 18:22:38 +01:00
|
|
|
c = ircdb.channels.getChannel(channel)
|
|
|
|
if len(c.ignores) == 0:
|
2003-12-04 08:18:10 +01:00
|
|
|
s = 'I\'m not currently ignoring any hostmasks in %r' % channel
|
2004-01-08 04:12:14 +01:00
|
|
|
irc.reply(s)
|
2003-12-04 08:18:10 +01:00
|
|
|
else:
|
2004-04-20 12:11:27 +02:00
|
|
|
L = sorted(c.ignores)
|
2004-01-08 04:12:14 +01:00
|
|
|
irc.reply(utils.commaAndify(imap(repr, L)))
|
2004-10-02 04:36:10 +02:00
|
|
|
ignores = wrap(ignores, [('checkChannelCapability', 'op')])
|
2003-11-05 18:22:38 +01:00
|
|
|
|
2004-09-23 18:13:00 +02:00
|
|
|
def addcapability(self, irc, msg, args, channel, hostmask, capabilities):
|
2004-09-20 03:33:44 +02:00
|
|
|
"""[<channel>] <name|hostmask> <capability> [<capability> ...]
|
2003-03-27 07:28:13 +01:00
|
|
|
|
2004-02-17 14:28:40 +01:00
|
|
|
If you have the #channel,op capability, this will give the user
|
2003-11-19 09:13:19 +01:00
|
|
|
currently identified as <name> (or the user to whom <hostmask> maps)
|
|
|
|
the capability <capability> in the channel. <channel> is only necessary
|
|
|
|
if the message isn't sent in the channel itself.
|
2003-03-27 07:28:13 +01:00
|
|
|
"""
|
2003-09-29 07:01:41 +02:00
|
|
|
try:
|
2004-09-23 18:13:00 +02:00
|
|
|
id = ircdb.users.getUserId(hostmask)
|
2003-09-29 07:01:41 +02:00
|
|
|
user = ircdb.users.getUser(id)
|
|
|
|
except KeyError:
|
2004-01-08 16:47:38 +01:00
|
|
|
irc.errorNoUser()
|
2004-09-23 18:13:00 +02:00
|
|
|
for c in capabilities.split():
|
2004-09-20 03:33:44 +02:00
|
|
|
c = ircdb.makeChannelCapability(channel, c)
|
|
|
|
user.addCapability(c)
|
|
|
|
ircdb.users.setUser(id, user)
|
|
|
|
irc.replySuccess()
|
2004-10-02 04:36:10 +02:00
|
|
|
addcapability = wrap(addcapability, [('checkChannelCapability', 'op'),
|
|
|
|
'hostmask', 'capability'])
|
2003-03-27 07:28:13 +01:00
|
|
|
|
2004-09-23 18:13:00 +02:00
|
|
|
def removecapability(self, irc, msg, args, channel, hostmask, capabilities):
|
2004-09-20 03:33:44 +02:00
|
|
|
"""[<channel>] <name|hostmask> <capability> [<capability> ...]
|
2003-03-27 07:28:13 +01:00
|
|
|
|
2004-02-17 14:28:40 +01:00
|
|
|
If you have the #channel,op capability, this will take from the user
|
2003-11-19 09:13:19 +01:00
|
|
|
currently identified as <name> (or the user to whom <hostmask> maps)
|
|
|
|
the capability <capability> in the channel. <channel> is only necessary
|
|
|
|
if the message isn't sent in the channel itself.
|
2003-03-27 07:28:13 +01:00
|
|
|
"""
|
2003-09-29 07:01:41 +02:00
|
|
|
try:
|
2004-09-23 18:13:00 +02:00
|
|
|
id = ircdb.users.getUserId(hostmask)
|
2003-09-29 07:01:41 +02:00
|
|
|
except KeyError:
|
2004-01-08 16:47:38 +01:00
|
|
|
irc.errorNoUser()
|
2004-08-05 20:45:09 +02:00
|
|
|
return
|
|
|
|
user = ircdb.users.getUser(id)
|
2004-09-20 03:33:44 +02:00
|
|
|
fail = []
|
|
|
|
for c in capabilities.split():
|
|
|
|
cap = ircdb.makeChannelCapability(channel, c)
|
|
|
|
try:
|
|
|
|
user.removeCapability(cap)
|
|
|
|
except KeyError:
|
|
|
|
fail.append(c)
|
2004-08-05 20:45:09 +02:00
|
|
|
ircdb.users.setUser(id, user)
|
2004-09-20 03:33:44 +02:00
|
|
|
if fail:
|
|
|
|
irc.error('That user didn\'t have the %s %s.' %
|
|
|
|
(utils.commaAndify(fail),
|
|
|
|
utils.pluralize('capability', len(fail))), Raise=True)
|
2004-08-05 20:45:09 +02:00
|
|
|
irc.replySuccess()
|
2004-10-02 04:36:10 +02:00
|
|
|
removecapability = wrap(removecapability,
|
|
|
|
[('checkChannelCapability', 'op'),
|
|
|
|
'hostmask', 'capability'])
|
2004-09-28 09:10:27 +02:00
|
|
|
|
|
|
|
# XXX This needs to be fix0red to be like Owner.defaultcapability. Or
|
|
|
|
# something else. This is a horrible interface.
|
2004-09-23 18:13:00 +02:00
|
|
|
def setdefaultcapability(self, irc, msg, args, channel, v):
|
|
|
|
"""[<channel>] {True|False}
|
2003-03-27 07:28:13 +01:00
|
|
|
|
2004-02-17 14:28:40 +01:00
|
|
|
If you have the #channel,op capability, this will set the default
|
2003-11-19 09:13:19 +01:00
|
|
|
response to non-power-related (that is, not {op, halfop, voice}
|
|
|
|
capabilities to be the value you give. <channel> is only necessary if
|
|
|
|
the message isn't sent in the channel itself.
|
2003-03-27 07:28:13 +01:00
|
|
|
"""
|
2003-10-04 14:57:44 +02:00
|
|
|
c = ircdb.channels.getChannel(channel)
|
2004-09-23 18:13:00 +02:00
|
|
|
if v:
|
2003-09-29 07:01:41 +02:00
|
|
|
c.setDefaultCapability(True)
|
2003-03-27 07:28:13 +01:00
|
|
|
else:
|
2004-09-23 18:13:00 +02:00
|
|
|
c.setDefaultCapability(False)
|
2003-09-29 07:01:41 +02:00
|
|
|
ircdb.channels.setChannel(channel, c)
|
2004-01-08 04:12:14 +01:00
|
|
|
irc.replySuccess()
|
2004-10-02 04:36:10 +02:00
|
|
|
setdefaultcapability = wrap(setdefaultcapability,
|
|
|
|
[('checkChannelCapability', 'op'), 'boolean'])
|
2003-09-29 07:01:41 +02:00
|
|
|
|
2004-09-23 18:13:00 +02:00
|
|
|
def setcapability(self, irc, msg, args, channel, capabilities):
|
2004-09-20 03:33:44 +02:00
|
|
|
"""[<channel>] <capability> [<capability> ...]
|
2003-03-27 07:28:13 +01:00
|
|
|
|
2004-02-17 14:28:40 +01:00
|
|
|
If you have the #channel,op capability, this will add the channel
|
2003-11-19 09:13:19 +01:00
|
|
|
capability <capability> for all users in the channel. <channel> is
|
|
|
|
only necessary if the message isn't sent in the channel itself.
|
2003-03-27 07:28:13 +01:00
|
|
|
"""
|
2004-09-20 03:33:44 +02:00
|
|
|
chan = ircdb.channels.getChannel(channel)
|
2004-10-02 04:36:10 +02:00
|
|
|
for c in capabilities:
|
2004-09-20 03:33:44 +02:00
|
|
|
chan.addCapability(c)
|
|
|
|
ircdb.channels.setChannel(channel, chan)
|
2004-01-08 04:12:14 +01:00
|
|
|
irc.replySuccess()
|
2004-10-02 04:36:10 +02:00
|
|
|
setcapability = wrap(setcapability,
|
|
|
|
[('checkChannelCapability', 'op'), 'capability+'])
|
2003-03-27 07:28:13 +01:00
|
|
|
|
2004-09-23 18:13:00 +02:00
|
|
|
def unsetcapability(self, irc, msg, args, channel, capabilities):
|
2004-09-20 03:33:44 +02:00
|
|
|
"""[<channel>] <capability> [<capability> ...]
|
2003-03-27 07:28:13 +01:00
|
|
|
|
2004-02-17 14:28:40 +01:00
|
|
|
If you have the #channel,op capability, this will unset the channel
|
2003-11-19 09:13:19 +01:00
|
|
|
capability <capability> so each user's specific capability or the
|
|
|
|
channel default capability will take precedence. <channel> is only
|
|
|
|
necessary if the message isn't sent in the channel itself.
|
2003-03-27 07:28:13 +01:00
|
|
|
"""
|
2004-09-20 03:33:44 +02:00
|
|
|
chan = ircdb.channels.getChannel(channel)
|
|
|
|
fail = []
|
2004-10-02 04:36:10 +02:00
|
|
|
for c in capabilities:
|
2004-09-20 03:33:44 +02:00
|
|
|
try:
|
|
|
|
chan.removeCapability(c)
|
|
|
|
except KeyError:
|
|
|
|
fail.append(c)
|
|
|
|
ircdb.channels.setChannel(channel, chan)
|
|
|
|
if fail:
|
|
|
|
irc.error('I do not know about the %s %s.' %
|
|
|
|
(utils.commaAndify(fail),
|
|
|
|
utils.pluralize('capability', len(fail))), Raise=True)
|
|
|
|
irc.replySuccess()
|
2004-10-02 04:36:10 +02:00
|
|
|
unsetcapability = wrap(unsetcapability,
|
|
|
|
[('checkChannelCapability', 'op'), 'capability+'])
|
2003-03-27 07:28:13 +01:00
|
|
|
|
2004-09-23 18:13:00 +02:00
|
|
|
def capabilities(self, irc, msg, args, channel):
|
2003-04-02 13:08:34 +02:00
|
|
|
"""[<channel>]
|
|
|
|
|
2003-11-19 09:13:19 +01:00
|
|
|
Returns the capabilities present on the <channel>. <channel> is only
|
|
|
|
necessary if the message isn't sent in the channel itself.
|
2003-04-02 13:08:34 +02:00
|
|
|
"""
|
|
|
|
c = ircdb.channels.getChannel(channel)
|
2004-04-20 12:11:27 +02:00
|
|
|
L = sorted(c.capabilities)
|
2004-09-28 09:10:27 +02:00
|
|
|
irc.reply(' '.join(L))
|
2004-10-02 04:36:10 +02:00
|
|
|
capabilities = wrap(capabilities, ['channel'])
|
2003-04-02 13:08:34 +02:00
|
|
|
|
2003-12-03 02:28:31 +01:00
|
|
|
def lobotomies(self, irc, msg, args):
|
|
|
|
"""takes no arguments
|
|
|
|
|
|
|
|
Returns the channels in which this bot is lobotomized.
|
|
|
|
"""
|
|
|
|
L = []
|
|
|
|
for (channel, c) in ircdb.channels.iteritems():
|
|
|
|
if c.lobotomized:
|
|
|
|
L.append(channel)
|
|
|
|
if L:
|
2003-12-04 08:18:10 +01:00
|
|
|
L.sort()
|
2003-12-03 02:28:31 +01:00
|
|
|
s = 'I\'m currently lobotomized in %s.' % utils.commaAndify(L)
|
2004-01-08 04:12:14 +01:00
|
|
|
irc.reply(s)
|
2003-12-03 02:28:31 +01:00
|
|
|
else:
|
2004-01-08 04:12:14 +01:00
|
|
|
irc.reply('I\'m not currently lobotomized in any channels.')
|
2004-02-20 06:33:12 +01:00
|
|
|
|
2004-09-23 18:13:00 +02:00
|
|
|
def nicks(self, irc, msg, args, channel):
|
2004-02-20 06:33:12 +01:00
|
|
|
"""[<channel>]
|
|
|
|
|
|
|
|
Returns the nicks in <channel>. <channel> is only necessary if the
|
|
|
|
message isn't sent in the channel itself.
|
|
|
|
"""
|
|
|
|
L = list(irc.state.channels[channel].users)
|
|
|
|
utils.sortBy(str.lower, L)
|
|
|
|
irc.reply(utils.commaAndify(L))
|
2004-10-02 04:36:10 +02:00
|
|
|
nicks = wrap(nicks, ['channel'])
|
2004-06-19 04:06:44 +02:00
|
|
|
|
2004-09-11 18:23:56 +02:00
|
|
|
def alertOps(self, irc, channel, s, frm=None):
|
|
|
|
"""Internal message for notifying all the #channel,ops in a channel of
|
|
|
|
a given situation."""
|
|
|
|
capability = ircdb.makeChannelCapability(channel, 'op')
|
|
|
|
s = 'Alert to all %s ops: %s' % (channel, s)
|
|
|
|
if frm is not None:
|
|
|
|
s += ' (from %s)' % frm
|
|
|
|
for nick in irc.state.channels[channel].users:
|
|
|
|
hostmask = irc.state.nickToHostmask(nick)
|
|
|
|
if ircdb.checkCapability(hostmask, capability):
|
|
|
|
irc.reply(s, to=nick, private=True)
|
|
|
|
|
2004-09-28 09:10:27 +02:00
|
|
|
def alert(self, irc, msg, args, channel, text):
|
2004-09-11 18:23:56 +02:00
|
|
|
"""[<channel>] <text>
|
|
|
|
|
|
|
|
Sends <text> to all the users in <channel> who have the <channel>,op
|
|
|
|
capability.
|
|
|
|
"""
|
|
|
|
self.alertOps(irc, channel, text, frm=msg.nick)
|
2004-10-02 04:36:10 +02:00
|
|
|
alert = wrap(alert, [('checkChannelCapability', 'op'), 'text'])
|
2004-09-11 18:23:56 +02:00
|
|
|
|
2004-06-19 04:06:44 +02:00
|
|
|
|
2003-10-21 08:03:57 +02:00
|
|
|
Class = Channel
|
2003-03-27 07:28:13 +01:00
|
|
|
|
|
|
|
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|