2003-03-12 07:26:59 +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-03-26 09:39:50 +01:00
|
|
|
"""
|
|
|
|
Handles relaying between networks.
|
|
|
|
"""
|
|
|
|
|
2003-11-25 09:23:47 +01:00
|
|
|
__revision__ = "$Id$"
|
|
|
|
|
2003-10-05 14:56:56 +02:00
|
|
|
import plugins
|
2003-03-12 07:26:59 +01:00
|
|
|
|
2003-03-27 09:17:51 +01:00
|
|
|
import re
|
2003-10-22 07:15:19 +02:00
|
|
|
import sys
|
2004-02-04 09:19:28 +01:00
|
|
|
import copy
|
2003-06-22 18:17:33 +02:00
|
|
|
import time
|
2003-11-15 05:37:04 +01:00
|
|
|
from itertools import imap, ifilter
|
2003-03-27 09:17:51 +01:00
|
|
|
|
2003-04-20 01:51:11 +02:00
|
|
|
import conf
|
2003-06-22 18:17:33 +02:00
|
|
|
import utils
|
2003-10-29 09:38:15 +01:00
|
|
|
import world
|
2003-03-26 09:39:50 +01:00
|
|
|
import irclib
|
2003-04-20 02:10:53 +02:00
|
|
|
import drivers
|
2003-03-26 09:39:50 +01:00
|
|
|
import ircmsgs
|
|
|
|
import ircutils
|
2003-03-12 07:26:59 +01:00
|
|
|
import privmsgs
|
2004-01-30 05:54:15 +01:00
|
|
|
import registry
|
2003-03-12 07:26:59 +01:00
|
|
|
import callbacks
|
2003-03-26 09:39:50 +01:00
|
|
|
|
2004-01-30 00:58:27 +01:00
|
|
|
def configure(advanced):
|
2003-04-08 09:15:45 +02:00
|
|
|
import socket
|
2004-02-06 05:36:21 +01:00
|
|
|
from questions import output, expect, anything, something, yn
|
2004-01-28 23:19:25 +01:00
|
|
|
conf.registerPlugin('Relay', True)
|
2004-01-31 23:24:43 +01:00
|
|
|
startNetwork = anything('What is the name of the network you\'re '
|
2003-04-08 09:15:45 +02:00
|
|
|
'connecting to first?')
|
2003-10-21 06:09:48 +02:00
|
|
|
onStart.append('relay start %s' % startNetwork)
|
2004-01-31 23:24:43 +01:00
|
|
|
while yn('Do you want to connect to another network for relaying?'):
|
|
|
|
network = anything('What is the name of the network you want to '
|
2003-04-08 09:15:45 +02:00
|
|
|
'connect to?')
|
|
|
|
server = ''
|
|
|
|
while not server:
|
|
|
|
server = anything('What server does that network use?')
|
|
|
|
try:
|
2004-01-31 23:24:43 +01:00
|
|
|
output('Looking up %s' % server)
|
2003-04-08 09:15:45 +02:00
|
|
|
ip = socket.gethostbyname(server)
|
2004-01-31 23:24:43 +01:00
|
|
|
output('Found %s (%s)' % (server, ip))
|
2003-04-08 09:15:45 +02:00
|
|
|
except socket.error:
|
2004-01-31 23:24:43 +01:00
|
|
|
output('Sorry, but I couldn\'t find that server.')
|
2003-04-08 09:15:45 +02:00
|
|
|
server = ''
|
|
|
|
if yn('Does that server require you to connect on a port other than '
|
2004-01-31 23:24:43 +01:00
|
|
|
'the default port for IRC (6667)?', default=False):
|
2003-04-08 09:15:45 +02:00
|
|
|
port = ''
|
|
|
|
while not port:
|
|
|
|
port = anything('What port is that?')
|
|
|
|
try:
|
|
|
|
int(port)
|
|
|
|
except ValueError:
|
2004-01-31 23:24:43 +01:00
|
|
|
output('Sorry, but that isn\'t a valid port.')
|
2003-04-08 09:15:45 +02:00
|
|
|
port = ''
|
|
|
|
server = ':'.join((server, port))
|
2003-10-21 06:09:48 +02:00
|
|
|
onStart.append('relay connect %s %s' % (network, server))
|
2003-04-08 09:15:45 +02:00
|
|
|
channel = anything('What channel would you like to relay between?')
|
2003-10-22 11:14:49 +02:00
|
|
|
afterConnect.append('relay join %s' % utils.dqrepr(channel))
|
2004-01-31 23:24:43 +01:00
|
|
|
while yn('Would like to relay between any more channels?'):
|
2003-04-08 09:15:45 +02:00
|
|
|
channel = anything('What channel?')
|
2003-10-21 06:09:48 +02:00
|
|
|
afterConnect.append('relay join %s' % channel)
|
2004-01-31 23:24:43 +01:00
|
|
|
if yn('Would you like to use color to distinguish between nicks?'):
|
2003-10-21 06:09:48 +02:00
|
|
|
afterConnect.append('relay color 2')
|
2003-08-20 18:26:23 +02:00
|
|
|
|
2003-04-08 09:15:45 +02:00
|
|
|
|
2003-12-16 14:44:09 +01:00
|
|
|
ircs = ircutils.IrcDict()
|
2004-01-02 21:59:14 +01:00
|
|
|
lastmsg = {} # Not IrcDict. Doesn't map strings.
|
2003-12-02 14:39:30 +01:00
|
|
|
channels = ircutils.IrcSet()
|
2004-01-02 21:59:14 +01:00
|
|
|
ircstates = {} # Not IrcDict. Doesn't map strings.
|
|
|
|
abbreviations = {} # Not IrcDict. Doesn't map strings.
|
2003-12-02 14:39:30 +01:00
|
|
|
originalIrc = None
|
|
|
|
|
|
|
|
def reload(x=None):
|
|
|
|
global ircs, ircstates, lastmsg, channels, abbreviations, originalIrc
|
|
|
|
if x is None:
|
|
|
|
return (ircs, ircstates, lastmsg, channels, abbreviations, originalIrc)
|
|
|
|
else:
|
|
|
|
(ircs, ircstates, lastmsg, channels, abbreviations, originalIrc) = x
|
|
|
|
|
2004-01-30 05:54:15 +01:00
|
|
|
conf.registerPlugin('Relay')
|
|
|
|
conf.registerChannelValue(conf.supybot.plugins.Relay, 'color',
|
|
|
|
registry.Boolean(True, """Determines whether the bot will color relayed
|
|
|
|
PRIVMSGs so as to make the messages easier to read."""))
|
|
|
|
conf.registerChannelValue(conf.supybot.plugins.Relay, 'topicSync',
|
|
|
|
registry.Boolean(True, """Determines whether the bot will synchronize
|
|
|
|
topics between networks in the channels it relays."""))
|
2004-02-08 00:39:04 +01:00
|
|
|
|
|
|
|
class SpaceSeparatedSetOfChannels(registry.SeparatedListOf):
|
|
|
|
List = ircutils.IrcSet
|
|
|
|
Value = conf.ValidChannel
|
|
|
|
def splitter(self, s):
|
|
|
|
return s.split()
|
|
|
|
joiner = ' '.join
|
|
|
|
|
2004-02-07 23:43:45 +01:00
|
|
|
conf.registerGlobalValue(conf.supybot.plugins.Relay, 'channels',
|
2004-02-08 00:39:04 +01:00
|
|
|
SpaceSeparatedSetOfChannels([], """Determines which channels the bot
|
2004-02-07 23:43:45 +01:00
|
|
|
will relay in."""))
|
2004-02-06 05:36:21 +01:00
|
|
|
|
2004-01-30 05:54:15 +01:00
|
|
|
class Relay(callbacks.Privmsg):
|
2003-11-04 18:34:48 +01:00
|
|
|
noIgnore = True
|
2003-10-22 07:15:19 +02:00
|
|
|
priority = sys.maxint
|
2003-03-26 09:39:50 +01:00
|
|
|
def __init__(self):
|
|
|
|
callbacks.Privmsg.__init__(self)
|
2003-12-02 14:39:30 +01:00
|
|
|
self.ircs = ircs
|
2003-03-26 09:39:50 +01:00
|
|
|
self.started = False
|
2003-12-02 14:39:30 +01:00
|
|
|
self.ircstates = ircstates
|
|
|
|
self.lastmsg = lastmsg
|
2004-02-07 23:43:45 +01:00
|
|
|
self.channels = self.registryValue('channels')
|
2003-12-18 09:29:17 +01:00
|
|
|
self._whois = {}
|
2003-12-16 14:44:09 +01:00
|
|
|
self.abbreviations = abbreviations
|
2003-08-20 18:26:23 +02:00
|
|
|
|
2003-09-22 13:17:10 +02:00
|
|
|
def __call__(self, irc, msg):
|
2003-09-23 21:39:48 +02:00
|
|
|
if self.started:
|
|
|
|
try:
|
2003-12-17 14:16:42 +01:00
|
|
|
irc = self._getRealIrc(irc)
|
2003-09-23 21:39:48 +02:00
|
|
|
self.ircstates[irc].addMsg(irc, self.lastmsg[irc])
|
|
|
|
finally:
|
|
|
|
self.lastmsg[irc] = msg
|
|
|
|
callbacks.Privmsg.__call__(self, irc, msg)
|
2003-08-20 18:26:23 +02:00
|
|
|
|
2003-08-23 14:12:04 +02:00
|
|
|
def do376(self, irc, msg):
|
2004-02-07 23:43:45 +01:00
|
|
|
L = []
|
|
|
|
for channel in self.channels:
|
|
|
|
if channel not in irc.state.channels:
|
|
|
|
L.append(channel)
|
|
|
|
if L:
|
|
|
|
irc.queueMsg(ircmsgs.joins(L))
|
2003-12-16 14:44:09 +01:00
|
|
|
do377 = do422 = do376
|
2003-08-23 14:12:04 +02:00
|
|
|
|
2003-12-17 14:16:42 +01:00
|
|
|
def _getRealIrc(self, irc):
|
|
|
|
if isinstance(irc, irclib.Irc):
|
|
|
|
return irc
|
|
|
|
else:
|
|
|
|
return irc.getRealIrc()
|
|
|
|
|
2003-10-21 06:09:48 +02:00
|
|
|
def start(self, irc, msg, args):
|
2003-04-06 11:17:38 +02:00
|
|
|
"""<network abbreviation for current server>
|
|
|
|
|
|
|
|
This command is necessary to start the Relay plugin; the
|
|
|
|
<network abbreviation> is the abbreviation that the network the
|
|
|
|
bot is currently connected to should be shown as to other networks.
|
|
|
|
For instance, if the network abbreviation is 'oftc', then when
|
|
|
|
relaying messages from that network to other networks, the users
|
|
|
|
will show up as 'user@oftc'.
|
|
|
|
"""
|
2003-12-02 14:39:30 +01:00
|
|
|
global originalIrc
|
2003-12-17 14:16:42 +01:00
|
|
|
realIrc = self._getRealIrc(irc)
|
2003-12-02 14:39:30 +01:00
|
|
|
originalIrc = realIrc
|
2003-03-27 09:24:22 +01:00
|
|
|
abbreviation = privmsgs.getArgs(args)
|
|
|
|
self.ircs[abbreviation] = realIrc
|
|
|
|
self.abbreviations[realIrc] = abbreviation
|
2004-02-04 09:19:28 +01:00
|
|
|
self.ircstates[realIrc] = copy.copy(realIrc.state)
|
2003-09-05 20:53:09 +02:00
|
|
|
self.lastmsg[realIrc] = ircmsgs.ping('this is just a fake message')
|
2003-03-27 09:24:22 +01:00
|
|
|
self.started = True
|
2004-01-08 04:12:14 +01:00
|
|
|
irc.replySuccess()
|
2003-10-21 06:09:48 +02:00
|
|
|
start = privmsgs.checkCapability(start, 'owner')
|
2003-03-26 09:39:50 +01:00
|
|
|
|
2003-10-21 06:09:48 +02:00
|
|
|
def connect(self, irc, msg, args):
|
2003-04-06 11:17:38 +02:00
|
|
|
"""<network abbreviation> <domain:port> (port defaults to 6667)
|
2003-08-20 18:26:23 +02:00
|
|
|
|
2003-04-06 11:17:38 +02:00
|
|
|
Connects to another network at <domain:port>. The network
|
|
|
|
abbreviation <network abbreviation> is used when relaying messages from
|
|
|
|
that network to other networks.
|
|
|
|
"""
|
2003-09-23 20:59:22 +02:00
|
|
|
if not self.started:
|
2004-01-08 04:12:14 +01:00
|
|
|
irc.error('You must use the start command first.')
|
2003-09-23 20:59:22 +02:00
|
|
|
return
|
2003-11-11 14:20:06 +01:00
|
|
|
abbreviation, server = privmsgs.getArgs(args, required=2)
|
2003-12-17 14:16:42 +01:00
|
|
|
realIrc = self._getRealIrc(irc)
|
2003-03-27 09:24:22 +01:00
|
|
|
if ':' in server:
|
|
|
|
(server, port) = server.split(':')
|
|
|
|
port = int(port)
|
2003-03-26 09:39:50 +01:00
|
|
|
else:
|
2003-03-27 09:24:22 +01:00
|
|
|
port = 6667
|
2003-08-23 06:42:04 +02:00
|
|
|
newIrc = irclib.Irc(irc.nick, callbacks=realIrc.callbacks)
|
2003-08-26 18:40:31 +02:00
|
|
|
newIrc.state.history = realIrc.state.history
|
2003-04-20 01:51:11 +02:00
|
|
|
driver = drivers.newDriver((server, port), newIrc)
|
2003-04-20 02:00:37 +02:00
|
|
|
newIrc.driver = driver
|
2003-03-27 09:24:22 +01:00
|
|
|
self.ircs[abbreviation] = newIrc
|
|
|
|
self.abbreviations[newIrc] = abbreviation
|
2003-09-05 20:53:09 +02:00
|
|
|
self.ircstates[newIrc] = irclib.IrcState()
|
|
|
|
self.lastmsg[newIrc] = ircmsgs.ping('this is just a fake message')
|
2004-01-08 04:12:14 +01:00
|
|
|
irc.replySuccess()
|
2003-10-21 06:09:48 +02:00
|
|
|
connect = privmsgs.checkCapability(connect, 'owner')
|
2003-03-26 09:39:50 +01:00
|
|
|
|
2003-10-21 06:09:48 +02:00
|
|
|
def disconnect(self, irc, msg, args):
|
2003-04-06 11:17:38 +02:00
|
|
|
"""<network>
|
|
|
|
|
|
|
|
Disconnects and ceases to relay to and from the network represented by
|
|
|
|
the network abbreviation <network>.
|
|
|
|
"""
|
2003-09-23 20:59:22 +02:00
|
|
|
if not self.started:
|
2004-01-08 04:12:14 +01:00
|
|
|
irc.error('You must use the start command first.')
|
2003-09-23 20:59:22 +02:00
|
|
|
return
|
2003-03-27 09:24:22 +01:00
|
|
|
network = privmsgs.getArgs(args)
|
|
|
|
otherIrc = self.ircs[network]
|
2003-10-25 01:15:04 +02:00
|
|
|
otherIrc.driver.die()
|
|
|
|
world.ircs.remove(otherIrc)
|
2003-03-28 02:36:00 +01:00
|
|
|
del self.ircs[network]
|
2003-03-31 11:22:48 +02:00
|
|
|
del self.abbreviations[otherIrc]
|
2004-01-08 04:12:14 +01:00
|
|
|
irc.replySuccess()
|
2003-10-21 06:09:48 +02:00
|
|
|
disconnect = privmsgs.checkCapability(disconnect, 'owner')
|
2003-03-26 09:39:50 +01:00
|
|
|
|
2003-10-21 06:09:48 +02:00
|
|
|
def join(self, irc, msg, args):
|
2003-04-06 11:17:38 +02:00
|
|
|
"""<channel>
|
|
|
|
|
|
|
|
Starts relaying between the channel <channel> on all networks. If on a
|
|
|
|
network the bot isn't in <channel>, he'll join. This commands is
|
|
|
|
required even if the bot is in the channel on both networks; he won't
|
2003-10-21 06:09:48 +02:00
|
|
|
relay between those channels unless he's told to oin both
|
2003-04-06 11:17:38 +02:00
|
|
|
channels.
|
|
|
|
"""
|
2003-09-23 20:59:22 +02:00
|
|
|
if not self.started:
|
2004-01-08 04:12:14 +01:00
|
|
|
irc.error('You must use the start command first.')
|
2003-09-23 20:59:22 +02:00
|
|
|
return
|
2003-03-27 09:24:22 +01:00
|
|
|
channel = privmsgs.getArgs(args)
|
2003-10-30 05:06:46 +01:00
|
|
|
if not ircutils.isChannel(channel):
|
2004-01-08 04:12:14 +01:00
|
|
|
irc.error('%r is not a valid channel.' % channel)
|
2003-10-30 05:06:46 +01:00
|
|
|
return
|
2003-04-11 22:42:21 +02:00
|
|
|
self.channels.add(ircutils.toLower(channel))
|
2003-03-27 09:24:22 +01:00
|
|
|
for otherIrc in self.ircs.itervalues():
|
|
|
|
if channel not in otherIrc.state.channels:
|
|
|
|
otherIrc.queueMsg(ircmsgs.join(channel))
|
2004-01-08 04:12:14 +01:00
|
|
|
irc.replySuccess()
|
2003-10-21 06:09:48 +02:00
|
|
|
join = privmsgs.checkCapability(join, 'owner')
|
2003-03-26 09:39:50 +01:00
|
|
|
|
2003-10-21 06:09:48 +02:00
|
|
|
def part(self, irc, msg, args):
|
2003-04-06 11:17:38 +02:00
|
|
|
"""<channel>
|
|
|
|
|
|
|
|
Ceases relaying between the channel <channel> on all networks. The bot
|
|
|
|
will part from the channel on all networks in which it is on the
|
|
|
|
channel.
|
|
|
|
"""
|
2003-09-23 20:59:22 +02:00
|
|
|
if not self.started:
|
2004-01-08 04:12:14 +01:00
|
|
|
irc.error('You must use the start command first.')
|
2003-09-23 20:59:22 +02:00
|
|
|
return
|
2003-03-27 09:24:22 +01:00
|
|
|
channel = privmsgs.getArgs(args)
|
2003-10-30 05:06:46 +01:00
|
|
|
if not ircutils.isChannel(channel):
|
2004-01-08 04:12:14 +01:00
|
|
|
irc.error('%r is not a valid channel.' % channel)
|
2003-10-30 05:06:46 +01:00
|
|
|
return
|
2003-04-11 22:42:21 +02:00
|
|
|
self.channels.remove(ircutils.toLower(channel))
|
2003-03-27 09:24:22 +01:00
|
|
|
for otherIrc in self.ircs.itervalues():
|
|
|
|
if channel in otherIrc.state.channels:
|
|
|
|
otherIrc.queueMsg(ircmsgs.part(channel))
|
2004-01-08 04:12:14 +01:00
|
|
|
irc.replySuccess()
|
2003-10-21 06:09:48 +02:00
|
|
|
part = privmsgs.checkCapability(part, 'owner')
|
2003-03-26 09:39:50 +01:00
|
|
|
|
2003-12-16 14:44:09 +01:00
|
|
|
def command(self, irc, msg, args):
|
|
|
|
"""<network> <command> [<arg> ...]
|
|
|
|
|
|
|
|
Gives the bot <command> (with its associated <arg>s) on <network>.
|
|
|
|
"""
|
|
|
|
if not self.started:
|
2004-01-08 04:12:14 +01:00
|
|
|
irc.error('You must use the start command first.')
|
2003-12-16 14:44:09 +01:00
|
|
|
return
|
|
|
|
if len(args) < 2:
|
|
|
|
raise callbacks.ArgumentError
|
|
|
|
network = args.pop(0)
|
|
|
|
try:
|
|
|
|
otherIrc = self.ircs[network]
|
|
|
|
except KeyError:
|
2004-01-08 04:12:14 +01:00
|
|
|
irc.error('I\'m not currently on %s.' % network)
|
2003-12-16 14:45:37 +01:00
|
|
|
return
|
2003-12-16 14:44:09 +01:00
|
|
|
Owner = irc.getCallback('Owner')
|
|
|
|
Owner.disambiguate(irc, args)
|
|
|
|
self.Proxy(otherIrc, msg, args)
|
2004-01-08 04:12:14 +01:00
|
|
|
irc.replySuccess()
|
2003-12-16 14:44:09 +01:00
|
|
|
command = privmsgs.checkCapability(command, 'admin')
|
|
|
|
|
2003-10-21 06:09:48 +02:00
|
|
|
def say(self, irc, msg, args):
|
2003-08-07 10:20:23 +02:00
|
|
|
"""<network> [<channel>] <text>
|
|
|
|
|
|
|
|
Says <text> on <channel> (using the current channel if unspecified)
|
|
|
|
on <network>.
|
|
|
|
"""
|
2003-09-23 20:59:22 +02:00
|
|
|
if not self.started:
|
2004-01-08 04:12:14 +01:00
|
|
|
irc.error('You must use the start command first.')
|
2003-09-23 20:59:22 +02:00
|
|
|
return
|
2003-08-07 10:20:23 +02:00
|
|
|
if not args:
|
2003-10-21 06:09:48 +02:00
|
|
|
raise callbacks.ArgumentError
|
2003-08-07 10:20:23 +02:00
|
|
|
network = args.pop(0)
|
|
|
|
channel = privmsgs.getChannel(msg, args)
|
|
|
|
text = privmsgs.getArgs(args)
|
|
|
|
if network not in self.ircs:
|
2004-01-08 04:12:14 +01:00
|
|
|
irc.error('I\'m not currently on %s.' % network)
|
2003-08-07 10:20:23 +02:00
|
|
|
return
|
|
|
|
if channel not in self.channels:
|
2004-01-08 04:12:14 +01:00
|
|
|
irc.error('I\'m not currently relaying to %s.' % channel)
|
2003-08-07 10:20:23 +02:00
|
|
|
return
|
|
|
|
self.ircs[network].queueMsg(ircmsgs.privmsg(channel, text))
|
2003-10-21 06:09:48 +02:00
|
|
|
say = privmsgs.checkCapability(say, 'admin')
|
2003-08-07 10:20:23 +02:00
|
|
|
|
2003-10-21 06:09:48 +02:00
|
|
|
def names(self, irc, msg, args):
|
2003-04-06 11:17:38 +02:00
|
|
|
"""[<channel>] (only if not sent in the channel itself.)
|
|
|
|
|
|
|
|
The <channel> argument is only necessary if the message isn't sent on
|
|
|
|
the channel itself. Returns the nicks of the people in the channel on
|
|
|
|
the various networks the bot is connected to.
|
|
|
|
"""
|
2003-09-23 20:59:22 +02:00
|
|
|
if not self.started:
|
2004-01-08 04:12:14 +01:00
|
|
|
irc.error('You must use the start command first.')
|
2003-09-23 20:59:22 +02:00
|
|
|
return
|
2003-12-17 14:16:42 +01:00
|
|
|
realIrc = self._getRealIrc(irc)
|
2003-03-27 22:14:28 +01:00
|
|
|
channel = privmsgs.getChannel(msg, args)
|
|
|
|
if channel not in self.channels:
|
2004-01-08 04:12:14 +01:00
|
|
|
irc.error('I\'m not relaying %s.' % channel)
|
2003-03-27 22:14:28 +01:00
|
|
|
return
|
|
|
|
users = []
|
|
|
|
for (abbreviation, otherIrc) in self.ircs.iteritems():
|
2003-11-07 15:54:48 +01:00
|
|
|
ops = []
|
|
|
|
halfops = []
|
|
|
|
voices = []
|
|
|
|
usersS = []
|
2003-03-27 22:28:15 +01:00
|
|
|
if abbreviation != self.abbreviations[realIrc]:
|
2003-11-11 12:37:17 +01:00
|
|
|
try:
|
|
|
|
Channel = otherIrc.state.channels[channel]
|
|
|
|
except KeyError:
|
2003-11-11 13:11:13 +01:00
|
|
|
s = 'Somehow I\'m not in %s on %s.'% (channel,abbreviation)
|
2004-01-08 04:12:14 +01:00
|
|
|
irc.error(s)
|
2003-11-11 12:37:17 +01:00
|
|
|
return
|
2003-11-28 19:22:41 +01:00
|
|
|
numUsers = 0
|
2003-11-07 15:54:48 +01:00
|
|
|
for s in Channel.users:
|
|
|
|
s = s.strip()
|
|
|
|
if not s:
|
|
|
|
continue
|
2003-11-28 19:22:41 +01:00
|
|
|
numUsers += 1
|
2003-12-01 13:03:23 +01:00
|
|
|
if s in Channel.ops:
|
2003-11-07 15:54:48 +01:00
|
|
|
ops.append('@%s' % s)
|
|
|
|
elif s in Channel.halfops:
|
|
|
|
halfops.append('%%%s' % s)
|
|
|
|
elif s in Channel.voices:
|
|
|
|
voices.append('+%s' % s)
|
|
|
|
else:
|
|
|
|
usersS.append(s)
|
2003-11-21 12:45:43 +01:00
|
|
|
utils.sortBy(ircutils.toLower, ops)
|
|
|
|
utils.sortBy(ircutils.toLower, voices)
|
|
|
|
utils.sortBy(ircutils.toLower, halfops)
|
|
|
|
utils.sortBy(ircutils.toLower, usersS)
|
2003-11-15 05:37:04 +01:00
|
|
|
usersS = ', '.join(ifilter(None, imap(', '.join,
|
|
|
|
(ops,halfops,voices,usersS))))
|
2003-11-28 19:22:41 +01:00
|
|
|
users.append('%s (%s): %s' %
|
|
|
|
(ircutils.bold(abbreviation), numUsers, usersS))
|
|
|
|
users.sort()
|
2004-01-08 04:12:14 +01:00
|
|
|
irc.reply('; '.join(users))
|
2003-06-22 18:17:33 +02:00
|
|
|
|
2003-10-21 06:09:48 +02:00
|
|
|
def whois(self, irc, msg, args):
|
2003-06-22 18:17:33 +02:00
|
|
|
"""<nick>@<network>
|
|
|
|
|
|
|
|
Returns the WHOIS response <network> gives for <nick>.
|
|
|
|
"""
|
2003-09-23 20:59:22 +02:00
|
|
|
if not self.started:
|
2004-01-08 04:12:14 +01:00
|
|
|
irc.error('You must use the start command first.')
|
2003-09-23 20:59:22 +02:00
|
|
|
return
|
2003-06-22 18:17:33 +02:00
|
|
|
nickAtNetwork = privmsgs.getArgs(args)
|
2003-12-17 14:16:42 +01:00
|
|
|
realIrc = self._getRealIrc(irc)
|
2003-08-12 10:48:16 +02:00
|
|
|
try:
|
|
|
|
(nick, network) = nickAtNetwork.split('@', 1)
|
2003-09-29 07:34:02 +02:00
|
|
|
if not ircutils.isNick(nick):
|
2004-01-08 04:12:14 +01:00
|
|
|
irc.error('%s is not an IRC nick.' % nick)
|
2003-09-29 07:34:02 +02:00
|
|
|
return
|
2003-08-23 14:12:04 +02:00
|
|
|
nick = ircutils.toLower(nick)
|
2003-08-12 10:48:16 +02:00
|
|
|
except ValueError:
|
2003-08-25 08:48:28 +02:00
|
|
|
if len(self.abbreviations) == 2:
|
|
|
|
# If there are only two networks being relayed, we can safely
|
|
|
|
# pick the *other* one.
|
|
|
|
nick = ircutils.toLower(nickAtNetwork)
|
|
|
|
for (keyIrc, net) in self.abbreviations.iteritems():
|
|
|
|
if keyIrc != realIrc:
|
|
|
|
network = net
|
|
|
|
else:
|
|
|
|
raise callbacks.ArgumentError
|
2003-06-22 18:17:33 +02:00
|
|
|
if network not in self.ircs:
|
2004-01-08 04:12:14 +01:00
|
|
|
irc.error('I\'m not on that network.')
|
2003-06-22 18:17:33 +02:00
|
|
|
return
|
|
|
|
otherIrc = self.ircs[network]
|
2003-08-21 18:31:37 +02:00
|
|
|
otherIrc.queueMsg(ircmsgs.whois(nick, nick))
|
2003-10-21 09:19:53 +02:00
|
|
|
self._whois[(otherIrc, nick)] = (irc, msg, {})
|
2003-06-22 18:17:33 +02:00
|
|
|
|
|
|
|
def do311(self, irc, msg):
|
2003-12-17 14:16:42 +01:00
|
|
|
irc = self._getRealIrc(irc)
|
2003-08-23 14:12:04 +02:00
|
|
|
nick = ircutils.toLower(msg.args[1])
|
2003-10-21 09:19:53 +02:00
|
|
|
if (irc, nick) not in self._whois:
|
2003-06-22 18:17:33 +02:00
|
|
|
return
|
|
|
|
else:
|
2003-10-21 09:19:53 +02:00
|
|
|
self._whois[(irc, nick)][-1][msg.command] = msg
|
2003-06-22 18:17:33 +02:00
|
|
|
|
2003-12-09 15:35:54 +01:00
|
|
|
do301 = do311
|
2003-06-22 18:17:33 +02:00
|
|
|
do312 = do311
|
|
|
|
do317 = do311
|
|
|
|
do319 = do311
|
2003-12-09 15:35:54 +01:00
|
|
|
do320 = do311
|
2003-08-20 18:26:23 +02:00
|
|
|
|
2003-06-22 18:17:33 +02:00
|
|
|
def do318(self, irc, msg):
|
2003-12-17 14:16:42 +01:00
|
|
|
irc = self._getRealIrc(irc)
|
2004-01-02 21:59:14 +01:00
|
|
|
nick = msg.args[1]
|
|
|
|
loweredNick = ircutils.toLower(nick)
|
|
|
|
if (irc, loweredNick) not in self._whois:
|
2003-06-22 18:17:33 +02:00
|
|
|
return
|
2004-01-02 21:59:14 +01:00
|
|
|
(replyIrc, replyMsg, d) = self._whois[(irc, loweredNick)]
|
2003-08-12 10:48:16 +02:00
|
|
|
hostmask = '@'.join(d['311'].args[2:4])
|
2003-08-21 18:31:37 +02:00
|
|
|
user = d['311'].args[-1]
|
2003-08-26 18:40:31 +02:00
|
|
|
if '319' in d:
|
|
|
|
channels = d['319'].args[-1].split()
|
2003-10-28 15:08:11 +01:00
|
|
|
ops = []
|
|
|
|
voices = []
|
|
|
|
normal = []
|
|
|
|
halfops = []
|
|
|
|
for channel in channels:
|
|
|
|
if channel.startswith('@'):
|
2003-11-04 09:50:10 +01:00
|
|
|
ops.append(channel[1:])
|
2003-10-28 15:08:11 +01:00
|
|
|
elif channel.startswith('%'):
|
2003-11-04 09:50:10 +01:00
|
|
|
halfops.append(channel[1:])
|
2003-10-28 15:08:11 +01:00
|
|
|
elif channel.startswith('+'):
|
2003-11-04 09:50:10 +01:00
|
|
|
voices.append(channel[1:])
|
2003-10-28 15:08:11 +01:00
|
|
|
else:
|
|
|
|
normal.append(channel)
|
|
|
|
L = []
|
|
|
|
if ops:
|
|
|
|
L.append('is an op on %s' % utils.commaAndify(ops))
|
|
|
|
if halfops:
|
|
|
|
L.append('is a halfop on %s' % utils.commaAndify(halfops))
|
|
|
|
if voices:
|
|
|
|
L.append('is voiced on %s' % utils.commaAndify(voices))
|
|
|
|
if L:
|
|
|
|
L.append('is also on %s' % utils.commaAndify(normal))
|
|
|
|
else:
|
|
|
|
L.append('is on %s' % utils.commaAndify(normal))
|
2003-08-12 10:48:16 +02:00
|
|
|
else:
|
2003-10-28 15:08:11 +01:00
|
|
|
L = ['isn\'t on any non-secret channels']
|
|
|
|
channels = utils.commaAndify(L)
|
2003-08-12 10:48:16 +02:00
|
|
|
if '317' in d:
|
|
|
|
idle = utils.timeElapsed(d['317'].args[2])
|
2004-01-18 08:58:26 +01:00
|
|
|
signon = time.strftime(conf.supybot.humanTimestampFormat(),
|
2003-08-26 13:15:15 +02:00
|
|
|
time.localtime(float(d['317'].args[3])))
|
2003-08-12 10:48:16 +02:00
|
|
|
else:
|
2003-08-21 18:31:37 +02:00
|
|
|
idle = '<unknown>'
|
|
|
|
signon = '<unknown>'
|
2003-10-16 12:58:31 +02:00
|
|
|
if '312' in d:
|
|
|
|
server = d['312'].args[2]
|
|
|
|
else:
|
|
|
|
server = '<unknown>'
|
2003-12-09 15:35:54 +01:00
|
|
|
if '301' in d:
|
2003-12-09 15:56:45 +01:00
|
|
|
away = ' %s is away: %s.' % (nick, d['301'].args[2])
|
2003-12-09 15:35:54 +01:00
|
|
|
else:
|
|
|
|
away = ''
|
|
|
|
if '320' in d:
|
|
|
|
if d['320'].args[2]:
|
|
|
|
identify = ' identified'
|
|
|
|
else:
|
|
|
|
identify = ''
|
|
|
|
else:
|
|
|
|
identify = ''
|
2004-01-09 00:03:48 +01:00
|
|
|
s = '%s (%s) has been%s on server %s since %s (idle for %s) and ' \
|
2003-12-09 15:35:54 +01:00
|
|
|
'%s.%s' % (user, hostmask, identify, server, signon, idle,
|
|
|
|
channels, away)
|
2004-01-09 01:03:59 +01:00
|
|
|
replyIrc.reply(s)
|
2004-01-02 21:59:14 +01:00
|
|
|
del self._whois[(irc, loweredNick)]
|
2003-08-20 18:26:23 +02:00
|
|
|
|
2003-08-26 19:55:30 +02:00
|
|
|
def do402(self, irc, msg):
|
2003-12-17 14:16:42 +01:00
|
|
|
irc = self._getRealIrc(irc)
|
2004-01-02 21:59:14 +01:00
|
|
|
nick = msg.args[1]
|
|
|
|
loweredNick = ircutils.toLower(nick)
|
|
|
|
if (irc, loweredNick) not in self._whois:
|
2003-08-26 19:55:30 +02:00
|
|
|
return
|
2004-01-02 21:59:14 +01:00
|
|
|
(replyIrc, replyMsg, d) = self._whois[(irc, loweredNick)]
|
|
|
|
del self._whois[(irc, loweredNick)]
|
2003-08-26 19:55:30 +02:00
|
|
|
s = 'There is no %s on %s.' % (nick, self.abbreviations[irc])
|
2004-01-09 01:03:59 +01:00
|
|
|
replyIrc.reply(s)
|
2003-08-26 19:55:30 +02:00
|
|
|
|
2003-08-28 18:31:56 +02:00
|
|
|
do401 = do402
|
|
|
|
|
2003-08-15 07:41:51 +02:00
|
|
|
def _formatPrivmsg(self, nick, network, msg):
|
2003-07-23 07:29:16 +02:00
|
|
|
# colorize nicks
|
2004-01-30 05:54:15 +01:00
|
|
|
color = self.registryValue('color', msg.args[0])
|
2003-10-30 03:03:49 +01:00
|
|
|
if color:
|
2003-08-21 13:19:32 +02:00
|
|
|
nick = ircutils.mircColor(nick, *ircutils.canonicalColor(nick))
|
|
|
|
colors = ircutils.canonicalColor(nick, shift=4)
|
2003-03-27 09:17:51 +01:00
|
|
|
if ircmsgs.isAction(msg):
|
2003-10-30 03:03:49 +01:00
|
|
|
if color:
|
2003-08-21 13:19:32 +02:00
|
|
|
t = ircutils.mircColor('*', *colors)
|
|
|
|
else:
|
|
|
|
t = '*'
|
2003-08-15 07:41:51 +02:00
|
|
|
s = '%s %s@%s %s' % (t, nick, network, ircmsgs.unAction(msg))
|
2003-03-27 09:17:51 +01:00
|
|
|
else:
|
2003-10-30 03:03:49 +01:00
|
|
|
if color:
|
2003-08-21 13:19:32 +02:00
|
|
|
lt = ircutils.mircColor('<', *colors)
|
|
|
|
gt = ircutils.mircColor('>', *colors)
|
|
|
|
else:
|
|
|
|
lt = '<'
|
|
|
|
gt = '>'
|
2003-08-15 07:41:51 +02:00
|
|
|
s = '%s%s@%s%s %s' % (lt, nick, network, gt, msg.args[1])
|
2003-08-12 10:48:16 +02:00
|
|
|
return s
|
2003-03-27 09:17:51 +01:00
|
|
|
|
2003-10-10 08:10:50 +02:00
|
|
|
def _sendToOthers(self, irc, msg):
|
2004-01-19 21:21:30 +01:00
|
|
|
assert msg.command == 'PRIVMSG' or msg.command == 'TOPIC'
|
2003-10-10 08:10:50 +02:00
|
|
|
for otherIrc in self.ircs.itervalues():
|
|
|
|
if otherIrc != irc:
|
|
|
|
if msg.args[0] in otherIrc.state.channels:
|
|
|
|
otherIrc.queueMsg(msg)
|
|
|
|
|
2003-03-26 09:39:50 +01:00
|
|
|
def doPrivmsg(self, irc, msg):
|
|
|
|
if self.started and ircutils.isChannel(msg.args[0]):
|
2003-12-17 14:16:42 +01:00
|
|
|
irc = self._getRealIrc(irc)
|
2003-03-26 09:39:50 +01:00
|
|
|
channel = msg.args[0]
|
2004-01-01 20:10:20 +01:00
|
|
|
if channel not in self.channels:
|
|
|
|
return
|
2004-01-04 14:50:43 +01:00
|
|
|
if ircutils.isCtcp(msg) and \
|
|
|
|
not 'AWAY' in msg.args[1] and \
|
|
|
|
not 'ACTION' in msg.args[1]:
|
2003-03-27 21:10:10 +01:00
|
|
|
return
|
2003-03-26 09:39:50 +01:00
|
|
|
abbreviation = self.abbreviations[irc]
|
2003-03-27 09:17:51 +01:00
|
|
|
s = self._formatPrivmsg(msg.nick, abbreviation, msg)
|
2003-10-10 08:10:50 +02:00
|
|
|
m = ircmsgs.privmsg(channel, s)
|
|
|
|
self._sendToOthers(irc, m)
|
2003-03-26 09:39:50 +01:00
|
|
|
|
|
|
|
def doJoin(self, irc, msg):
|
|
|
|
if self.started:
|
2003-12-17 14:16:42 +01:00
|
|
|
irc = self._getRealIrc(irc)
|
2003-03-27 21:32:49 +01:00
|
|
|
channel = msg.args[0]
|
|
|
|
if channel not in self.channels:
|
|
|
|
return
|
2003-03-26 09:39:50 +01:00
|
|
|
abbreviation = self.abbreviations[irc]
|
2003-04-30 16:49:09 +02:00
|
|
|
s = '%s (%s) has joined on %s' % (msg.nick,msg.prefix,abbreviation)
|
2003-10-10 08:10:50 +02:00
|
|
|
m = ircmsgs.privmsg(channel, s)
|
|
|
|
self._sendToOthers(irc, m)
|
2003-03-26 09:39:50 +01:00
|
|
|
|
|
|
|
def doPart(self, irc, msg):
|
|
|
|
if self.started:
|
2003-12-17 14:16:42 +01:00
|
|
|
irc = self._getRealIrc(irc)
|
2003-03-27 21:32:49 +01:00
|
|
|
channel = msg.args[0]
|
|
|
|
if channel not in self.channels:
|
|
|
|
return
|
2003-03-26 09:39:50 +01:00
|
|
|
abbreviation = self.abbreviations[irc]
|
2003-04-30 16:49:09 +02:00
|
|
|
s = '%s (%s) has left on %s' % (msg.nick, msg.prefix, abbreviation)
|
2003-10-10 08:10:50 +02:00
|
|
|
m = ircmsgs.privmsg(channel, s)
|
|
|
|
self._sendToOthers(irc, m)
|
2003-03-26 09:39:50 +01:00
|
|
|
|
2003-03-31 09:04:23 +02:00
|
|
|
def doMode(self, irc, msg):
|
|
|
|
if self.started:
|
2003-12-17 14:16:42 +01:00
|
|
|
irc = self._getRealIrc(irc)
|
2003-03-31 09:04:23 +02:00
|
|
|
channel = msg.args[0]
|
2003-10-10 08:10:50 +02:00
|
|
|
if channel not in self.channels:
|
|
|
|
return
|
|
|
|
abbreviation = self.abbreviations[irc]
|
|
|
|
s = 'mode change by %s on %s: %s' % \
|
|
|
|
(msg.nick, abbreviation, ' '.join(msg.args[1:]))
|
|
|
|
m = ircmsgs.privmsg(channel, s)
|
|
|
|
self._sendToOthers(irc, m)
|
2003-09-03 20:42:52 +02:00
|
|
|
|
|
|
|
def doKick(self, irc, msg):
|
|
|
|
if self.started:
|
2003-12-17 14:16:42 +01:00
|
|
|
irc = self._getRealIrc(irc)
|
2003-09-03 20:42:52 +02:00
|
|
|
channel = msg.args[0]
|
2003-10-10 08:10:50 +02:00
|
|
|
if channel not in self.channels:
|
|
|
|
return
|
|
|
|
abbrev = self.abbreviations[irc]
|
|
|
|
if len(msg.args) == 3:
|
2003-10-18 01:08:27 +02:00
|
|
|
s = '%s was kicked by %s on %s (%s)' % \
|
|
|
|
(msg.args[1], msg.nick, abbrev, msg.args[2])
|
2003-10-10 08:10:50 +02:00
|
|
|
else:
|
2003-10-18 01:08:27 +02:00
|
|
|
s = '%s was kicked by %s on %s' % \
|
|
|
|
(msg.args[1], msg.nick, abbrev)
|
2003-10-10 08:10:50 +02:00
|
|
|
m = ircmsgs.privmsg(channel, s)
|
|
|
|
self._sendToOthers(irc, m)
|
2003-08-20 18:26:23 +02:00
|
|
|
|
2003-03-31 09:04:23 +02:00
|
|
|
def doNick(self, irc, msg):
|
|
|
|
if self.started:
|
2003-12-17 14:16:42 +01:00
|
|
|
irc = self._getRealIrc(irc)
|
2003-03-31 11:22:48 +02:00
|
|
|
newNick = msg.args[0]
|
2003-08-12 10:48:16 +02:00
|
|
|
network = self.abbreviations[irc]
|
|
|
|
s = 'nick change by %s to %s on %s' % (msg.nick, newNick, network)
|
2003-03-31 11:22:48 +02:00
|
|
|
for channel in self.channels:
|
|
|
|
if newNick in irc.state.channels[channel].users:
|
2003-10-10 08:10:50 +02:00
|
|
|
m = ircmsgs.privmsg(channel, s)
|
|
|
|
self._sendToOthers(irc, m)
|
|
|
|
|
|
|
|
def doTopic(self, irc, msg):
|
|
|
|
if self.started:
|
2003-12-17 14:16:42 +01:00
|
|
|
irc = self._getRealIrc(irc)
|
2003-10-10 15:37:23 +02:00
|
|
|
if msg.nick == irc.nick:
|
|
|
|
return
|
2003-12-10 09:27:30 +01:00
|
|
|
(channel, newTopic) = msg.args
|
2003-10-10 08:10:50 +02:00
|
|
|
network = self.abbreviations[irc]
|
2004-01-30 05:54:15 +01:00
|
|
|
if self.registryValue('topicSync', channel):
|
2003-12-10 09:27:30 +01:00
|
|
|
m = ircmsgs.topic(channel, newTopic)
|
|
|
|
else:
|
|
|
|
s = 'topic change by %s on %s: %s' %(msg.nick,network,newTopic)
|
|
|
|
m = ircmsgs.privmsg(channel, s)
|
2003-10-10 08:10:50 +02:00
|
|
|
self._sendToOthers(irc, m)
|
2003-04-01 09:09:36 +02:00
|
|
|
|
|
|
|
def doQuit(self, irc, msg):
|
|
|
|
if self.started:
|
2003-12-17 14:16:42 +01:00
|
|
|
irc = self._getRealIrc(irc)
|
2003-04-01 09:09:36 +02:00
|
|
|
network = self.abbreviations[irc]
|
2003-06-22 18:17:33 +02:00
|
|
|
if msg.args:
|
2003-04-30 16:49:09 +02:00
|
|
|
s = '%s has quit %s (%s)' % (msg.nick, network, msg.args[0])
|
2003-04-01 09:09:36 +02:00
|
|
|
else:
|
2003-04-30 16:49:09 +02:00
|
|
|
s = '%s has quit %s.' % (msg.nick, network)
|
2003-04-01 09:09:36 +02:00
|
|
|
for channel in self.channels:
|
2003-04-09 21:11:00 +02:00
|
|
|
if msg.nick in self.ircstates[irc].channels[channel].users:
|
2003-10-10 08:10:50 +02:00
|
|
|
m = ircmsgs.privmsg(channel, s)
|
|
|
|
self._sendToOthers(irc, m)
|
2003-08-20 18:26:23 +02:00
|
|
|
|
2003-03-27 09:17:51 +01:00
|
|
|
def outFilter(self, irc, msg):
|
2003-03-31 11:22:48 +02:00
|
|
|
if not self.started:
|
|
|
|
return msg
|
2003-12-17 14:16:42 +01:00
|
|
|
irc = self._getRealIrc(irc)
|
2003-03-27 09:17:51 +01:00
|
|
|
if msg.command == 'PRIVMSG':
|
|
|
|
abbreviations = self.abbreviations.values()
|
2003-03-27 09:56:34 +01:00
|
|
|
rPrivmsg = re.compile(r'<[^@]+@(?:%s)>' % '|'.join(abbreviations))
|
2003-06-05 23:03:22 +02:00
|
|
|
rAction = re.compile(r'\* [^/]+@(?:%s) ' % '|'.join(abbreviations))
|
2003-08-12 10:48:16 +02:00
|
|
|
text = ircutils.unColor(msg.args[1])
|
|
|
|
if not (rPrivmsg.match(text) or \
|
|
|
|
rAction.match(text) or \
|
|
|
|
'has left on ' in text or \
|
|
|
|
'has joined on ' in text or \
|
|
|
|
'has quit' in text or \
|
2003-10-19 16:45:14 +02:00
|
|
|
'was kicked by' in text or \
|
2003-08-12 10:48:16 +02:00
|
|
|
text.startswith('mode change') or \
|
2003-10-10 08:10:50 +02:00
|
|
|
text.startswith('nick change') or \
|
|
|
|
text.startswith('topic change')):
|
2003-03-27 09:17:51 +01:00
|
|
|
channel = msg.args[0]
|
2003-03-28 06:36:59 +01:00
|
|
|
if channel in self.channels:
|
|
|
|
abbreviation = self.abbreviations[irc]
|
|
|
|
s = self._formatPrivmsg(irc.nick, abbreviation, msg)
|
|
|
|
for otherIrc in self.ircs.itervalues():
|
|
|
|
if otherIrc != irc:
|
|
|
|
if channel in otherIrc.state.channels:
|
|
|
|
otherIrc.queueMsg(ircmsgs.privmsg(channel, s))
|
2003-12-10 09:27:30 +01:00
|
|
|
elif msg.command == 'TOPIC' and len(msg.args) > 1 and \
|
2004-01-30 05:54:15 +01:00
|
|
|
self.registryValue('topicSync', msg.args[0]):
|
2003-03-28 06:36:59 +01:00
|
|
|
(channel, topic) = msg.args
|
|
|
|
if channel in self.channels:
|
2003-03-27 09:24:22 +01:00
|
|
|
for otherIrc in self.ircs.itervalues():
|
2003-03-27 09:17:51 +01:00
|
|
|
if otherIrc != irc:
|
2004-01-15 12:25:04 +01:00
|
|
|
try:
|
|
|
|
if otherIrc.state.getTopic(channel) != topic:
|
|
|
|
otherIrc.queueMsg(ircmsgs.topic(channel,topic))
|
|
|
|
except KeyError:
|
|
|
|
self.log.warning('Odd, not on %s on %s -- '
|
|
|
|
'Can\'t synchronize topics.',
|
|
|
|
channel, otherIrc.server)
|
2003-08-20 18:26:23 +02:00
|
|
|
|
2003-03-27 09:26:36 +01:00
|
|
|
return msg
|
2003-03-27 09:17:51 +01:00
|
|
|
|
2003-03-26 09:39:50 +01:00
|
|
|
Class = Relay
|
2003-08-20 18:26:23 +02:00
|
|
|
|
2003-03-24 09:41:19 +01:00
|
|
|
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|