mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-14 22:49:23 +01:00
Changed from 's.find(x) != -1' to 'x in s'
This commit is contained in:
parent
feda60aff2
commit
39cce9c3af
@ -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:
|
||||
|
@ -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):
|
||||
|
@ -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
|
||||
|
@ -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.')
|
||||
|
@ -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.')
|
||||
|
@ -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.
|
||||
|
@ -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))
|
||||
|
@ -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]
|
||||
|
@ -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))
|
||||
|
@ -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
|
||||
|
@ -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))
|
||||
|
@ -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"""
|
||||
|
@ -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."""
|
||||
|
Loading…
Reference in New Issue
Block a user