mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-11 12:42:34 +01:00
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)
|
||||
name = privmsgs.getArgs(args, required=0, optional=1)
|
||||
if name == irc.nick:
|
||||
if ircutils.strEqual(name, irc.nick):
|
||||
id = 0
|
||||
elif not name:
|
||||
try:
|
||||
|
@ -171,7 +171,7 @@ class Enforcer(callbacks.Privmsg):
|
||||
self.unbans[banmask] = eventId
|
||||
|
||||
def doJoin(self, irc, msg):
|
||||
if msg.nick == irc.nick:
|
||||
if ircutils.strEqual(msg.nick, irc.nick):
|
||||
return
|
||||
channel = msg.args[0]
|
||||
c = ircdb.channels.getChannel(channel)
|
||||
@ -216,7 +216,7 @@ class Enforcer(callbacks.Privmsg):
|
||||
if not ircutils.isUserHostmask(hostmask):
|
||||
return True # It's a server.
|
||||
nick = ircutils.nickFromHostmask(hostmask)
|
||||
if nick == irc.nick:
|
||||
if ircutils.strEqual(nick, irc.nick):
|
||||
return True # It's me.
|
||||
chanserv = self.registryValue('ChanServ')
|
||||
if ircutils.strEqual(nick, chanserv):
|
||||
@ -248,7 +248,7 @@ class Enforcer(callbacks.Privmsg):
|
||||
deop = False
|
||||
for nick in kicked:
|
||||
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.
|
||||
irc.sendMsg(ircmsgs.join(channel))
|
||||
if self._isProtected(channel, hostmask):
|
||||
@ -265,19 +265,19 @@ class Enforcer(callbacks.Privmsg):
|
||||
if not self.registryValue('takeRevenge.onOps', channel):
|
||||
return
|
||||
for (mode, value) in ircutils.separateModes(msg.args[1:]):
|
||||
if value == msg.nick:
|
||||
if ircutils.strEqual(value, msg.nick):
|
||||
continue
|
||||
elif mode == '+o' and value != irc.nick:
|
||||
elif mode == '+o':
|
||||
hostmask = irc.state.nickToHostmask(value)
|
||||
if ircdb.checkCapability(channel,
|
||||
ircdb.makeAntiCapability('op')):
|
||||
irc.sendMsg(ircmsgs.deop(channel, value))
|
||||
elif mode == '+h' and value != irc.nick:
|
||||
elif mode == '+h':
|
||||
hostmask = irc.state.nickToHostmask(value)
|
||||
if ircdb.checkCapability(channel,
|
||||
ircdb.makeAntiCapability('halfop')):
|
||||
irc.sendMsg(ircmsgs.dehalfop(channel, value))
|
||||
elif mode == '+v' and value != irc.nick:
|
||||
elif mode == '+v':
|
||||
hostmask = irc.state.nickToHostmask(value)
|
||||
if ircdb.checkCapability(channel,
|
||||
ircdb.makeAntiCapability('voice')):
|
||||
|
@ -346,7 +346,7 @@ class FunDB(callbacks.Privmsg):
|
||||
nick = nick.rstrip('.')
|
||||
if not nick:
|
||||
raise callbacks.ArgumentError
|
||||
if nick == irc.nick:
|
||||
if ircutils.strEqual(nick, irc.nick):
|
||||
nick = msg.nick
|
||||
try:
|
||||
(nick, reason) = itertools.imap(' '.join,
|
||||
|
@ -72,7 +72,7 @@ conf.registerGlobalValue(conf.supybot.plugins.Parter, 'channels',
|
||||
|
||||
class Parter(callbacks.Privmsg):
|
||||
def doJoin(self, irc, msg):
|
||||
if irc.nick == msg.nick:
|
||||
if ircutils.strEqual(irc.nick, msg.nick):
|
||||
channels = msg.args[0].split(',')
|
||||
autoParts = self.registryValue('channels')
|
||||
for channel in channels:
|
||||
|
@ -164,11 +164,11 @@ class QuoteGrabs(plugins.ChannelDBHandler, callbacks.Privmsg):
|
||||
"""
|
||||
channel = privmsgs.getChannel(msg, args)
|
||||
nick = privmsgs.getArgs(args)
|
||||
if nick == msg.nick:
|
||||
if ircutils.strEqual(nick, msg.nick):
|
||||
irc.error('You can\'t quote grab yourself.')
|
||||
return
|
||||
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)
|
||||
irc.replySuccess()
|
||||
return
|
||||
|
@ -565,7 +565,7 @@ class Relay(callbacks.Privmsg):
|
||||
|
||||
def doTopic(self, irc, msg):
|
||||
irc = self._getRealIrc(irc)
|
||||
if msg.nick == irc.nick:
|
||||
if ircutils.strEqual(msg.nick, irc.nick):
|
||||
return
|
||||
(channel, newTopic) = msg.args
|
||||
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.'
|
||||
self.log.warning(s)
|
||||
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)
|
||||
identify = 'IDENTIFY %s' % password
|
||||
# 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. '
|
||||
'Set supybot.plugins.Services.nick.')
|
||||
return
|
||||
if irc.nick == nick:
|
||||
if ircutils.strEqual(irc.nick, nick):
|
||||
self._doIdentify(irc)
|
||||
else:
|
||||
self._doGhost(irc)
|
||||
@ -260,7 +261,8 @@ class Services(privmsgs.CapabilityCheckingPrivmsg):
|
||||
|
||||
def doNick(self, irc, msg):
|
||||
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)
|
||||
elif ircutils.strEqual(msg.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:
|
||||
# XXX We should notify the user that this happened.
|
||||
self.log.debug('Got "Access level required" from ChanServ.')
|
||||
elif 'inviting' in s:
|
||||
self.log.debug('Got "Inviting to channel" from ChanServ.')
|
||||
else:
|
||||
self.log.warning('Got unexpected notice from ChanServ: %r.', msg)
|
||||
|
||||
@ -379,10 +383,10 @@ class Services(privmsgs.CapabilityCheckingPrivmsg):
|
||||
|
||||
def doMode(self, irc, msg):
|
||||
chanserv = self.registryValue('ChanServ')
|
||||
if msg.nick == chanserv:
|
||||
if ircutils.strEqual(msg.nick, chanserv):
|
||||
channel = msg.args[0]
|
||||
if len(msg.args) == 3:
|
||||
if msg.args[2] == irc.nick:
|
||||
if ircutils.strEqual(msg.args[2], irc.nick):
|
||||
mode = msg.args[1]
|
||||
info = self.log.info
|
||||
if mode == '+o':
|
||||
@ -400,7 +404,9 @@ class Services(privmsgs.CapabilityCheckingPrivmsg):
|
||||
def _chanservCommand(self, irc, channel, command):
|
||||
chanserv = self.registryValue('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
|
||||
else:
|
||||
return False
|
||||
@ -490,7 +496,7 @@ class Services(privmsgs.CapabilityCheckingPrivmsg):
|
||||
irc.error('I\'m not in %s.' % channel)
|
||||
|
||||
def doInvite(self, irc, msg):
|
||||
if msg.nick == self.registryValue('ChanServ'):
|
||||
if ircutils.strEqual(msg.nick, self.registryValue('ChanServ')):
|
||||
channel = msg.args[1]
|
||||
self.log.info('Joining %s, invited by ChanServ.' % channel)
|
||||
irc.queueMsg(ircmsgs.join(channel))
|
||||
@ -521,7 +527,7 @@ class Services(privmsgs.CapabilityCheckingPrivmsg):
|
||||
nick = privmsgs.getArgs(args, required=0, optional=1)
|
||||
if not nick:
|
||||
nick = self._getNick()
|
||||
if nick == irc.nick:
|
||||
if ircutils.strEqual(nick, irc.nick):
|
||||
irc.error('I cowardly refuse to ghost myself.')
|
||||
else:
|
||||
self._doGhost(irc, nick=nick)
|
||||
|
@ -314,7 +314,7 @@ class URL(callbacks.PrivmsgCommandAndRegexp):
|
||||
nolimit = True
|
||||
elif option == '--from':
|
||||
def from_(url, nick, arg=arg):
|
||||
return nick.lower() == arg.lower()
|
||||
return ircutils.strEqual(nick, arg)
|
||||
predicates.append(from_)
|
||||
elif option == '--with':
|
||||
def with(url, nick, arg=arg):
|
||||
|
@ -33,55 +33,50 @@ from testsupport import *
|
||||
|
||||
import supybot.ircdb as ircdb
|
||||
|
||||
try:
|
||||
import sqlite
|
||||
except ImportError:
|
||||
sqlite = None
|
||||
class ChannelStatsTestCase(ChannelPluginTestCase):
|
||||
plugins = ('ChannelStats', 'User')
|
||||
def setUp(self):
|
||||
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:
|
||||
class ChannelStatsTestCase(ChannelPluginTestCase):
|
||||
plugins = ('ChannelStats', 'User')
|
||||
def setUp(self):
|
||||
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):
|
||||
self.assertNotError('channelstats')
|
||||
self.assertNotError('channelstats')
|
||||
self.assertNotError('channelstats')
|
||||
|
||||
def test(self):
|
||||
self.assertNotError('channelstats')
|
||||
self.assertNotError('channelstats')
|
||||
self.assertNotError('channelstats')
|
||||
def testStats(self):
|
||||
self.assertError('channelstats stats %s' % self.nick)
|
||||
self.assertNotError('channelstats stats %s' % self.nick)
|
||||
self.assertNotError('channelstats stats %s' % self.nick.upper())
|
||||
self.assertNotError('channelstats stats')
|
||||
self.assertRegexp('channelstats stats', self.nick)
|
||||
|
||||
def testStats(self):
|
||||
self.assertError('channelstats stats %s' % self.nick)
|
||||
self.assertNotError('channelstats stats %s' % self.nick)
|
||||
self.assertNotError('channelstats stats %s' % self.nick.upper())
|
||||
self.assertNotError('channelstats stats')
|
||||
self.assertRegexp('channelstats stats', self.nick)
|
||||
def testSelfStats(self):
|
||||
self.assertError('channelstats stats %s' % self.irc.nick)
|
||||
self.assertNotError('channelstats stats %s' % self.irc.nick)
|
||||
self.assertNotError('channelstats stats %s' % self.irc.nick)
|
||||
self.assertNotError('channelstats stats %s' % self.irc.nick.upper())
|
||||
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):
|
||||
self.assertError('channelstats stats %s' % self.irc.nick)
|
||||
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')
|
||||
def testNoKeyErrorStats(self):
|
||||
self.assertNotRegexp('stats sweede', 'KeyError')
|
||||
|
||||
|
||||
# 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',
|
||||
'shoots jemfinch for being dumb (#2)')
|
||||
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.assertRegexp('fundb stats lart', 'currently 1 lart')
|
||||
self.assertAction('lart jemfinch', 'shoots jemfinch (#2)')
|
||||
|
Loading…
Reference in New Issue
Block a user