diff --git a/plugins/Alias.py b/plugins/Alias.py index 4b1fe786d..457d44af1 100644 --- a/plugins/Alias.py +++ b/plugins/Alias.py @@ -70,7 +70,7 @@ def findBiggestDollar(alias): def makeNewAlias(name, alias): if findAliasCommand(name, alias): raise RecursiveAlias - doChannel = alias.find('$channel') != -1 + doChannel = '$channel' in alias biggestDollar = findBiggestDollar(alias) doDollars = bool(biggestDollar) if biggestDollar is not None: diff --git a/plugins/Friendly.py b/plugins/Friendly.py index 092045fcc..cdec2c58e 100755 --- a/plugins/Friendly.py +++ b/plugins/Friendly.py @@ -39,12 +39,12 @@ import callbacks class Friendly(callbacks.PrivmsgRegexp): def greet(self, irc, msg, match): "(?:heya?|(?:w(?:hat'?s\b|as)s?up)|howdy|hi|hello)" - if msg.args[1].find(irc.nick) != -1: + if irc.nick in msg.args[1]: irc.queueMsg(ircmsgs.privmsg(msg.args[0], 'howdy :)')) def goodbye(self, irc, msg, match): "(?:good)?bye|adios|vale|ciao|au revoir|seeya|night" - if msg.args[1].find(irc.nick) != -1: + if irc.nick in msg.args[1]: irc.queueMsg(ircmsgs.privmsg(msg.args[0], 'seeya, d00d!')) def exclaim(self, irc, msg, match): diff --git a/plugins/FunDB.py b/plugins/FunDB.py index c84fa8f12..8273f0ffb 100755 --- a/plugins/FunDB.py +++ b/plugins/FunDB.py @@ -344,7 +344,7 @@ class FunDB(callbacks.Privmsg): be "addlart chops $who in half with an AOL cd." """ lart = privmsgs.getArgs(args) - if lart.find('$who') == -1: + if '$who' in lart: irc.error(msg, 'There must be an $who in the lart somewhere.') return cursor = self.db.cursor() @@ -431,7 +431,7 @@ if __name__ == '__main__': cursor.execute("""PRAGMA cache_size = 50000""") addWord(db, line) elif category == 'larts': - if line.find('$who') != -1: + if '$who' in line: cursor.execute("""INSERT INTO larts VALUES (NULL, %s)""", line) else: print 'Invalid lart: %s' % line diff --git a/plugins/Gameknot.py b/plugins/Gameknot.py index 0a6f29183..c023369b7 100644 --- a/plugins/Gameknot.py +++ b/plugins/Gameknot.py @@ -79,7 +79,7 @@ class Gameknot(callbacks.PrivmsgCommandAndRegexp): games = self._gkgames.search(profile).group(1) (w, l, d) = self._gkrecord.search(profile).groups() seen = self._gkseen.search(utils.htmlToText(profile)) - if seen.group(0).find("is hiding") != -1: + if 'is hiding' in seen.group(0): seen = '%s is hiding his/her online status.' % name elif seen.group(2).startswith('0'): seen = '%s is on gameknot right now.' % name @@ -90,7 +90,7 @@ class Gameknot(callbacks.PrivmsgCommandAndRegexp): games = '1 active game' else: games = '%s active games' % games - if profile.find('Team:') >= 0: + if 'Team:' in profile: team = self._gkteam.search(profile).group('name') irc.reply(msg, '%s (team: %s) is rated %s and has %s ' \ 'and a record of W-%s, L-%s, D-%s. %s' % \ @@ -100,7 +100,7 @@ class Gameknot(callbacks.PrivmsgCommandAndRegexp): 'and a record of W-%s, L-%s, D-%s. %s' % \ (name, rating, games, w, l, d, seen)) except AttributeError: - if profile.find('User %s not found!' % name) != -1: + if ('User %s not found!' % name) in profile: irc.error(msg, 'No user %s exists.' % name) else: irc.error(msg, 'The format of the page was odd.') diff --git a/plugins/Http.py b/plugins/Http.py index d2651a2c8..836469531 100644 --- a/plugins/Http.py +++ b/plugins/Http.py @@ -305,7 +305,7 @@ class Http(callbacks.Privmsg): html = m.group(1) s = utils.htmlToText(html, tagReplace='').strip('\xa0 ') irc.reply(msg, s[9:]) # Snip off "the site" - elif html.find('We could not get any results') != -1: + elif 'We could not get any results' in html: irc.reply(msg, 'No results found for %s.' % hostname) else: irc.error(msg, 'The format of the was odd.') diff --git a/plugins/NickServ.py b/plugins/NickServ.py index 569ffca66..a6f8882fe 100644 --- a/plugins/NickServ.py +++ b/plugins/NickServ.py @@ -81,7 +81,7 @@ class NickServ(privmsgs.CapabilityCheckingPrivmsg): # NickServ told us the nick is registered. identify = 'IDENTIFY %s' % self.password irc.queueMsg(ircmsgs.privmsg(self.nickserv, identify)) - elif msg.args[1].find('recognized') != -1: + elif 'recognized' in msg.args[1]: self.sentGhost = False elif self._ghosted.search(msg.args[1]): # NickServ told us the nick has been ghost-killed. diff --git a/plugins/OSU.py b/plugins/OSU.py index 203b0fc83..1aa4db00a 100644 --- a/plugins/OSU.py +++ b/plugins/OSU.py @@ -62,7 +62,7 @@ class OSU(callbacks.Privmsg): emails = [] for line in data.splitlines(): line.strip() - if line.find('Published address') != -1: + if 'Published address' in line: emails.append(line.split()[-1]) if emails: irc.reply(msg, 'Possible matches: %s' % ', '.join(emails)) diff --git a/plugins/Relay.py b/plugins/Relay.py index bb463847a..34d1faa30 100644 --- a/plugins/Relay.py +++ b/plugins/Relay.py @@ -382,9 +382,9 @@ class Relay(callbacks.Privmsg): rAction = re.compile(r'\* [^/]+@(?:%s) ' % '|'.join(abbreviations)) if not (rPrivmsg.match(msg.args[1]) or \ rAction.match(msg.args[1]) or \ - msg.args[1].find('has left on ') != -1 or \ - msg.args[1].find('has joined on ') != -1 or \ - msg.args[1].find('has quit') != -1 or \ + 'has left on ' in msg.args[1] or \ + 'has joined on ' in msg.args[1] or \ + 'has quit' in msg.args[1] or \ msg.args[1].startswith('mode change') or \ msg.args[1].startswith('nick change')): channel = msg.args[0] diff --git a/plugins/ThreadedFunCommands.py b/plugins/ThreadedFunCommands.py index a22eb04ed..ef4cf3c87 100644 --- a/plugins/ThreadedFunCommands.py +++ b/plugins/ThreadedFunCommands.py @@ -71,9 +71,9 @@ class ThreadedFunCommands(callbacks.Privmsg): text = conn.read_all() for line in text.splitlines(): (name, version) = line.split(':') - if name.find('latest stable') != -1: + if 'latest stable' in name: stable = version.strip() - elif name.find('latest beta') != -1: + elif 'latest beta' in name: beta = version.strip() irc.reply(msg, 'The latest stable kernel is %s; ' \ 'the latest beta kernel is %s.' % (stable, beta)) diff --git a/plugins/Topic.py b/plugins/Topic.py index 3e7056785..a56649221 100644 --- a/plugins/Topic.py +++ b/plugins/Topic.py @@ -65,7 +65,7 @@ class Topic(callbacks.Privmsg): capability = ircdb.makeChannelCapability(channel, 'topic') topic = privmsgs.getArgs(args) if ircdb.checkCapability(msg.prefix, capability): - if topic.find(self.topicSeparator) != -1: + if self.topicSeparator in topic: s = 'You can\'t have %s in your topic' % self.topicSeparator irc.error(msg, s) return diff --git a/src/bot.py b/src/bot.py index b12b45b7b..93e99663e 100755 --- a/src/bot.py +++ b/src/bot.py @@ -104,7 +104,7 @@ def processConfigFile(filename): nick = d['nick'] server = d['server'] password = d['password'] - if server.find(':') != -1: + if ':' in server: (server, port) = server.split(':', 1) try: server = (server, int(port)) diff --git a/src/ircmsgs.py b/src/ircmsgs.py index d85f68081..e41f683d2 100644 --- a/src/ircmsgs.py +++ b/src/ircmsgs.py @@ -100,7 +100,7 @@ class IrcMsg(object): self.prefix, s = s[1:].split(None, 1) else: self.prefix = '' - if s.find(' :') != -1: + if ' :' in s: s, last = s.split(' :', 1) self.args = s.split() self.args.append(last.rstrip('\r\n')) @@ -186,6 +186,12 @@ class IrcMsg(object): def __setstate__(self, s): self.__init__(s) +try: + import _ircmsg + IrcMsg = _ircmsg.IrcMsg +except: + pass + def isAction(msg): """A predicate returning true if the PRIVMSG in question is an ACTION""" diff --git a/src/ircutils.py b/src/ircutils.py index a2490c8ec..5966ec9fd 100644 --- a/src/ircutils.py +++ b/src/ircutils.py @@ -54,7 +54,7 @@ def isUserHostmask(s): def isServerHostmask(s): """Returns True if s is a valid server hostmask.""" - return (not isUserHostmask(s) and s.find('!') == -1 and s.find('@') == -1) + return not isUserHostmask(s) def nickFromHostmask(hostmask): """Returns the nick from a user hostmask."""