names[0] = names[0][1:] #remove colon
for n in names:
user = self.parent.user(n.lstrip('@+'))
- if n[0] == '@':
+ if n.startswith('@'):
chan.userjoin(user, 'op')
- elif n[0] == '+':
+ elif n.startswith('+'):
chan.userjoin(user, 'voice')
else:
chan.userjoin(user)
if len(msg) == 0:
return
- triggerused = msg[0] == self.parent.trigger
- if triggerused: msg = msg[1:]
+ triggerused = msg.startswith(self.parent.trigger)
+ if triggerused: msg = msg[len(self.parent.trigger):]
pieces = msg.split()
if target == self.nick:
- if msg[0] == "\001": #ctcp
+ if msg.startswith("\001"): #ctcp
msg = msg.strip("\001")
if msg == "VERSION":
self.msg(user, "\001VERSION Erebus v%d.%d - http://github.com/zonidjan/erebus" % (self.parent.APIVERSION, self.parent.RELEASE))
return
if len(pieces) > 1:
chanword = pieces[1]
- if chanword[0] == '#':
+ if chanword.startswith('#'):
chanparam = self.parent.channel(chanword)
if target != self.nick: # message was sent to a channel
chan = self.parent.channel(target)
try:
- if msg[0] == '*': # message may be addressed to bot by "*BOTNICK" trigger?
+ if msg.startswith('*'): # message may be addressed to bot by "*BOTNICK" trigger?
if pieces[0][1:].lower() == self.nick.lower():
pieces.pop(0) # command actually starts with next word
msg = ' '.join(pieces) # command actually starts with next word
target = str(target)
- if target[0] == '#': command = "PRIVMSG %s :%s" % (target, msg)
+ if target.startswith('#'): command = "PRIVMSG %s :%s" % (target, msg)
else: command = "NOTICE %s :%s" % (target, msg)
return command
def _kick(bot, user, chan, realtarget, *args):
people = []
- if args[0][0] == "#":
+ if args[0].startswith("#"):
people = bot.parent.getuserbyauth(args[0][1:])
else:
people = [args[0]]
maxlevel = 100
filepath = bot.parent.cfg.get('help', 'path', default='./help/%d.txt')
for arg in args:
- if arg[0] == "@":
+ if arg.startswith("@"):
module = arg[1:]
- elif arg[0] == "#" and user.glevel >= lib.OWNER:
+ elif arg.startswith("#") and user.glevel >= lib.ADMIN:
minlevel = maxlevel = int(arg[1:])
else:
filepath = arg
for line in sorted(lines):
bot.slowmsg(user, str(line))
bot.slowmsg(user, "End of command listing.")
- elif args[0][0] == "@":
+ elif args[0].startswith("@"):
lines = []
mod = args[0][1:].lower()
for func in helps.itervalues():
def _getbot(bot, user, chan, realtarget, *args):
target = None
- if args[0][0] == "#":
+ if args[0].startswith("#"):
target = bot.parent.channel(args[0])
print "target = %s" % (target)
if target is not None:
nextqid = random.randrange(0, len(self.questions))
nextq = self.questions[nextqid]
- if nextq[0][0] == "!":
+ if nextq[0].startswith("!"):
nextqid = None
nextq = specialQuestion(nextq)
@lib.help("<full question>", "finds a qid given a complete question")
def findq(bot, user, chan, realtarget, *args):
args = list(args)
- if args[0][0] == "@":
+ if args[0].startswith("@"):
cat = args.pop(0)[1:].lower()
questions = state.db['questions'][cat]
else:
@lib.help("[@<category>] <regex>", "finds a qid given a regex or partial question")
def findqre(bot, user, chan, realtarget, *args):
args = list(args)
- if args[0][0] == "@":
+ if args[0].startswith("@"):
cat = args.pop(0)[1:].lower()
questions = state.db['questions'][cat]
else:
@lib.help("[@<category>] <qid>", "displays the q*a for a qid", "category defaults to current")
def showq(bot, user, chan, realtarget, *args):
args = list(args)
- if args[0][0] == "@":
+ if args[0].startswith("@"):
cat = args.pop(0)[1:].lower()
questions = state.db['questions'][cat]
else:
@lib.help("[@<category>] <qid>", "removes a question from the database")
def delq(bot, user, chan, realtarget, *args):
args = list(args)
- if args[0][0] == "@":
+ if args[0].startswith("@"):
cat = args.pop(0)[1:].lower()
questions = state.db['questions'][cat]
else:
@lib.help("[@<category>] <q>*<a>", "adds a question")
def addq(bot, user, chan, realtarget, *args):
args = list(args)
- if args[0][0] == "@":
+ if args[0].startswith("@"):
cat = args.pop(0)[1:].lower()
questions = state.db['questions'][cat]
else:
if thing.auth is not None:
return "#"+thing.auth
elif isinstance(thing, basestring):
- if thing[0] == "#":
+ if thing.startswith("#"):
return thing
else:
if parent.user(thing).auth is not None: