2003-03-27 07:47:42 +01:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
###
|
|
|
|
# Copyright (c) 2002, Jeremiah Fincher
|
|
|
|
# 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
|
|
|
These are commands useful for administrating the bot; they all require their
|
|
|
|
caller to have the 'admin' capability. This plugin is loaded by default.
|
2003-03-27 07:47:42 +01:00
|
|
|
"""
|
|
|
|
|
2003-11-25 09:38:19 +01:00
|
|
|
__revision__ = "$Id$"
|
|
|
|
|
2003-10-05 14:47:19 +02:00
|
|
|
import fix
|
2003-10-02 02:26:57 +02:00
|
|
|
|
2003-10-04 14:54:42 +02:00
|
|
|
import time
|
2003-10-02 02:26:57 +02:00
|
|
|
import pprint
|
2003-03-27 07:47:42 +01:00
|
|
|
import string
|
2004-01-13 19:03:01 +01:00
|
|
|
import logging
|
2003-10-02 02:26:57 +02:00
|
|
|
import smtplib
|
2003-10-04 14:54:42 +02:00
|
|
|
import textwrap
|
2003-11-15 05:37:04 +01:00
|
|
|
from itertools import imap
|
2003-03-27 07:47:42 +01:00
|
|
|
|
2004-01-13 19:03:01 +01:00
|
|
|
import log
|
2003-03-27 07:47:42 +01:00
|
|
|
import conf
|
|
|
|
import ircdb
|
2003-11-09 15:34:23 +01:00
|
|
|
import utils
|
2003-03-27 07:47:42 +01:00
|
|
|
import ircmsgs
|
2003-11-09 15:34:23 +01:00
|
|
|
import ircutils
|
2003-03-27 07:47:42 +01:00
|
|
|
import privmsgs
|
|
|
|
import callbacks
|
|
|
|
|
2004-02-08 10:28:33 +01:00
|
|
|
|
2003-10-21 08:03:57 +02:00
|
|
|
class Admin(privmsgs.CapabilityCheckingPrivmsg):
|
2003-03-27 07:47:42 +01:00
|
|
|
capability = 'admin'
|
2003-12-10 08:29:01 +01:00
|
|
|
def __init__(self):
|
|
|
|
privmsgs.CapabilityCheckingPrivmsg.__init__(self)
|
|
|
|
self.joins = {}
|
2004-02-13 19:37:13 +01:00
|
|
|
self.pendingNickChanges = {}
|
2004-01-18 08:58:26 +01:00
|
|
|
|
|
|
|
def do376(self, irc, msg):
|
2004-02-11 07:27:35 +01:00
|
|
|
channels = list(conf.supybot.channels())
|
2004-01-21 18:13:04 +01:00
|
|
|
utils.sortBy(lambda s: ',' not in s, channels)
|
|
|
|
keys = []
|
|
|
|
chans = []
|
|
|
|
for channel in channels:
|
|
|
|
if ',' in channel:
|
|
|
|
(channel, key) = channel.split(',', 1)
|
|
|
|
chans.append(channel)
|
|
|
|
keys.append(key)
|
|
|
|
else:
|
|
|
|
chans.append(channel)
|
2004-02-10 01:12:51 +01:00
|
|
|
irc.queueMsg(ircmsgs.joins(chans, keys))
|
2004-01-18 08:58:26 +01:00
|
|
|
do422 = do377 = do376
|
2003-12-10 08:29:01 +01:00
|
|
|
|
|
|
|
def do471(self, irc, msg):
|
|
|
|
try:
|
|
|
|
channel = msg.args[1]
|
2004-02-10 05:01:05 +01:00
|
|
|
(irc, msg) = self.joins.pop(channel)
|
2004-01-08 04:12:14 +01:00
|
|
|
irc.error('Cannot join %s, it\'s full.' % channel)
|
2003-12-10 08:29:01 +01:00
|
|
|
except KeyError:
|
2004-01-06 04:32:21 +01:00
|
|
|
self.log.debug('Got 471 without Admin.join being called.')
|
2003-12-10 08:29:01 +01:00
|
|
|
|
|
|
|
def do473(self, irc, msg):
|
|
|
|
try:
|
|
|
|
channel = msg.args[1]
|
2004-02-10 05:01:05 +01:00
|
|
|
(irc, msg) = self.joins.pop(channel)
|
2004-01-08 04:12:14 +01:00
|
|
|
irc.error('Cannot join %s, I was not invited.' % channel)
|
2003-12-10 08:29:01 +01:00
|
|
|
except KeyError:
|
2004-01-06 04:32:21 +01:00
|
|
|
self.log.debug('Got 473 without Admin.join being called.')
|
2003-12-10 08:29:01 +01:00
|
|
|
|
|
|
|
def do474(self, irc, msg):
|
|
|
|
try:
|
|
|
|
channel = msg.args[1]
|
2004-02-10 05:01:05 +01:00
|
|
|
(irc, msg) = self.joins.pop(channel)
|
2004-01-08 04:12:14 +01:00
|
|
|
irc.error('Cannot join %s, it\'s banned me.' % channel)
|
2003-12-10 08:29:01 +01:00
|
|
|
except KeyError:
|
2004-01-06 04:32:21 +01:00
|
|
|
self.log.debug('Got 474 without Admin.join being called.')
|
2003-12-10 08:29:01 +01:00
|
|
|
|
|
|
|
def do475(self, irc, msg):
|
|
|
|
try:
|
|
|
|
channel = msg.args[1]
|
2004-02-10 05:01:05 +01:00
|
|
|
(irc, msg) = self.joins.pop(channel)
|
2004-01-08 04:12:14 +01:00
|
|
|
irc.error('Cannot join %s, my keyword was wrong.' % channel)
|
2003-12-10 08:29:01 +01:00
|
|
|
except KeyError:
|
2004-01-06 04:32:21 +01:00
|
|
|
self.log.debug('Got 475 without Admin.join being called.')
|
2003-12-10 08:29:01 +01:00
|
|
|
|
2004-02-10 05:01:05 +01:00
|
|
|
def do515(self, irc, msg):
|
|
|
|
try:
|
|
|
|
channel = msg.args[1]
|
|
|
|
(irc, msg) = self.joins.pop(channel)
|
|
|
|
irc.error('Cannot join %s, I\'m not identified with the nickserv.'
|
|
|
|
% channel)
|
|
|
|
except KeyError:
|
|
|
|
self.log.debug('Got 515 without Admin.join being called.')
|
|
|
|
|
2003-12-10 08:29:01 +01:00
|
|
|
def doJoin(self, irc, msg):
|
|
|
|
if msg.prefix == irc.prefix:
|
|
|
|
try:
|
|
|
|
del self.joins[msg.args[0]]
|
|
|
|
except KeyError:
|
|
|
|
s = 'Joined a channel without Admin.join being called'
|
2004-01-06 04:32:21 +01:00
|
|
|
self.log.debug(s)
|
|
|
|
|
|
|
|
def doInvite(self, irc, msg):
|
2004-02-10 04:23:50 +01:00
|
|
|
channel = msg.args[1]
|
|
|
|
if channel not in irc.state.channels:
|
|
|
|
if conf.supybot.alwaysJoinOnInvite() or \
|
|
|
|
ircdb.checkCapability(msg.prefix, 'admin'):
|
2004-02-21 10:56:27 +01:00
|
|
|
self.log.info('Invited to %s by %s', channel, msg.prefix)
|
2004-02-10 04:23:50 +01:00
|
|
|
irc.queueMsg(ircmsgs.join(channel))
|
2004-02-11 07:27:35 +01:00
|
|
|
conf.supybot.channels().add(channel)
|
2003-12-10 08:29:01 +01:00
|
|
|
|
2003-03-27 07:47:42 +01:00
|
|
|
def join(self, irc, msg, args):
|
2003-04-11 22:26:49 +02:00
|
|
|
"""<channel>[,<key>] [<channel>[,<key>] ...]
|
2003-03-27 07:47:42 +01:00
|
|
|
|
|
|
|
Tell the bot to join the whitespace-separated list of channels
|
2003-04-10 09:56:41 +02:00
|
|
|
you give it. If a channel requires a key, attach it behind the
|
|
|
|
channel name via a comma. I.e., if you need to join both #a and #b,
|
|
|
|
and #a requires a key of 'aRocks', then you'd call 'join #a,aRocks #b'
|
2003-03-27 07:47:42 +01:00
|
|
|
"""
|
2004-02-10 01:53:01 +01:00
|
|
|
if not args:
|
|
|
|
raise callbacks.ArgumentError
|
2003-04-10 09:56:41 +02:00
|
|
|
keys = []
|
|
|
|
channels = []
|
2003-04-11 09:10:21 +02:00
|
|
|
for channel in args:
|
2004-01-21 18:13:04 +01:00
|
|
|
original = channel
|
2003-04-11 22:26:49 +02:00
|
|
|
if ',' in channel:
|
|
|
|
(channel, key) = channel.split(',', 1)
|
2003-04-10 09:56:41 +02:00
|
|
|
channels.insert(0, channel)
|
|
|
|
keys.insert(0, key)
|
|
|
|
else:
|
|
|
|
channels.append(channel)
|
2004-01-19 23:20:48 +01:00
|
|
|
if not ircutils.isChannel(channel):
|
|
|
|
irc.error('%r is not a valid channel.' % channel)
|
|
|
|
return
|
2004-02-11 07:27:35 +01:00
|
|
|
conf.supybot.channels().add(original)
|
2003-04-10 09:56:41 +02:00
|
|
|
irc.queueMsg(ircmsgs.joins(channels, keys))
|
|
|
|
for channel in channels:
|
2003-12-10 08:29:01 +01:00
|
|
|
self.joins[channel] = (irc, msg)
|
2003-03-27 07:47:42 +01:00
|
|
|
|
2003-12-10 08:29:01 +01:00
|
|
|
def channels(self, irc, msg, args):
|
|
|
|
"""takes no arguments
|
|
|
|
|
|
|
|
Returns the channels the bot is on. Must be given in private, in order
|
|
|
|
to protect the secrecy of secret channels.
|
|
|
|
"""
|
|
|
|
if ircutils.isChannel(msg.args[0]):
|
2004-01-09 00:03:48 +01:00
|
|
|
irc.errorRequiresPrivacy()
|
2003-12-10 08:32:04 +01:00
|
|
|
return
|
2003-12-10 08:29:01 +01:00
|
|
|
L = irc.state.channels.keys()
|
|
|
|
if L:
|
|
|
|
utils.sortBy(ircutils.toLower, L)
|
2004-01-08 04:12:14 +01:00
|
|
|
irc.reply(utils.commaAndify(L))
|
2003-12-10 08:29:01 +01:00
|
|
|
else:
|
2004-01-08 04:12:14 +01:00
|
|
|
irc.reply('I\'m not currently in any channels.')
|
2003-12-10 08:29:01 +01:00
|
|
|
|
2004-02-13 19:37:13 +01:00
|
|
|
def do484(self, irc, msg):
|
|
|
|
irc = self.pendingNickChanges.get(irc, None)
|
|
|
|
if irc is not None:
|
|
|
|
irc.error('My connection is restricted, I can\'t change nicks.')
|
|
|
|
else:
|
|
|
|
self.log.debug('Got 484 without Admin.nick being called.')
|
|
|
|
|
|
|
|
def do433(self, irc, msg):
|
|
|
|
irc = self.pendingNickChanges.get(irc, None)
|
|
|
|
if irc is not None:
|
|
|
|
irc.error('Someone else is already using that nick.')
|
|
|
|
else:
|
|
|
|
self.log.debug('Got 433 without Admin.nick being called.')
|
|
|
|
|
|
|
|
def doNick(self, irc, msg):
|
|
|
|
if msg.nick == irc.nick or msg.args[0] == irc.nick:
|
|
|
|
del self.pendingNickChanges[irc]
|
|
|
|
|
2003-03-27 07:47:42 +01:00
|
|
|
def nick(self, irc, msg, args):
|
|
|
|
"""<nick>
|
|
|
|
|
|
|
|
Changes the bot's nick to <nick>."""
|
|
|
|
nick = privmsgs.getArgs(args)
|
2004-01-21 18:13:04 +01:00
|
|
|
if ircutils.isNick(nick):
|
|
|
|
conf.supybot.nick.setValue(nick)
|
|
|
|
irc.queueMsg(ircmsgs.nick(nick))
|
2004-02-13 19:37:13 +01:00
|
|
|
self.pendingNickChanges[irc.getRealIrc()] = irc
|
2004-01-21 18:13:04 +01:00
|
|
|
else:
|
|
|
|
irc.error('That\'s not a valid nick.')
|
2003-03-27 07:47:42 +01:00
|
|
|
|
|
|
|
def part(self, irc, msg, args):
|
|
|
|
"""<channel> [<channel> ...]
|
|
|
|
|
|
|
|
Tells the bot to part the whitespace-separated list of channels
|
|
|
|
you give it.
|
|
|
|
"""
|
2003-07-23 04:12:17 +02:00
|
|
|
if not args:
|
2004-02-10 01:53:01 +01:00
|
|
|
args = [msg.args[0]]
|
2003-09-05 20:47:58 +02:00
|
|
|
for arg in args:
|
|
|
|
if arg not in irc.state.channels:
|
2004-01-08 04:12:14 +01:00
|
|
|
irc.error('I\'m not currently in %s' % arg)
|
2003-09-05 20:47:58 +02:00
|
|
|
return
|
2004-01-21 18:13:04 +01:00
|
|
|
for arg in args:
|
2004-02-12 08:18:21 +01:00
|
|
|
L = []
|
2004-02-10 04:23:50 +01:00
|
|
|
for channelWithPass in conf.supybot.channels():
|
|
|
|
channel = channelWithPass.split(',')[0]
|
|
|
|
if arg == channel:
|
2004-02-12 08:18:21 +01:00
|
|
|
L.append(channelWithPass)
|
|
|
|
# This is necessary so the set doesn't change size while iterating.
|
|
|
|
for channel in L:
|
|
|
|
conf.supybot.channels().remove(channel)
|
2003-03-27 07:47:42 +01:00
|
|
|
irc.queueMsg(ircmsgs.parts(args, msg.nick))
|
2004-04-16 09:39:55 +02:00
|
|
|
inAtLeastOneChannel = False
|
|
|
|
for channel in args:
|
|
|
|
if msg.nick in irc.state.channels[arg].users:
|
|
|
|
inAtLeastOneChannel = True
|
|
|
|
if not inAtLeastOneChannel:
|
|
|
|
irc.replySuccess()
|
2003-03-27 07:47:42 +01:00
|
|
|
|
|
|
|
def disable(self, irc, msg, args):
|
|
|
|
"""<command>
|
|
|
|
|
|
|
|
Disables the command <command> for all non-owner users.
|
|
|
|
"""
|
|
|
|
command = privmsgs.getArgs(args)
|
|
|
|
if command in ('enable', 'identify'):
|
2004-01-08 04:12:14 +01:00
|
|
|
irc.error('You can\'t disable %s!' % command)
|
2003-03-27 07:47:42 +01:00
|
|
|
else:
|
2003-09-06 20:37:22 +02:00
|
|
|
try:
|
|
|
|
capability = ircdb.makeAntiCapability(command)
|
|
|
|
except ValueError:
|
2004-01-08 04:12:14 +01:00
|
|
|
irc.error('%r is not a valid command.' % command)
|
2003-09-06 20:37:22 +02:00
|
|
|
return
|
2004-01-18 08:58:26 +01:00
|
|
|
if command in conf.supybot.defaultCapabilities():
|
|
|
|
conf.supybot.defaultCapabilities().remove(command)
|
|
|
|
conf.supybot.defaultCapabilities().add(capability)
|
2004-01-08 04:12:14 +01:00
|
|
|
irc.replySuccess()
|
2003-03-27 07:47:42 +01:00
|
|
|
|
|
|
|
def enable(self, irc, msg, args):
|
|
|
|
"""<command>
|
|
|
|
|
|
|
|
Re-enables the command <command> for all non-owner users.
|
|
|
|
"""
|
|
|
|
command = privmsgs.getArgs(args)
|
2004-02-09 00:54:01 +01:00
|
|
|
command = command.lower()
|
|
|
|
L = []
|
|
|
|
for capability in conf.supybot.defaultCapabilities():
|
|
|
|
if ircdb.isAntiCapability(capability):
|
|
|
|
nonAntiCapability = ircdb.unAntiCapability(capability)
|
|
|
|
if nonAntiCapability.lower() == command:
|
|
|
|
L.append(capability)
|
|
|
|
if L:
|
|
|
|
for capability in L:
|
|
|
|
conf.supybot.defaultCapabilities().remove(capability)
|
2004-01-08 04:12:14 +01:00
|
|
|
irc.replySuccess()
|
2003-03-27 07:47:42 +01:00
|
|
|
else:
|
2004-01-08 04:12:14 +01:00
|
|
|
irc.error('That command wasn\'t disabled.')
|
2003-03-27 07:47:42 +01:00
|
|
|
|
|
|
|
def addcapability(self, irc, msg, args):
|
|
|
|
"""<name|hostmask> <capability>
|
|
|
|
|
|
|
|
Gives the user specified by <name> (or the user to whom <hostmask>
|
|
|
|
currently maps) the specified capability <capability>
|
|
|
|
"""
|
2003-11-25 17:07:29 +01:00
|
|
|
# Ok, the concepts that are important with capabilities:
|
|
|
|
#
|
|
|
|
### 1) No user should be able to elevate his privilege to owner.
|
|
|
|
### 2) Admin users are *not* superior to #channel.ops, and don't
|
|
|
|
### have God-like powers over channels.
|
|
|
|
### 3) We assume that Admin users are two things: non-malicious and
|
|
|
|
### and greedy for power. So they'll try to elevate their privilege
|
|
|
|
### to owner, but they won't try to crash the bot for no reason.
|
|
|
|
|
|
|
|
# Thus, the owner capability can't be given in the bot. Admin users
|
|
|
|
# can only give out capabilities they have themselves (which will
|
2004-01-18 08:58:26 +01:00
|
|
|
# depend on both conf.supybot.defaultAllow and
|
|
|
|
# conf.supybot.defaultCapabilities), but generally means they can't
|
|
|
|
# mess with channel capabilities.
|
2003-11-12 23:54:47 +01:00
|
|
|
(name, capability) = privmsgs.getArgs(args, required=2)
|
|
|
|
if capability == 'owner':
|
2004-01-18 08:58:26 +01:00
|
|
|
irc.error('The "owner" capability can\'t be added in the bot. '
|
|
|
|
'Use the supybot-adduser program (or edit the '
|
|
|
|
'users.conf file yourself) to add an owner capability.')
|
2003-11-12 23:54:47 +01:00
|
|
|
return
|
2003-03-27 07:47:42 +01:00
|
|
|
if ircdb.checkCapability(msg.prefix, capability) or \
|
2003-11-25 17:07:29 +01:00
|
|
|
'-' in capability:
|
2003-03-27 07:47:42 +01:00
|
|
|
try:
|
2003-09-12 22:06:58 +02:00
|
|
|
id = ircdb.users.getUserId(name)
|
|
|
|
user = ircdb.users.getUser(id)
|
|
|
|
user.addCapability(capability)
|
|
|
|
ircdb.users.setUser(id, user)
|
2004-01-08 04:12:14 +01:00
|
|
|
irc.replySuccess()
|
2003-03-27 07:47:42 +01:00
|
|
|
except KeyError:
|
2004-01-08 16:47:38 +01:00
|
|
|
irc.errorNoUser()
|
2003-03-27 07:47:42 +01:00
|
|
|
else:
|
|
|
|
s = 'You can\'t add capabilities you don\'t have.'
|
2004-01-08 04:12:14 +01:00
|
|
|
irc.error(s)
|
2003-03-27 07:47:42 +01:00
|
|
|
|
|
|
|
def removecapability(self, irc, msg, args):
|
|
|
|
"""<name|hostmask> <capability>
|
|
|
|
|
|
|
|
Takes from the user specified by <name> (or the uswer to whom
|
|
|
|
<hostmask> currently maps) the specified capability <capability>
|
|
|
|
"""
|
|
|
|
(name, capability) = privmsgs.getArgs(args, 2)
|
|
|
|
if ircdb.checkCapability(msg.prefix, capability) or \
|
2004-02-11 07:59:44 +01:00
|
|
|
ircdb.isAntiCapability(capability):
|
2003-03-27 07:47:42 +01:00
|
|
|
try:
|
2003-09-12 22:06:58 +02:00
|
|
|
id = ircdb.users.getUserId(name)
|
|
|
|
user = ircdb.users.getUser(id)
|
2003-09-23 19:05:53 +02:00
|
|
|
except KeyError:
|
2004-01-08 16:47:38 +01:00
|
|
|
irc.errorNoUser()
|
2003-09-23 19:05:53 +02:00
|
|
|
return
|
|
|
|
try:
|
2003-09-22 04:14:40 +02:00
|
|
|
user.removeCapability(capability)
|
2003-09-12 22:06:58 +02:00
|
|
|
ircdb.users.setUser(id, user)
|
2004-01-08 04:12:14 +01:00
|
|
|
irc.replySuccess()
|
2003-03-27 07:47:42 +01:00
|
|
|
except KeyError:
|
2004-01-08 04:12:14 +01:00
|
|
|
irc.error('That user doesn\'t have that capability.')
|
2003-09-23 19:05:53 +02:00
|
|
|
return
|
2003-03-27 07:47:42 +01:00
|
|
|
else:
|
|
|
|
s = 'You can\'t remove capabilities you don\'t have.'
|
2004-01-08 04:12:14 +01:00
|
|
|
irc.error(s)
|
2003-03-27 07:47:42 +01:00
|
|
|
|
2003-11-09 15:34:23 +01:00
|
|
|
def ignore(self, irc, msg, args):
|
|
|
|
"""<hostmask|nick>
|
|
|
|
|
|
|
|
Ignores <hostmask> or, if a nick is given, ignores whatever hostmask
|
|
|
|
that nick is currently using.
|
|
|
|
"""
|
|
|
|
arg = privmsgs.getArgs(args)
|
|
|
|
if ircutils.isUserHostmask(arg):
|
|
|
|
hostmask = arg
|
|
|
|
else:
|
|
|
|
try:
|
|
|
|
hostmask = irc.state.nickToHostmask(arg)
|
|
|
|
except KeyError:
|
2004-01-08 04:12:14 +01:00
|
|
|
irc.error('I can\'t find a hostmask for %s' % arg)
|
2003-11-09 15:34:23 +01:00
|
|
|
return
|
2004-02-04 01:39:52 +01:00
|
|
|
ircdb.ignores.addHostmask(hostmask)
|
2004-01-08 04:12:14 +01:00
|
|
|
irc.replySuccess()
|
2003-11-09 15:34:23 +01:00
|
|
|
|
|
|
|
def unignore(self, irc, msg, args):
|
|
|
|
"""<hostmask|nick>
|
|
|
|
|
|
|
|
Ignores <hostmask> or, if a nick is given, ignores whatever hostmask
|
|
|
|
that nick is currently using.
|
|
|
|
"""
|
|
|
|
arg = privmsgs.getArgs(args)
|
|
|
|
if ircutils.isUserHostmask(arg):
|
|
|
|
hostmask = arg
|
|
|
|
else:
|
|
|
|
try:
|
|
|
|
hostmask = irc.state.nickToHostmask(arg)
|
|
|
|
except KeyError:
|
2004-01-08 04:12:14 +01:00
|
|
|
irc.error('I can\'t find a hostmask for %s' % arg)
|
2003-11-09 15:34:23 +01:00
|
|
|
return
|
|
|
|
try:
|
2004-02-04 01:39:52 +01:00
|
|
|
ircdb.ignores.removeHostmask(hostmask)
|
2004-01-08 04:12:14 +01:00
|
|
|
irc.replySuccess()
|
2004-02-04 01:39:52 +01:00
|
|
|
except KeyError:
|
|
|
|
irc.error('%s wasn\'t in the ignores database.' % hostmask)
|
2003-11-09 15:34:23 +01:00
|
|
|
|
|
|
|
def ignores(self, irc, msg, args):
|
|
|
|
"""takes no arguments
|
|
|
|
|
|
|
|
Returns the hostmasks currently being globally ignored.
|
|
|
|
"""
|
2004-02-04 01:39:52 +01:00
|
|
|
if ircdb.ignores.hostmasks:
|
|
|
|
irc.reply(utils.commaAndify(imap(repr, ircdb.ignores.hostmasks)))
|
2003-11-09 15:34:23 +01:00
|
|
|
else:
|
2004-01-08 04:12:14 +01:00
|
|
|
irc.reply('I\'m not currently globally ignoring anyone.')
|
2003-11-09 15:34:23 +01:00
|
|
|
|
2003-10-17 18:39:05 +02:00
|
|
|
def reportbug(self, irc, msg, args):
|
2003-10-02 02:26:57 +02:00
|
|
|
"""<description>
|
|
|
|
|
|
|
|
Reports a bug to a private mailing list supybot-bugs. <description>
|
|
|
|
will be the subject of the email. The most recent 10 or so messages
|
|
|
|
the bot receives will be sent in the body of the email.
|
|
|
|
"""
|
|
|
|
description = privmsgs.getArgs(args)
|
|
|
|
messages = pprint.pformat(irc.state.history[-10:])
|
|
|
|
email = textwrap.dedent("""
|
|
|
|
Subject: %s
|
|
|
|
From: jemfinch@users.sourceforge.net
|
|
|
|
To: supybot-bugs@lists.sourceforge.net
|
|
|
|
Date: %s
|
|
|
|
|
|
|
|
Bug report for Supybot %s.
|
|
|
|
%s
|
|
|
|
""") % (description, time.ctime(), conf.version, messages)
|
|
|
|
email = email.strip()
|
|
|
|
email = email.replace('\n', '\r\n')
|
|
|
|
smtp = smtplib.SMTP('mail.sourceforge.net', 25)
|
|
|
|
smtp.sendmail('jemfinch@users.sf.net',
|
|
|
|
['supybot-bugs@lists.sourceforge.net'],
|
|
|
|
email)
|
|
|
|
smtp.quit()
|
2004-01-08 04:12:14 +01:00
|
|
|
irc.replySuccess()
|
2003-10-19 17:15:58 +02:00
|
|
|
reportbug = privmsgs.thread(reportbug)
|
2003-10-02 02:26:57 +02:00
|
|
|
|
2003-03-27 07:47:42 +01:00
|
|
|
|
2003-10-21 08:03:57 +02:00
|
|
|
Class = Admin
|
2003-03-27 07:47:42 +01:00
|
|
|
|
|
|
|
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|