mirror of https://github.com/Mikaela/Limnoria.git
Fixed some == tests on nicks (became ircutils.strEqual).
This commit is contained in:
parent
ed71df8655
commit
86c7743fc9
|
@ -271,7 +271,7 @@ class ChannelStats(callbacks.Privmsg):
|
||||||
"""
|
"""
|
||||||
channel = privmsgs.getChannel(msg, args)
|
channel = privmsgs.getChannel(msg, args)
|
||||||
name = privmsgs.getArgs(args, required=0, optional=1)
|
name = privmsgs.getArgs(args, required=0, optional=1)
|
||||||
if name == irc.nick:
|
if ircutils.strEqual(name, irc.nick):
|
||||||
id = 0
|
id = 0
|
||||||
elif not name:
|
elif not name:
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -171,7 +171,7 @@ class Enforcer(callbacks.Privmsg):
|
||||||
self.unbans[banmask] = eventId
|
self.unbans[banmask] = eventId
|
||||||
|
|
||||||
def doJoin(self, irc, msg):
|
def doJoin(self, irc, msg):
|
||||||
if msg.nick == irc.nick:
|
if ircutils.strEqual(msg.nick, irc.nick):
|
||||||
return
|
return
|
||||||
channel = msg.args[0]
|
channel = msg.args[0]
|
||||||
c = ircdb.channels.getChannel(channel)
|
c = ircdb.channels.getChannel(channel)
|
||||||
|
@ -216,7 +216,7 @@ class Enforcer(callbacks.Privmsg):
|
||||||
if not ircutils.isUserHostmask(hostmask):
|
if not ircutils.isUserHostmask(hostmask):
|
||||||
return True # It's a server.
|
return True # It's a server.
|
||||||
nick = ircutils.nickFromHostmask(hostmask)
|
nick = ircutils.nickFromHostmask(hostmask)
|
||||||
if nick == irc.nick:
|
if ircutils.strEqual(nick, irc.nick):
|
||||||
return True # It's me.
|
return True # It's me.
|
||||||
chanserv = self.registryValue('ChanServ')
|
chanserv = self.registryValue('ChanServ')
|
||||||
if ircutils.strEqual(nick, chanserv):
|
if ircutils.strEqual(nick, chanserv):
|
||||||
|
@ -248,7 +248,7 @@ class Enforcer(callbacks.Privmsg):
|
||||||
deop = False
|
deop = False
|
||||||
for nick in kicked:
|
for nick in kicked:
|
||||||
hostmask = irc.state.nickToHostmask(nick)
|
hostmask = irc.state.nickToHostmask(nick)
|
||||||
if nick == irc.nick:
|
if ircutils.strEqual(nick, irc.nick):
|
||||||
# Must be a sendMsg so he joins the channel before MODEing.
|
# Must be a sendMsg so he joins the channel before MODEing.
|
||||||
irc.sendMsg(ircmsgs.join(channel))
|
irc.sendMsg(ircmsgs.join(channel))
|
||||||
if self._isProtected(channel, hostmask):
|
if self._isProtected(channel, hostmask):
|
||||||
|
@ -265,19 +265,19 @@ class Enforcer(callbacks.Privmsg):
|
||||||
if not self.registryValue('takeRevenge.onOps', channel):
|
if not self.registryValue('takeRevenge.onOps', channel):
|
||||||
return
|
return
|
||||||
for (mode, value) in ircutils.separateModes(msg.args[1:]):
|
for (mode, value) in ircutils.separateModes(msg.args[1:]):
|
||||||
if value == msg.nick:
|
if ircutils.strEqual(value, msg.nick):
|
||||||
continue
|
continue
|
||||||
elif mode == '+o' and value != irc.nick:
|
elif mode == '+o':
|
||||||
hostmask = irc.state.nickToHostmask(value)
|
hostmask = irc.state.nickToHostmask(value)
|
||||||
if ircdb.checkCapability(channel,
|
if ircdb.checkCapability(channel,
|
||||||
ircdb.makeAntiCapability('op')):
|
ircdb.makeAntiCapability('op')):
|
||||||
irc.sendMsg(ircmsgs.deop(channel, value))
|
irc.sendMsg(ircmsgs.deop(channel, value))
|
||||||
elif mode == '+h' and value != irc.nick:
|
elif mode == '+h':
|
||||||
hostmask = irc.state.nickToHostmask(value)
|
hostmask = irc.state.nickToHostmask(value)
|
||||||
if ircdb.checkCapability(channel,
|
if ircdb.checkCapability(channel,
|
||||||
ircdb.makeAntiCapability('halfop')):
|
ircdb.makeAntiCapability('halfop')):
|
||||||
irc.sendMsg(ircmsgs.dehalfop(channel, value))
|
irc.sendMsg(ircmsgs.dehalfop(channel, value))
|
||||||
elif mode == '+v' and value != irc.nick:
|
elif mode == '+v':
|
||||||
hostmask = irc.state.nickToHostmask(value)
|
hostmask = irc.state.nickToHostmask(value)
|
||||||
if ircdb.checkCapability(channel,
|
if ircdb.checkCapability(channel,
|
||||||
ircdb.makeAntiCapability('voice')):
|
ircdb.makeAntiCapability('voice')):
|
||||||
|
|
|
@ -346,7 +346,7 @@ class FunDB(callbacks.Privmsg):
|
||||||
nick = nick.rstrip('.')
|
nick = nick.rstrip('.')
|
||||||
if not nick:
|
if not nick:
|
||||||
raise callbacks.ArgumentError
|
raise callbacks.ArgumentError
|
||||||
if nick == irc.nick:
|
if ircutils.strEqual(nick, irc.nick):
|
||||||
nick = msg.nick
|
nick = msg.nick
|
||||||
try:
|
try:
|
||||||
(nick, reason) = itertools.imap(' '.join,
|
(nick, reason) = itertools.imap(' '.join,
|
||||||
|
|
|
@ -72,7 +72,7 @@ conf.registerGlobalValue(conf.supybot.plugins.Parter, 'channels',
|
||||||
|
|
||||||
class Parter(callbacks.Privmsg):
|
class Parter(callbacks.Privmsg):
|
||||||
def doJoin(self, irc, msg):
|
def doJoin(self, irc, msg):
|
||||||
if irc.nick == msg.nick:
|
if ircutils.strEqual(irc.nick, msg.nick):
|
||||||
channels = msg.args[0].split(',')
|
channels = msg.args[0].split(',')
|
||||||
autoParts = self.registryValue('channels')
|
autoParts = self.registryValue('channels')
|
||||||
for channel in channels:
|
for channel in channels:
|
||||||
|
|
|
@ -164,11 +164,11 @@ class QuoteGrabs(plugins.ChannelDBHandler, callbacks.Privmsg):
|
||||||
"""
|
"""
|
||||||
channel = privmsgs.getChannel(msg, args)
|
channel = privmsgs.getChannel(msg, args)
|
||||||
nick = privmsgs.getArgs(args)
|
nick = privmsgs.getArgs(args)
|
||||||
if nick == msg.nick:
|
if ircutils.strEqual(nick, msg.nick):
|
||||||
irc.error('You can\'t quote grab yourself.')
|
irc.error('You can\'t quote grab yourself.')
|
||||||
return
|
return
|
||||||
for m in reversed(irc.state.history):
|
for m in reversed(irc.state.history):
|
||||||
if m.command == 'PRIVMSG' and ircutils.nickEqual(m.nick, nick):
|
if m.command == 'PRIVMSG' and ircutils.strEqual(m.nick, nick):
|
||||||
self._grab(irc, m, msg.prefix)
|
self._grab(irc, m, msg.prefix)
|
||||||
irc.replySuccess()
|
irc.replySuccess()
|
||||||
return
|
return
|
||||||
|
|
|
@ -565,7 +565,7 @@ class Relay(callbacks.Privmsg):
|
||||||
|
|
||||||
def doTopic(self, irc, msg):
|
def doTopic(self, irc, msg):
|
||||||
irc = self._getRealIrc(irc)
|
irc = self._getRealIrc(irc)
|
||||||
if msg.nick == irc.nick:
|
if ircutils.strEqual(msg.nick, irc.nick):
|
||||||
return
|
return
|
||||||
(channel, newTopic) = msg.args
|
(channel, newTopic) = msg.args
|
||||||
if channel not in self.registryValue('channels'):
|
if channel not in self.registryValue('channels'):
|
||||||
|
|
|
@ -172,7 +172,8 @@ class Services(privmsgs.CapabilityCheckingPrivmsg):
|
||||||
s = 'Tried to identify without a NickServ or password set.'
|
s = 'Tried to identify without a NickServ or password set.'
|
||||||
self.log.warning(s)
|
self.log.warning(s)
|
||||||
return
|
return
|
||||||
assert irc.nick == nick, 'Identifying with not normal nick.'
|
assert ircutils.strEqual(irc.nick, nick), \
|
||||||
|
'Identifying with not normal nick.'
|
||||||
self.log.info('Sending identify (current nick: %s)' % irc.nick)
|
self.log.info('Sending identify (current nick: %s)' % irc.nick)
|
||||||
identify = 'IDENTIFY %s' % password
|
identify = 'IDENTIFY %s' % password
|
||||||
# It's important that this next statement is irc.sendMsg, not
|
# It's important that this next statement is irc.sendMsg, not
|
||||||
|
@ -238,7 +239,7 @@ class Services(privmsgs.CapabilityCheckingPrivmsg):
|
||||||
self.log.warning('Cannot identify without a nick being set. '
|
self.log.warning('Cannot identify without a nick being set. '
|
||||||
'Set supybot.plugins.Services.nick.')
|
'Set supybot.plugins.Services.nick.')
|
||||||
return
|
return
|
||||||
if irc.nick == nick:
|
if ircutils.strEqual(irc.nick, nick):
|
||||||
self._doIdentify(irc)
|
self._doIdentify(irc)
|
||||||
else:
|
else:
|
||||||
self._doGhost(irc)
|
self._doGhost(irc)
|
||||||
|
@ -260,7 +261,8 @@ class Services(privmsgs.CapabilityCheckingPrivmsg):
|
||||||
|
|
||||||
def doNick(self, irc, msg):
|
def doNick(self, irc, msg):
|
||||||
nick = self._getNick()
|
nick = self._getNick()
|
||||||
if msg.args[0] == irc.nick and irc.nick == nick:
|
if ircutils.strEqual(msg.args[0], irc.nick) and \
|
||||||
|
ircutils.strEqual(irc.nick, nick):
|
||||||
self._doIdentify(irc)
|
self._doIdentify(irc)
|
||||||
elif ircutils.strEqual(msg.nick, nick):
|
elif ircutils.strEqual(msg.nick, nick):
|
||||||
irc.sendMsg(ircmsgs.nick(nick))
|
irc.sendMsg(ircmsgs.nick(nick))
|
||||||
|
@ -303,6 +305,8 @@ class Services(privmsgs.CapabilityCheckingPrivmsg):
|
||||||
elif 'access level' in s and 'is required' in s:
|
elif 'access level' in s and 'is required' in s:
|
||||||
# XXX We should notify the user that this happened.
|
# XXX We should notify the user that this happened.
|
||||||
self.log.debug('Got "Access level required" from ChanServ.')
|
self.log.debug('Got "Access level required" from ChanServ.')
|
||||||
|
elif 'inviting' in s:
|
||||||
|
self.log.debug('Got "Inviting to channel" from ChanServ.')
|
||||||
else:
|
else:
|
||||||
self.log.warning('Got unexpected notice from ChanServ: %r.', msg)
|
self.log.warning('Got unexpected notice from ChanServ: %r.', msg)
|
||||||
|
|
||||||
|
@ -379,10 +383,10 @@ class Services(privmsgs.CapabilityCheckingPrivmsg):
|
||||||
|
|
||||||
def doMode(self, irc, msg):
|
def doMode(self, irc, msg):
|
||||||
chanserv = self.registryValue('ChanServ')
|
chanserv = self.registryValue('ChanServ')
|
||||||
if msg.nick == chanserv:
|
if ircutils.strEqual(msg.nick, chanserv):
|
||||||
channel = msg.args[0]
|
channel = msg.args[0]
|
||||||
if len(msg.args) == 3:
|
if len(msg.args) == 3:
|
||||||
if msg.args[2] == irc.nick:
|
if ircutils.strEqual(msg.args[2], irc.nick):
|
||||||
mode = msg.args[1]
|
mode = msg.args[1]
|
||||||
info = self.log.info
|
info = self.log.info
|
||||||
if mode == '+o':
|
if mode == '+o':
|
||||||
|
@ -400,7 +404,9 @@ class Services(privmsgs.CapabilityCheckingPrivmsg):
|
||||||
def _chanservCommand(self, irc, channel, command):
|
def _chanservCommand(self, irc, channel, command):
|
||||||
chanserv = self.registryValue('ChanServ')
|
chanserv = self.registryValue('ChanServ')
|
||||||
if chanserv:
|
if chanserv:
|
||||||
irc.sendMsg(ircmsgs.privmsg(chanserv, '%s %s' % (command, channel)))
|
msg = ircmsgs.privmsg(chanserv,
|
||||||
|
' '.join([command, channel, irc.nick]))
|
||||||
|
irc.sendMsg(msg)
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
@ -490,7 +496,7 @@ class Services(privmsgs.CapabilityCheckingPrivmsg):
|
||||||
irc.error('I\'m not in %s.' % channel)
|
irc.error('I\'m not in %s.' % channel)
|
||||||
|
|
||||||
def doInvite(self, irc, msg):
|
def doInvite(self, irc, msg):
|
||||||
if msg.nick == self.registryValue('ChanServ'):
|
if ircutils.strEqual(msg.nick, self.registryValue('ChanServ')):
|
||||||
channel = msg.args[1]
|
channel = msg.args[1]
|
||||||
self.log.info('Joining %s, invited by ChanServ.' % channel)
|
self.log.info('Joining %s, invited by ChanServ.' % channel)
|
||||||
irc.queueMsg(ircmsgs.join(channel))
|
irc.queueMsg(ircmsgs.join(channel))
|
||||||
|
@ -521,7 +527,7 @@ class Services(privmsgs.CapabilityCheckingPrivmsg):
|
||||||
nick = privmsgs.getArgs(args, required=0, optional=1)
|
nick = privmsgs.getArgs(args, required=0, optional=1)
|
||||||
if not nick:
|
if not nick:
|
||||||
nick = self._getNick()
|
nick = self._getNick()
|
||||||
if nick == irc.nick:
|
if ircutils.strEqual(nick, irc.nick):
|
||||||
irc.error('I cowardly refuse to ghost myself.')
|
irc.error('I cowardly refuse to ghost myself.')
|
||||||
else:
|
else:
|
||||||
self._doGhost(irc, nick=nick)
|
self._doGhost(irc, nick=nick)
|
||||||
|
|
|
@ -314,7 +314,7 @@ class URL(callbacks.PrivmsgCommandAndRegexp):
|
||||||
nolimit = True
|
nolimit = True
|
||||||
elif option == '--from':
|
elif option == '--from':
|
||||||
def from_(url, nick, arg=arg):
|
def from_(url, nick, arg=arg):
|
||||||
return nick.lower() == arg.lower()
|
return ircutils.strEqual(nick, arg)
|
||||||
predicates.append(from_)
|
predicates.append(from_)
|
||||||
elif option == '--with':
|
elif option == '--with':
|
||||||
def with(url, nick, arg=arg):
|
def with(url, nick, arg=arg):
|
||||||
|
|
|
@ -33,55 +33,50 @@ from testsupport import *
|
||||||
|
|
||||||
import supybot.ircdb as ircdb
|
import supybot.ircdb as ircdb
|
||||||
|
|
||||||
try:
|
class ChannelStatsTestCase(ChannelPluginTestCase):
|
||||||
import sqlite
|
plugins = ('ChannelStats', 'User')
|
||||||
except ImportError:
|
def setUp(self):
|
||||||
sqlite = None
|
ChannelPluginTestCase.setUp(self)
|
||||||
|
self.prefix = 'foo!bar@baz'
|
||||||
|
self.nick = 'foo'
|
||||||
|
self.irc.feedMsg(ircmsgs.privmsg(self.irc.nick,
|
||||||
|
'register foo bar',
|
||||||
|
prefix=self.prefix))
|
||||||
|
_ = self.irc.takeMsg()
|
||||||
|
chanop = ircdb.makeChannelCapability(self.channel, 'op')
|
||||||
|
ircdb.users.getUser(self.nick).addCapability(chanop)
|
||||||
|
|
||||||
if sqlite is not None:
|
def test(self):
|
||||||
class ChannelStatsTestCase(ChannelPluginTestCase):
|
self.assertNotError('channelstats')
|
||||||
plugins = ('ChannelStats', 'User')
|
self.assertNotError('channelstats')
|
||||||
def setUp(self):
|
self.assertNotError('channelstats')
|
||||||
ChannelPluginTestCase.setUp(self)
|
|
||||||
self.prefix = 'foo!bar@baz'
|
|
||||||
self.nick = 'foo'
|
|
||||||
self.irc.feedMsg(ircmsgs.privmsg(self.irc.nick,
|
|
||||||
'register foo bar',
|
|
||||||
prefix=self.prefix))
|
|
||||||
_ = self.irc.takeMsg()
|
|
||||||
chanop = ircdb.makeChannelCapability(self.channel, 'op')
|
|
||||||
ircdb.users.getUser(self.nick).addCapability(chanop)
|
|
||||||
|
|
||||||
def test(self):
|
def testStats(self):
|
||||||
self.assertNotError('channelstats')
|
self.assertError('channelstats stats %s' % self.nick)
|
||||||
self.assertNotError('channelstats')
|
self.assertNotError('channelstats stats %s' % self.nick)
|
||||||
self.assertNotError('channelstats')
|
self.assertNotError('channelstats stats %s' % self.nick.upper())
|
||||||
|
self.assertNotError('channelstats stats')
|
||||||
|
self.assertRegexp('channelstats stats', self.nick)
|
||||||
|
|
||||||
def testStats(self):
|
def testSelfStats(self):
|
||||||
self.assertError('channelstats stats %s' % self.nick)
|
self.assertError('channelstats stats %s' % self.irc.nick)
|
||||||
self.assertNotError('channelstats stats %s' % self.nick)
|
self.assertNotError('channelstats stats %s' % self.irc.nick)
|
||||||
self.assertNotError('channelstats stats %s' % self.nick.upper())
|
self.assertNotError('channelstats stats %s' % self.irc.nick)
|
||||||
self.assertNotError('channelstats stats')
|
self.assertNotError('channelstats stats %s' % self.irc.nick.upper())
|
||||||
self.assertRegexp('channelstats stats', self.nick)
|
id = ircdb.users.getUserId(self.prefix)
|
||||||
|
u = ircdb.users.getUser(id)
|
||||||
|
u.addCapability(ircdb.makeChannelCapability(self.channel, 'op'))
|
||||||
|
ircdb.users.setUser(id, u)
|
||||||
|
try:
|
||||||
|
conf.supybot.plugins.ChannelStats.selfStats.setValue(False)
|
||||||
|
m1 = self.getMsg('channelstats stats %s' % self.irc.nick)
|
||||||
|
m2 = self.getMsg('channelstats stats %s' % self.irc.nick)
|
||||||
|
self.assertEqual(m1.args[1], m2.args[1])
|
||||||
|
finally:
|
||||||
|
conf.supybot.plugins.ChannelStats.selfStats.setValue(True)
|
||||||
|
|
||||||
def testSelfStats(self):
|
def testNoKeyErrorStats(self):
|
||||||
self.assertError('channelstats stats %s' % self.irc.nick)
|
self.assertNotRegexp('stats sweede', 'KeyError')
|
||||||
self.assertNotError('channelstats stats %s' % self.irc.nick)
|
|
||||||
self.assertNotError('channelstats stats %s' % self.irc.nick)
|
|
||||||
id = ircdb.users.getUserId(self.prefix)
|
|
||||||
u = ircdb.users.getUser(id)
|
|
||||||
u.addCapability(ircdb.makeChannelCapability(self.channel, 'op'))
|
|
||||||
ircdb.users.setUser(id, u)
|
|
||||||
try:
|
|
||||||
conf.supybot.plugins.ChannelStats.selfStats.setValue(False)
|
|
||||||
m1 = self.getMsg('channelstats stats %s' % self.irc.nick)
|
|
||||||
m2 = self.getMsg('channelstats stats %s' % self.irc.nick)
|
|
||||||
self.assertEqual(m1.args[1], m2.args[1])
|
|
||||||
finally:
|
|
||||||
conf.supybot.plugins.ChannelStats.selfStats.setValue(True)
|
|
||||||
|
|
||||||
def testNoKeyErrorStats(self):
|
|
||||||
self.assertNotRegexp('stats sweede', 'KeyError')
|
|
||||||
|
|
||||||
|
|
||||||
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
||||||
|
|
|
@ -68,6 +68,8 @@ class TestFunDB(ChannelPluginTestCase, PluginDocumentation):
|
||||||
self.assertAction('lart 2 jemfinch for being dumb',
|
self.assertAction('lart 2 jemfinch for being dumb',
|
||||||
'shoots jemfinch for being dumb (#2)')
|
'shoots jemfinch for being dumb (#2)')
|
||||||
self.assertNotRegexp('lart %s' % self.irc.nick, self.irc.nick)
|
self.assertNotRegexp('lart %s' % self.irc.nick, self.irc.nick)
|
||||||
|
self.assertNotRegexp('lart %s' % self.irc.nick.upper(),
|
||||||
|
self.irc.nick.upper())
|
||||||
self.assertNotError('remove lart 1')
|
self.assertNotError('remove lart 1')
|
||||||
self.assertRegexp('fundb stats lart', 'currently 1 lart')
|
self.assertRegexp('fundb stats lart', 'currently 1 lart')
|
||||||
self.assertAction('lart jemfinch', 'shoots jemfinch (#2)')
|
self.assertAction('lart jemfinch', 'shoots jemfinch (#2)')
|
||||||
|
|
Loading…
Reference in New Issue