Merge branch 'maint/0.83.4'

This commit is contained in:
James McCoy 2011-12-06 01:18:18 -05:00
commit ca23cbb774
8 changed files with 23 additions and 11 deletions

View File

@ -382,6 +382,8 @@ class Misc(callbacks.Plugin):
Tells the <nick> whatever <text> is. Use nested commands to your Tells the <nick> whatever <text> is. Use nested commands to your
benefit here. benefit here.
""" """
if irc.nested:
irc.error('This command cannot be nested.', Raise=True)
if target.lower() == 'me': if target.lower() == 'me':
target = msg.nick target = msg.nick
if ircutils.isChannel(target): if ircutils.isChannel(target):

View File

@ -142,6 +142,9 @@ class MiscTestCase(ChannelPluginTestCase):
m = self.getMsg('tell me you love me') m = self.getMsg('tell me you love me')
self.failUnless(m.args[0] == self.nick) self.failUnless(m.args[0] == self.nick)
def testNoNestedTell(self):
self.assertRegexp('echo [tell %s foo]' % self.nick, 'nested')
def testTellDoesNotPropogateAction(self): def testTellDoesNotPropogateAction(self):
m = self.getMsg('tell foo [action bar]') m = self.getMsg('tell foo [action bar]')
self.failIf(ircmsgs.isAction(m)) self.failIf(ircmsgs.isAction(m))

View File

@ -61,7 +61,7 @@ class Services(callbacks.Plugin):
self.channels = [] self.channels = []
self.sentGhost = None self.sentGhost = None
self.identified = False self.identified = False
self.waitingJoins = [] self.waitingJoins = {}
def disabled(self, irc): def disabled(self, irc):
disabled = self.registryValue('disabledNetworks') disabled = self.registryValue('disabledNetworks')
@ -76,7 +76,8 @@ class Services(callbacks.Plugin):
if self.registryValue('noJoinsUntilIdentified'): if self.registryValue('noJoinsUntilIdentified'):
self.log.info('Holding JOIN to %s until identified.', self.log.info('Holding JOIN to %s until identified.',
msg.args[0]) msg.args[0])
self.waitingJoins.append(msg) self.waitingJoins.setdefault(irc.network, [])
self.waitingJoins[irc.network].append(msg)
return None return None
return msg return msg
@ -301,6 +302,8 @@ class Services(callbacks.Plugin):
pass pass
elif ('now recognized' in s) or \ elif ('now recognized' in s) or \
('already identified' in s) or \ ('already identified' in s) or \
('already logged in' in s) or \
('successfully identified' in s) or \
('password accepted' in s) or \ ('password accepted' in s) or \
('now identified' in s): ('now identified' in s):
# freenode, oftc, arstechnica, zirc, .... # freenode, oftc, arstechnica, zirc, ....
@ -311,10 +314,10 @@ class Services(callbacks.Plugin):
self.checkPrivileges(irc, channel) self.checkPrivileges(irc, channel)
for channel in self.channels: for channel in self.channels:
irc.queueMsg(networkGroup.channels.join(channel)) irc.queueMsg(networkGroup.channels.join(channel))
if self.waitingJoins: waitingJoins = self.waitingJoins.pop(irc.network, None)
for m in self.waitingJoins: if waitingJoins:
for m in waitingJoins:
irc.sendMsg(m) irc.sendMsg(m)
self.waitingJoins = []
elif 'not yet authenticated' in s: elif 'not yet authenticated' in s:
# zirc.org has this, it requires an auth code. # zirc.org has this, it requires an auth code.
email = s.split()[-1] email = s.split()[-1]

View File

@ -46,6 +46,7 @@ import supybot.conf as conf
import supybot.utils as utils import supybot.utils as utils
import supybot.ircdb as ircdb import supybot.ircdb as ircdb
from supybot.commands import * from supybot.commands import *
import supybot.ircmsgs as ircmsgs
import supybot.callbacks as callbacks import supybot.callbacks as callbacks
def getTracer(fd): def getTracer(fd):

View File

@ -210,11 +210,9 @@ def newDriver(irc, moduleName=None):
return driver return driver
def parseMsg(s): def parseMsg(s):
start = time.time()
s = s.strip() s = s.strip()
if s: if s:
msg = ircmsgs.IrcMsg(s) msg = ircmsgs.IrcMsg(s)
msg.tag('receivedAt', start)
return msg return msg
else: else:
return None return None

View File

@ -778,6 +778,7 @@ class Irc(IrcCommandDispatcher):
"""Called by the IrcDriver; feeds a message received.""" """Called by the IrcDriver; feeds a message received."""
msg.tag('receivedBy', self) msg.tag('receivedBy', self)
msg.tag('receivedOn', self.network) msg.tag('receivedOn', self.network)
msg.tag('receivedAt', time.time())
if msg.args and self.isChannel(msg.args[0]): if msg.args and self.isChannel(msg.args[0]):
channel = msg.args[0] channel = msg.args[0]
else: else:

View File

@ -182,7 +182,7 @@ class IrcMsg(object):
return self._hash return self._hash
self._hash = hash(self.command) ^ \ self._hash = hash(self.command) ^ \
hash(self.prefix) ^ \ hash(self.prefix) ^ \
hash(self.args) hash(repr(self.args))
return self._hash return self._hash
def __repr__(self): def __repr__(self):
@ -522,7 +522,8 @@ def unbans(channel, hostmasks, prefix='', msg=None):
if msg and not prefix: if msg and not prefix:
prefix = msg.prefix prefix = msg.prefix
return IrcMsg(prefix=prefix, command='MODE', msg=msg, return IrcMsg(prefix=prefix, command='MODE', msg=msg,
args=(channel, '-' + ('b'*len(hostmasks)), hostmasks)) args=(channel, '-' + ('b'*len(hostmasks)),
' '.join(hostmasks)))
def kick(channel, nick, s='', prefix='', msg=None): def kick(channel, nick, s='', prefix='', msg=None):
"""Returns a KICK to kick nick from channel with the message msg.""" """Returns a KICK to kick nick from channel with the message msg."""
@ -727,7 +728,10 @@ def whois(nick, mask='', prefix='', msg=None):
assert isNick(nick), repr(nick) assert isNick(nick), repr(nick)
if msg and not prefix: if msg and not prefix:
prefix = msg.prefix prefix = msg.prefix
return IrcMsg(prefix=prefix, command='WHOIS', args=(nick, mask), msg=msg) args = (nick,)
if mask:
args = (nick, mask)
return IrcMsg(prefix=prefix, command='WHOIS', args=args, msg=msg)
def names(channel=None, prefix='', msg=None): def names(channel=None, prefix='', msg=None):
if conf.supybot.protocols.irc.strictRfc(): if conf.supybot.protocols.irc.strictRfc():

View File

@ -73,7 +73,7 @@ def isIPV4(s):
0 0
""" """
try: try:
return bool(socket.inet_pton(socket.AF_INET, s)) return bool(socket.inet_aton(s))
except socket.error: except socket.error:
return False return False