.format
This commit is contained in:
parent
2812569593
commit
7ab4f756fe
22 changed files with 69 additions and 78 deletions
|
@ -19,7 +19,7 @@ def permissions(inp, bot=None, notice=None):
|
||||||
for k in permissions:
|
for k in permissions:
|
||||||
groups.append(k)
|
groups.append(k)
|
||||||
if not groups:
|
if not groups:
|
||||||
notice("%s is not a group with permissions" % inp)
|
notice("{} is not a group with permissions".format(inp))
|
||||||
return None
|
return None
|
||||||
|
|
||||||
for v in groups:
|
for v in groups:
|
||||||
|
@ -27,10 +27,10 @@ def permissions(inp, bot=None, notice=None):
|
||||||
for value in permissions[v]["users"]:
|
for value in permissions[v]["users"]:
|
||||||
members = members + value + ", "
|
members = members + value + ", "
|
||||||
if members:
|
if members:
|
||||||
notice("the members in the %s group are.." % v)
|
notice("the members in the {} group are..".format(v))
|
||||||
notice(members[:-2])
|
notice(members[:-2])
|
||||||
else:
|
else:
|
||||||
notice("there are no members in the %s group" % v)
|
notice("there are no members in the {} group".format(v))
|
||||||
|
|
||||||
|
|
||||||
@hook.command(permissions=["permissions_users"])
|
@hook.command(permissions=["permissions_users"])
|
||||||
|
@ -51,7 +51,7 @@ def deluser(inp, bot=None, notice=None):
|
||||||
if specgroup == k:
|
if specgroup == k:
|
||||||
groups.append(k)
|
groups.append(k)
|
||||||
if not groups:
|
if not groups:
|
||||||
notice("%s is not a group with permissions" % inp[1])
|
notice("{} is not a group with permissions".format(inp[1]))
|
||||||
return None
|
return None
|
||||||
|
|
||||||
removed = 0
|
removed = 0
|
||||||
|
@ -61,14 +61,14 @@ def deluser(inp, bot=None, notice=None):
|
||||||
if inp[0] == value:
|
if inp[0] == value:
|
||||||
users.remove(inp[0])
|
users.remove(inp[0])
|
||||||
removed = 1
|
removed = 1
|
||||||
notice("%s has been removed from the group %s" % (inp[0], v))
|
notice("{} has been removed from the group {}".format(inp[0], v))
|
||||||
json.dump(bot.config, open('config', 'w'), sort_keys=True, indent=2)
|
json.dump(bot.config, open('config', 'w'), sort_keys=True, indent=2)
|
||||||
if specgroup:
|
if specgroup:
|
||||||
if removed == 0:
|
if removed == 0:
|
||||||
notice("%s is not in the group %s" % (inp[0], specgroup))
|
notice("{} is not in the group {}".format(inp[0], specgroup))
|
||||||
else:
|
else:
|
||||||
if removed == 0:
|
if removed == 0:
|
||||||
notice("%s is not in any groups" % inp[0])
|
notice("{} is not in any groups".format(inp[0]))
|
||||||
|
|
||||||
|
|
||||||
@hook.command(permissions=["permissions_users"])
|
@hook.command(permissions=["permissions_users"])
|
||||||
|
@ -89,14 +89,14 @@ def adduser(inp, bot=None, notice=None):
|
||||||
try:
|
try:
|
||||||
users = permissions[targetgroup]["users"]
|
users = permissions[targetgroup]["users"]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
notice("no such group as %s" % targetgroup)
|
notice("no such group as {}".format(targetgroup))
|
||||||
return None
|
return None
|
||||||
if user in users:
|
if user in users:
|
||||||
notice("%s is already in %s" % (user, targetgroup))
|
notice("{} is already in {}".format(user, targetgroup))
|
||||||
return None
|
return None
|
||||||
|
|
||||||
users.append(user)
|
users.append(user)
|
||||||
notice("%s has been added to the group %s" % (user, targetgroup))
|
notice("{} has been added to the group {}".format(user, targetgroup))
|
||||||
users.sort()
|
users.sort()
|
||||||
json.dump(bot.config, open('config', 'w'), sort_keys=True, indent=2)
|
json.dump(bot.config, open('config', 'w'), sort_keys=True, indent=2)
|
||||||
|
|
||||||
|
@ -106,9 +106,9 @@ def adduser(inp, bot=None, notice=None):
|
||||||
def stop(inp, nick=None, conn=None):
|
def stop(inp, nick=None, conn=None):
|
||||||
"""stop [reason] -- Kills the bot with [reason] as its quit message."""
|
"""stop [reason] -- Kills the bot with [reason] as its quit message."""
|
||||||
if inp:
|
if inp:
|
||||||
conn.cmd("QUIT", ["Killed by %s (%s)" % (nick, inp)])
|
conn.cmd("QUIT", ["Killed by {} ({})".format(nick, inp)])
|
||||||
else:
|
else:
|
||||||
conn.cmd("QUIT", ["Killed by %s." % nick])
|
conn.cmd("QUIT", ["Killed by {}.".format(nick)])
|
||||||
time.sleep(5)
|
time.sleep(5)
|
||||||
os.execl("./cloudbot", "cloudbot", "stop")
|
os.execl("./cloudbot", "cloudbot", "stop")
|
||||||
|
|
||||||
|
@ -117,9 +117,9 @@ def stop(inp, nick=None, conn=None):
|
||||||
def restart(inp, nick=None, conn=None):
|
def restart(inp, nick=None, conn=None):
|
||||||
"""restart [reason] -- Restarts the bot with [reason] as its quit message."""
|
"""restart [reason] -- Restarts the bot with [reason] as its quit message."""
|
||||||
if inp:
|
if inp:
|
||||||
conn.cmd("QUIT", ["Restarted by %s (%s)" % (nick, inp)])
|
conn.cmd("QUIT", ["Restarted by {} ({})".format(nick, inp)])
|
||||||
else:
|
else:
|
||||||
conn.cmd("QUIT", ["Restarted by %s." % nick])
|
conn.cmd("QUIT", ["Restarted by {}.".format(nick)])
|
||||||
time.sleep(5)
|
time.sleep(5)
|
||||||
os.execl("./cloudbot", "cloudbot", "restart")
|
os.execl("./cloudbot", "cloudbot", "restart")
|
||||||
|
|
||||||
|
@ -133,7 +133,7 @@ def clearlogs(inp, input=None):
|
||||||
@hook.command(permissions=["botcontrol"])
|
@hook.command(permissions=["botcontrol"])
|
||||||
def join(inp, conn=None, notice=None):
|
def join(inp, conn=None, notice=None):
|
||||||
"""join <channel> -- Joins <channel>."""
|
"""join <channel> -- Joins <channel>."""
|
||||||
notice("Attempting to join %s..." % inp)
|
notice("Attempting to join {}...".format(inp))
|
||||||
conn.join(inp)
|
conn.join(inp)
|
||||||
|
|
||||||
|
|
||||||
|
@ -146,7 +146,7 @@ def part(inp, conn=None, chan=None, notice=None):
|
||||||
target = inp
|
target = inp
|
||||||
else:
|
else:
|
||||||
target = chan
|
target = chan
|
||||||
notice("Attempting to leave %s..." % target)
|
notice("Attempting to leave {}...".format(target))
|
||||||
conn.part(target)
|
conn.part(target)
|
||||||
|
|
||||||
|
|
||||||
|
@ -159,7 +159,7 @@ def cycle(inp, conn=None, chan=None, notice=None):
|
||||||
target = inp
|
target = inp
|
||||||
else:
|
else:
|
||||||
target = chan
|
target = chan
|
||||||
notice("Attempting to cycle %s..." % target)
|
notice("Attempting to cycle {}...".format(target})
|
||||||
conn.part(target)
|
conn.part(target)
|
||||||
conn.join(target)
|
conn.join(target)
|
||||||
|
|
||||||
|
@ -170,7 +170,7 @@ def nick(inp, notice=None, conn=None):
|
||||||
if not re.match("^[A-Za-z0-9_|.-\]\[]*$", inp.lower()):
|
if not re.match("^[A-Za-z0-9_|.-\]\[]*$", inp.lower()):
|
||||||
notice("Invalid username!")
|
notice("Invalid username!")
|
||||||
return
|
return
|
||||||
notice("Attempting to change nick to \"%s\"..." % inp)
|
notice("Attempting to change nick to \"{}\"...".format(inp))
|
||||||
conn.set_nick(inp)
|
conn.set_nick(inp)
|
||||||
|
|
||||||
|
|
||||||
|
@ -189,10 +189,10 @@ def say(inp, conn=None, chan=None):
|
||||||
inp = inp.split(" ")
|
inp = inp.split(" ")
|
||||||
if inp[0][0] == "#":
|
if inp[0][0] == "#":
|
||||||
message = " ".join(inp[1:])
|
message = " ".join(inp[1:])
|
||||||
out = "PRIVMSG %s :%s" % (inp[0], message)
|
out = "PRIVMSG {} :{}".format(inp[0], message)
|
||||||
else:
|
else:
|
||||||
message = " ".join(inp[0:])
|
message = " ".join(inp[0:])
|
||||||
out = "PRIVMSG %s :%s" % (chan, message)
|
out = "PRIVMSG {} :{}".format(chan, message)
|
||||||
conn.send(out)
|
conn.send(out)
|
||||||
|
|
||||||
|
|
||||||
|
@ -208,11 +208,11 @@ def me(inp, conn=None, chan=None):
|
||||||
for x in inp[1:]:
|
for x in inp[1:]:
|
||||||
message = message + x + " "
|
message = message + x + " "
|
||||||
message = message[:-1]
|
message = message[:-1]
|
||||||
out = "PRIVMSG %s :\x01ACTION %s\x01" % (inp[0], message)
|
out = "PRIVMSG {} :\x01ACTION {}\x01".format(inp[0], message)
|
||||||
else:
|
else:
|
||||||
message = ""
|
message = ""
|
||||||
for x in inp[0:]:
|
for x in inp[0:]:
|
||||||
message = message + x + " "
|
message = message + x + " "
|
||||||
message = message[:-1]
|
message = message[:-1]
|
||||||
out = "PRIVMSG %s :\x01ACTION %s\x01" % (chan, message)
|
out = "PRIVMSG {} :\x01ACTION {}\x01".format(chan, message)
|
||||||
conn.send(out)
|
conn.send(out)
|
||||||
|
|
|
@ -100,7 +100,7 @@ def insult(inp, nick=None, me=None, conn=None, notice=None):
|
||||||
else:
|
else:
|
||||||
target = inp
|
target = inp
|
||||||
|
|
||||||
out = 'insults %s... "%s"' % (target, random.choice(insults))
|
out = 'insults {}... "{}"'.format(target, random.choice(insults))
|
||||||
me(out)
|
me(out)
|
||||||
|
|
||||||
|
|
||||||
|
@ -118,5 +118,5 @@ def flirt(inp, me=None, conn=None, notice=None):
|
||||||
else:
|
else:
|
||||||
target = inp
|
target = inp
|
||||||
|
|
||||||
out = 'flirts with %s... "%s"' % (target, random.choice(flirts))
|
out = 'flirts with {}... "{}"'.format(target, random.choice(flirts))
|
||||||
me(out)
|
me(out)
|
||||||
|
|
|
@ -12,5 +12,5 @@ def bitcoin(inp, say=None):
|
||||||
'low': data['low']['display_short'],
|
'low': data['low']['display_short'],
|
||||||
'vol': data['vol']['display_short'],
|
'vol': data['vol']['display_short'],
|
||||||
}
|
}
|
||||||
say("Current: \x0307%(buy)s\x0f - High: \x0307%(high)s\x0f"
|
say("Current: \x0307{}\x0f - High: \x0307{}\x0f"
|
||||||
" - Low: \x0307%(low)s\x0f - Volume: %(vol)s" % ticker)
|
" - Low: \x0307{}\x0f - Volume: {}".format(data['buy'],data['high'],data['low'],data['vol']))
|
||||||
|
|
|
@ -76,7 +76,7 @@ def bf(inp):
|
||||||
if steps > MAX_STEPS:
|
if steps > MAX_STEPS:
|
||||||
if output == '':
|
if output == '':
|
||||||
output = '(no output)'
|
output = '(no output)'
|
||||||
output += '[exceeded %d iterations]' % MAX_STEPS
|
output += '[exceeded {} iterations]'.format(MAX_STEPS)
|
||||||
break
|
break
|
||||||
|
|
||||||
stripped_output = re.sub(r'[\x00-\x1F]', '', output)
|
stripped_output = re.sub(r'[\x00-\x1F]', '', output)
|
||||||
|
|
|
@ -15,11 +15,10 @@ def coin(inp, me=None):
|
||||||
amount = 1
|
amount = 1
|
||||||
|
|
||||||
if amount == 1:
|
if amount == 1:
|
||||||
me("flips a coin and gets %s." % random.choice(["heads", "tails"]))
|
me("flips a coin and gets {}.".format(random.choice(["heads", "tails"])))
|
||||||
elif amount == 0:
|
elif amount == 0:
|
||||||
me("makes a coin flipping motion with its hands.")
|
me("makes a coin flipping motion with its hands.")
|
||||||
else:
|
else:
|
||||||
heads = int(random.normalvariate(.5 * amount, (.75 * amount) ** .5))
|
heads = int(random.normalvariate(.5 * amount, (.75 * amount) ** .5))
|
||||||
tails = amount - heads
|
tails = amount - heads
|
||||||
me("flips %i coins and gets "
|
me("flips {} coins and gets {} heads and {} tails.".format(amount, heads, tails))
|
||||||
"%i heads and %i tails." % (amount, heads, tails))
|
|
||||||
|
|
|
@ -15,4 +15,4 @@ def ctcp_ping(inp, notice=None):
|
||||||
|
|
||||||
@hook.regex(r'^\x01TIME\x01$')
|
@hook.regex(r'^\x01TIME\x01$')
|
||||||
def ctcp_time(inp, notice=None):
|
def ctcp_time(inp, notice=None):
|
||||||
notice('\x01TIME: The time is: %s' % time.strftime("%r", time.localtime()))
|
notice('\x01TIME: The time is: {}'.format(time.strftime("%r", time.localtime())))
|
||||||
|
|
|
@ -25,16 +25,12 @@ def onjoin(paraml, conn=None, bot=None):
|
||||||
nickserv_account_name = conn.conf.get('nickserv_user', '')
|
nickserv_account_name = conn.conf.get('nickserv_user', '')
|
||||||
nickserv_command = conn.conf.get('nickserv_command', 'IDENTIFY')
|
nickserv_command = conn.conf.get('nickserv_command', 'IDENTIFY')
|
||||||
if nickserv_password:
|
if nickserv_password:
|
||||||
print "Found a password..."
|
|
||||||
if nickserv_password in bot.config['censored_strings']:
|
if nickserv_password in bot.config['censored_strings']:
|
||||||
bot.config['censored_strings'].remove(nickserv_password)
|
bot.config['censored_strings'].remove(nickserv_password)
|
||||||
if nickserv_account_name:
|
if nickserv_account_name:
|
||||||
print "Found an account name..."
|
conn.msg(nickserv_name, "{} {} {}".format([nickserv_command, nickserv_account_name, nickserv_password]))
|
||||||
print "Sending"," ".join([nickserv_command, nickserv_account_name, nickserv_password]),"to",nickserv_name
|
|
||||||
conn.msg(nickserv_name, " ".join([nickserv_command, nickserv_account_name, nickserv_password]))
|
|
||||||
else:
|
else:
|
||||||
print "Sending"," ".join([nickserv_command, nickserv_password]),"to",nickserv_name
|
conn.msg(nickserv_name, "{} {}".format([nickserv_command, nickserv_password]))
|
||||||
conn.msg(nickserv_name, " ".join([nickserv_command, nickserv_password]))
|
|
||||||
bot.config['censored_strings'].append(nickserv_password)
|
bot.config['censored_strings'].append(nickserv_password)
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
||||||
|
|
|
@ -20,11 +20,11 @@ def correction(inp, say=None, notice=None, db=None):
|
||||||
message = last_message[1].replace("\x01ACTION ", "/me ").replace("\x01", "")
|
message = last_message[1].replace("\x01ACTION ", "/me ").replace("\x01", "")
|
||||||
else:
|
else:
|
||||||
message = last_message[1]
|
message = last_message[1]
|
||||||
say("%s meant to say: %s" % (nick, message.replace(find, "\x02" + replace + "\x02")))
|
say("{} meant to say: {}".format(nick, message.replace(find, "\x02" + replace + "\x02")))
|
||||||
else:
|
else:
|
||||||
notice("%s can't be found in your last message" % find)
|
notice("{} can't be found in your last message".format(find))
|
||||||
else:
|
else:
|
||||||
if nick == input.nick:
|
if nick == input.nick:
|
||||||
notice("I haven't seen you say anything here yet")
|
notice("I haven't seen you say anything here yet")
|
||||||
else:
|
else:
|
||||||
notice("I haven't seen %s say anything here yet" % nick)
|
notice("I haven't seen {} say anything here yet".format(nick))
|
||||||
|
|
|
@ -84,6 +84,6 @@ def dice(inp):
|
||||||
return "Thanks for overflowing a float, jerk >:["
|
return "Thanks for overflowing a float, jerk >:["
|
||||||
|
|
||||||
if desc:
|
if desc:
|
||||||
return "%s: %d (%s)" % (desc.strip(), total, ", ".join(rolls))
|
return "{}: {} ({})".format(desc.strip(), total, ", ".join(rolls))
|
||||||
else:
|
else:
|
||||||
return "%d (%s)" % (total, ", ".join(rolls))
|
return "{} ({})".format(total, ", ".join(rolls))
|
||||||
|
|
|
@ -21,11 +21,11 @@ def define(inp):
|
||||||
return 'No results for ' + inp + ' :('
|
return 'No results for ' + inp + ' :('
|
||||||
|
|
||||||
def format_output(show_examples):
|
def format_output(show_examples):
|
||||||
result = '%s: ' % h.xpath('//dt[@class="title-word"]/a/text()')[0]
|
result = '{}: '.format(h.xpath('//dt[@class="title-word"]/a/text()')[0])
|
||||||
|
|
||||||
correction = h.xpath('//span[@class="correct-word"]/text()')
|
correction = h.xpath('//span[@class="correct-word"]/text()')
|
||||||
if correction:
|
if correction:
|
||||||
result = 'Definition for "%s": ' % correction[0]
|
result = 'Definition for "{}": '.format(correction[0])
|
||||||
|
|
||||||
sections = []
|
sections = []
|
||||||
for section in definition:
|
for section in definition:
|
||||||
|
@ -40,7 +40,7 @@ def define(inp):
|
||||||
for article in sections:
|
for article in sections:
|
||||||
result += article[0]
|
result += article[0]
|
||||||
if len(article) > 2:
|
if len(article) > 2:
|
||||||
result += ' '.join('%d. %s' % (n + 1, section)
|
result += ' '.join('{}. {}'.format(n + 1, section)
|
||||||
for n, section in enumerate(article[1:]))
|
for n, section in enumerate(article[1:]))
|
||||||
else:
|
else:
|
||||||
result += article[1] + ' '
|
result += article[1] + ' '
|
||||||
|
@ -76,7 +76,7 @@ def etymology(inp):
|
||||||
etym = h.xpath('//dl')
|
etym = h.xpath('//dl')
|
||||||
|
|
||||||
if not etym:
|
if not etym:
|
||||||
return 'No etymology found for ' + inp + ' :('
|
return 'No etymology found for {} :('.format(inp)
|
||||||
|
|
||||||
etym = etym[0].text_content()
|
etym = etym[0].text_content()
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,6 @@ def down(inp):
|
||||||
# http://mail.python.org/pipermail/python-list/2006-December/589854.html
|
# http://mail.python.org/pipermail/python-list/2006-December/589854.html
|
||||||
try:
|
try:
|
||||||
http.get(inp, get_method='HEAD')
|
http.get(inp, get_method='HEAD')
|
||||||
return inp + ' seems to be up'
|
return '{} seems to be up'.format(inp)
|
||||||
except http.URLError:
|
except http.URLError:
|
||||||
return inp + ' seems to be down'
|
return '{} seems to be down'.format(inp)
|
||||||
|
|
|
@ -24,6 +24,6 @@ def drama(inp):
|
||||||
summary = " ".join(p.text_content().splitlines())
|
summary = " ".join(p.text_content().splitlines())
|
||||||
summary = re.sub("\[\d+\]", "", summary)
|
summary = re.sub("\[\d+\]", "", summary)
|
||||||
summary = text.truncate_str(summary, 220)
|
summary = text.truncate_str(summary, 220)
|
||||||
return "%s :: %s" % (summary, url)
|
return "{} :: {}".format(summary, url)
|
||||||
|
|
||||||
return "Unknown Error."
|
return "Unknown Error."
|
||||||
|
|
|
@ -18,4 +18,4 @@ def eightball(input, me=None):
|
||||||
in electronic form. Ask and it shall be answered!"""
|
in electronic form. Ask and it shall be answered!"""
|
||||||
|
|
||||||
magic = text.multiword_replace(random.choice(responses), color_codes)
|
magic = text.multiword_replace(random.choice(responses), color_codes)
|
||||||
me("shakes the magic 8 ball... %s" % magic)
|
me("shakes the magic 8 ball... {}".format(magic))
|
||||||
|
|
|
@ -34,4 +34,4 @@ def fact(inp, say=False, nick=False):
|
||||||
|
|
||||||
url = web.try_isgd(link)
|
url = web.try_isgd(link)
|
||||||
|
|
||||||
return "%s - %s" % (fact, url)
|
return "{} - {}".format(fact, url)
|
||||||
|
|
|
@ -62,14 +62,12 @@ def remember(inp, nick='', db=None, notice=None):
|
||||||
|
|
||||||
if old_data:
|
if old_data:
|
||||||
if append:
|
if append:
|
||||||
notice("Appending \x02%s\x02 to \x02%s\x02" % (new_data, old_data))
|
notice("Appending \x02{}\x02 to \x02{}\x02".format(new_data, old_data))
|
||||||
else:
|
else:
|
||||||
notice('Remembering \x02%s\x02 for \x02%s\x02. Type ?%s to see it.'
|
notice('Remembering \x02{}\x02 for \x02{}\x02. Type ?{} to see it.'.format(data, word, word))
|
||||||
% (data, word, word))
|
notice('Previous data was \x02{}\x02'.format(old_data))
|
||||||
notice('Previous data was \x02%s\x02' % old_data)
|
|
||||||
else:
|
else:
|
||||||
notice('Remembering \x02%s\x02 for \x02%s\x02. Type ?%s to see it.'
|
notice('Remembering \x02{}\x02 for \x02{}\x02. Type ?{} to see it.'.format(data, word, word))
|
||||||
% (data, word, word))
|
|
||||||
|
|
||||||
|
|
||||||
@hook.command("f", permissions=["delfactoid"])
|
@hook.command("f", permissions=["delfactoid"])
|
||||||
|
@ -131,7 +129,7 @@ def factoid(inp, say=None, db=None, bot=None, me=None, conn=None, input=None):
|
||||||
# factoid preprocessors
|
# factoid preprocessors
|
||||||
if data.startswith("<py>"):
|
if data.startswith("<py>"):
|
||||||
code = data[4:].strip()
|
code = data[4:].strip()
|
||||||
variables = 'input="""%s"""; nick="%s"; chan="%s"; bot_nick="%s";' % (arguments.replace('"', '\\"'),
|
variables = 'input="""{}"""; nick="{}"; chan="{}"; bot_nick="{}";'.format(arguments.replace('"', '\\"'),
|
||||||
input.nick, input.chan,
|
input.nick, input.chan,
|
||||||
input.conn.nick)
|
input.conn.nick)
|
||||||
result = execute.eval_py(variables + code)
|
result = execute.eval_py(variables + code)
|
||||||
|
@ -152,6 +150,6 @@ def factoid(inp, say=None, db=None, bot=None, me=None, conn=None, input=None):
|
||||||
say("Could not fetch URL.")
|
say("Could not fetch URL.")
|
||||||
else:
|
else:
|
||||||
if prefix_on:
|
if prefix_on:
|
||||||
say("\x02[%s]:\x02 %s" % (factoid_id, result))
|
say("\x02[{}]:\x02 {}".format(factoid_id, result))
|
||||||
else:
|
else:
|
||||||
say(result)
|
say(result)
|
||||||
|
|
|
@ -23,7 +23,7 @@ def fml(inp, reply=None):
|
||||||
# grab the last item in the fml cache and remove it
|
# grab the last item in the fml cache and remove it
|
||||||
id, text = fml_cache.pop()
|
id, text = fml_cache.pop()
|
||||||
# reply with the fml we grabbed
|
# reply with the fml we grabbed
|
||||||
reply('(#%d) %s' % (id, text))
|
reply('(#{}) {}'.format(id, text))
|
||||||
# refresh fml cache if its getting empty
|
# refresh fml cache if its getting empty
|
||||||
if len(fml_cache) < 3:
|
if len(fml_cache) < 3:
|
||||||
refresh_cache()
|
refresh_cache()
|
||||||
|
|
|
@ -11,9 +11,9 @@ def calc(inp):
|
||||||
result = soup.find('h2', {'class': 'r'})
|
result = soup.find('h2', {'class': 'r'})
|
||||||
exponent = result.find('sup')
|
exponent = result.find('sup')
|
||||||
if not result:
|
if not result:
|
||||||
return "Could not calculate '%s'" % inp
|
return "Could not calculate '{}'".format(inp)
|
||||||
|
|
||||||
if not exponent:
|
if not exponent:
|
||||||
return result.contents[0]
|
return result.contents[0]
|
||||||
if exponent:
|
if exponent:
|
||||||
return result.contents[0] + "^" + exponent.contents[0]
|
return "{}^{}".format(result.contents[0]*2)
|
||||||
|
|
|
@ -31,7 +31,7 @@ def ghissues(inp):
|
||||||
repo = shortcuts[args[0]]
|
repo = shortcuts[args[0]]
|
||||||
else:
|
else:
|
||||||
repo = args[0]
|
repo = args[0]
|
||||||
url = "https://api.github.com/repos/%s/issues" % repo
|
url = "https://api.github.com/repos/{}/issues".format(repo)
|
||||||
except IndexError:
|
except IndexError:
|
||||||
return "Invalid syntax. .github issues username/repo [number]"
|
return "Invalid syntax. .github issues username/repo [number]"
|
||||||
try:
|
try:
|
||||||
|
@ -50,13 +50,13 @@ def ghissues(inp):
|
||||||
return "Repo has no open issues"
|
return "Repo has no open issues"
|
||||||
except ValueError:
|
except ValueError:
|
||||||
return "Invalid data returned. Check arguments (.github issues username/repo [number]"
|
return "Invalid data returned. Check arguments (.github issues username/repo [number]"
|
||||||
fmt = "Issue: #%s (%s) by %s: %s | %s %s" # (number, state, user.login, title, truncate(body), gitio.gitio(data.url))
|
fmt = "Issue: #{} ({}) by {}: {} | {} {}".format(number, state, user.login, title, truncate(body), gitio.gitio(data.url))
|
||||||
fmt1 = "Issue: #%s (%s) by %s: %s %s" # (number, state, user.login, title, gitio.gitio(data.url))
|
fmt1 = "Issue: #{} ({}) by {}: {} {}".format(number, state, user.login, title, gitio.gitio(data.url))
|
||||||
number = data["number"]
|
number = data["number"]
|
||||||
if data["state"] == "open":
|
if data["state"] == "open":
|
||||||
state = u"\x033\x02OPEN\x02\x0f"
|
state = u"\x033\x02OPEN\x02\x0f"
|
||||||
else:
|
else:
|
||||||
state = u"\x034\x02CLOSED\x02\x0f by %s" % data["closed_by"]["login"]
|
state = u"\x034\x02CLOSED\x02\x0f by {}".format(data["closed_by"]["login"])
|
||||||
user = data["user"]["login"]
|
user = data["user"]["login"]
|
||||||
title = data["title"]
|
title = data["title"]
|
||||||
summary = truncate(data["body"])
|
summary = truncate(data["body"])
|
||||||
|
|
|
@ -17,8 +17,7 @@ def googleimage(inp):
|
||||||
|
|
||||||
parsed = api_get('images', inp)
|
parsed = api_get('images', inp)
|
||||||
if not 200 <= parsed['responseStatus'] < 300:
|
if not 200 <= parsed['responseStatus'] < 300:
|
||||||
raise IOError('error searching for images: %d: %s' % (
|
raise IOError('error searching for images: {}: {}'.format(parsed['responseStatus'], ''))
|
||||||
parsed['responseStatus'], ''))
|
|
||||||
if not parsed['responseData']['results']:
|
if not parsed['responseData']['results']:
|
||||||
return 'no images found'
|
return 'no images found'
|
||||||
return random.choice(parsed['responseData']['results'][:10]) \
|
return random.choice(parsed['responseData']['results'][:10]) \
|
||||||
|
@ -33,8 +32,7 @@ def google(inp):
|
||||||
|
|
||||||
parsed = api_get('web', inp)
|
parsed = api_get('web', inp)
|
||||||
if not 200 <= parsed['responseStatus'] < 300:
|
if not 200 <= parsed['responseStatus'] < 300:
|
||||||
raise IOError('error searching for pages: %d: %s' % (
|
raise IOError('error searching for pages: {}: {}'.format(parsed['responseStatus'], ''))
|
||||||
parsed['responseStatus'], ''))
|
|
||||||
if not parsed['responseData']['results']:
|
if not parsed['responseData']['results']:
|
||||||
return 'No results found.'
|
return 'No results found.'
|
||||||
|
|
||||||
|
@ -50,6 +48,6 @@ def google(inp):
|
||||||
content = http.html.fromstring(content).text_content()
|
content = http.html.fromstring(content).text_content()
|
||||||
content = text.truncate_str(content, 150)
|
content = text.truncate_str(content, 150)
|
||||||
|
|
||||||
out = '%s -- \x02%s\x02: "%s"' % (result['unescapedUrl'], title, content)
|
out = '{} -- \x02{}\x02: "{}"'.format(result['unescapedUrl'], title, content)
|
||||||
|
|
||||||
return out
|
return out
|
||||||
|
|
|
@ -46,7 +46,7 @@ def horoscope(inp, db=None, notice=None, nick=None):
|
||||||
#result = unicode(result, "utf8").replace('flight ','')
|
#result = unicode(result, "utf8").replace('flight ','')
|
||||||
|
|
||||||
if not title:
|
if not title:
|
||||||
return "Could not get the horoscope for %s." % inp
|
return "Could not get the horoscope for {}.".format(inp)
|
||||||
|
|
||||||
if inp and not dontsave:
|
if inp and not dontsave:
|
||||||
db.execute("insert or replace into horoscope(nick, sign) values (?,?)",
|
db.execute("insert or replace into horoscope(nick, sign) values (?,?)",
|
||||||
|
|
|
@ -34,7 +34,7 @@ def ignored(inp, notice=None, bot=None):
|
||||||
"""ignored -- Lists ignored channels/users."""
|
"""ignored -- Lists ignored channels/users."""
|
||||||
ignorelist = bot.config["plugins"]["ignore"]["ignored"]
|
ignorelist = bot.config["plugins"]["ignore"]["ignored"]
|
||||||
if ignorelist:
|
if ignorelist:
|
||||||
notice("Ignored channels/users are: %s" % ", ".join(ignorelist))
|
notice("Ignored channels/users are: {}".format(", ".join(ignorelist)))
|
||||||
else:
|
else:
|
||||||
notice("No masks are currently ignored.")
|
notice("No masks are currently ignored.")
|
||||||
return
|
return
|
||||||
|
@ -46,9 +46,9 @@ def ignore(inp, notice=None, bot=None, config=None):
|
||||||
target = inp.lower()
|
target = inp.lower()
|
||||||
ignorelist = bot.config["plugins"]["ignore"]["ignored"]
|
ignorelist = bot.config["plugins"]["ignore"]["ignored"]
|
||||||
if target in ignorelist:
|
if target in ignorelist:
|
||||||
notice("%s is already ignored." % target)
|
notice("{} is already ignored.".format(target))
|
||||||
else:
|
else:
|
||||||
notice("%s has been ignored." % target)
|
notice("{} has been ignored.".format(target))
|
||||||
ignorelist.append(target)
|
ignorelist.append(target)
|
||||||
ignorelist.sort()
|
ignorelist.sort()
|
||||||
json.dump(bot.config, open('config', 'w'), sort_keys=True, indent=2)
|
json.dump(bot.config, open('config', 'w'), sort_keys=True, indent=2)
|
||||||
|
@ -62,10 +62,10 @@ def unignore(inp, notice=None, bot=None, config=None):
|
||||||
target = inp.lower()
|
target = inp.lower()
|
||||||
ignorelist = bot.config["plugins"]["ignore"]["ignored"]
|
ignorelist = bot.config["plugins"]["ignore"]["ignored"]
|
||||||
if target in ignorelist:
|
if target in ignorelist:
|
||||||
notice("%s has been unignored." % target)
|
notice("{} has been unignored.".format(target))
|
||||||
ignorelist.remove(target)
|
ignorelist.remove(target)
|
||||||
ignorelist.sort()
|
ignorelist.sort()
|
||||||
json.dump(bot.config, open('config', 'w'), sort_keys=True, indent=2)
|
json.dump(bot.config, open('config', 'w'), sort_keys=True, indent=2)
|
||||||
else:
|
else:
|
||||||
notice("%s is not ignored." % target)
|
notice("{} is not ignored.".format(target))
|
||||||
return
|
return
|
||||||
|
|
|
@ -21,7 +21,7 @@ def imdb(inp):
|
||||||
if content.get('Error', None) == 'Movie not found!':
|
if content.get('Error', None) == 'Movie not found!':
|
||||||
return 'Movie not found!'
|
return 'Movie not found!'
|
||||||
elif content['Response'] == 'True':
|
elif content['Response'] == 'True':
|
||||||
content['URL'] = 'http://www.imdb.com/title/%(imdbID)s' % content
|
content['URL'] = 'http://www.imdb.com/title/{}'.format(content['imdbID'])
|
||||||
|
|
||||||
out = '\x02%(Title)s\x02 (%(Year)s) (%(Genre)s): %(Plot)s'
|
out = '\x02%(Title)s\x02 (%(Year)s) (%(Genre)s): %(Plot)s'
|
||||||
if content['Runtime'] != 'N/A':
|
if content['Runtime'] != 'N/A':
|
||||||
|
|
Reference in a new issue