Merge pull request #143 from thenoodle68/develop
Formatting and other things.
This commit is contained in:
commit
f788af8d55
53 changed files with 173 additions and 196 deletions
|
@ -22,7 +22,7 @@ def censor(text):
|
||||||
if 'censored_strings' in bot.config:
|
if 'censored_strings' in bot.config:
|
||||||
if bot.config['censored_strings']:
|
if bot.config['censored_strings']:
|
||||||
words = map(re.escape, bot.config['censored_strings'])
|
words = map(re.escape, bot.config['censored_strings'])
|
||||||
regex = re.compile('(%s)' % "|".join(words))
|
regex = re.compile('({})'.format("|".join(words)))
|
||||||
text = regex.sub(replacement, text)
|
text = regex.sub(replacement, text)
|
||||||
return text
|
return text
|
||||||
|
|
||||||
|
@ -194,7 +194,7 @@ class IRC(object):
|
||||||
|
|
||||||
def join(self, channel):
|
def join(self, channel):
|
||||||
""" makes the bot join a channel """
|
""" makes the bot join a channel """
|
||||||
self.send("JOIN %s" % channel)
|
self.send("JOIN {}".format(channel))
|
||||||
if channel not in self.channels:
|
if channel not in self.channels:
|
||||||
self.channels.append(channel)
|
self.channels.append(channel)
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ class Input(dict):
|
||||||
conn.msg(chan, '(' + nick + ') ' + msg)
|
conn.msg(chan, '(' + nick + ') ' + msg)
|
||||||
|
|
||||||
def me(msg, chan=chan):
|
def me(msg, chan=chan):
|
||||||
conn.msg(chan, "\x01%s %s\x01" % ("ACTION", msg))
|
conn.msg(chan, "\x01{} {}\x01".format("ACTION", msg))
|
||||||
|
|
||||||
def notice(msg, nick=nick):
|
def notice(msg, nick=nick):
|
||||||
conn.cmd('NOTICE', [nick, msg])
|
conn.cmd('NOTICE', [nick, msg])
|
||||||
|
@ -154,9 +154,9 @@ def main(conn, out):
|
||||||
if inp.command == 'PRIVMSG':
|
if inp.command == 'PRIVMSG':
|
||||||
# COMMANDS
|
# COMMANDS
|
||||||
if inp.chan == inp.nick: # private message, no command prefix
|
if inp.chan == inp.nick: # private message, no command prefix
|
||||||
prefix = '^(?:[%s]?|' % command_prefix
|
prefix = '^(?:[{}]?|'.format(command_prefix)
|
||||||
else:
|
else:
|
||||||
prefix = '^(?:[%s]|' % command_prefix
|
prefix = '^(?:[%s]|'.format(command_prefix)
|
||||||
|
|
||||||
command_re = prefix + inp.conn.nick
|
command_re = prefix + inp.conn.nick
|
||||||
command_re += r'[,;:]+\s+)(\w+)(?:$|\s+)(.*)'
|
command_re += r'[,;:]+\s+)(\w+)(?:$|\s+)(.*)'
|
||||||
|
@ -169,7 +169,7 @@ def main(conn, out):
|
||||||
|
|
||||||
if isinstance(command, list): # multiple potential matches
|
if isinstance(command, list): # multiple potential matches
|
||||||
input = Input(conn, *out)
|
input = Input(conn, *out)
|
||||||
input.notice("Did you mean %s or %s?" %
|
input.notice("Did you mean {} or {}?".format
|
||||||
(', '.join(command[:-1]), command[-1]))
|
(', '.join(command[:-1]), command[-1]))
|
||||||
elif command in bot.commands:
|
elif command in bot.commands:
|
||||||
input = Input(conn, *out)
|
input = Input(conn, *out)
|
||||||
|
|
|
@ -18,7 +18,7 @@ def make_signature(f):
|
||||||
|
|
||||||
|
|
||||||
def format_plug(plug, kind='', lpad=0):
|
def format_plug(plug, kind='', lpad=0):
|
||||||
out = ' ' * lpad + '%s:%s:%s' % make_signature(plug[0])
|
out = ' ' * lpad + '{}:{}:{}'.format(make_signature(plug[0]))
|
||||||
if kind == 'command':
|
if kind == 'command':
|
||||||
out += ' ' * (50 - len(out)) + plug[1]['name']
|
out += ' ' * (50 - len(out)) + plug[1]['name']
|
||||||
|
|
||||||
|
@ -118,13 +118,12 @@ def reload(init=False):
|
||||||
for plug in bot.plugs['command']:
|
for plug in bot.plugs['command']:
|
||||||
name = plug[1]['name'].lower()
|
name = plug[1]['name'].lower()
|
||||||
if not re.match(r'^\w+$', name):
|
if not re.match(r'^\w+$', name):
|
||||||
print '### ERROR: invalid command name "%s" (%s)' % (name,
|
print '### ERROR: invalid command name "{}" ({})'.format(name, format_plug(plug))
|
||||||
format_plug(plug))
|
|
||||||
continue
|
continue
|
||||||
if name in bot.commands:
|
if name in bot.commands:
|
||||||
print "### ERROR: command '%s' already registered (%s, %s)" % \
|
print "### ERROR: command '{}' already registered ({}, {})".format(name,
|
||||||
(name, format_plug(bot.commands[name]),
|
format_plug(bot.commands[name]),
|
||||||
format_plug(plug))
|
format_plug(plug))
|
||||||
continue
|
continue
|
||||||
bot.commands[name] = plug
|
bot.commands[name] = plug
|
||||||
|
|
||||||
|
@ -155,7 +154,7 @@ def reload(init=False):
|
||||||
for kind, plugs in sorted(bot.plugs.iteritems()):
|
for kind, plugs in sorted(bot.plugs.iteritems()):
|
||||||
if kind == 'command':
|
if kind == 'command':
|
||||||
continue
|
continue
|
||||||
print ' %s:' % kind
|
print ' {}:'.format(kind)
|
||||||
for plug in plugs:
|
for plug in plugs:
|
||||||
print format_plug(plug, kind=kind, lpad=6)
|
print format_plug(plug, kind=kind, lpad=6)
|
||||||
print
|
print
|
||||||
|
|
|
@ -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)
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import re
|
|
||||||
import random
|
import random
|
||||||
|
|
||||||
from util import hook
|
from util import hook
|
||||||
|
@ -6,13 +5,10 @@ from util import hook
|
||||||
|
|
||||||
@hook.command
|
@hook.command
|
||||||
def choose(inp):
|
def choose(inp):
|
||||||
"""choose <choice1>, [choice2], [choice3] ... [choiceN]
|
"""choose <choice1>, [choice2], [choice3]
|
||||||
Randomly picks one of the given choices."""
|
Randomly picks one of the given choices."""
|
||||||
|
|
||||||
c = re.findall(r'([^,]+)', inp)
|
c = inp.split(" ")
|
||||||
if len(c) == 1:
|
if len(c) == 1:
|
||||||
c = re.findall(r'(\S+)', inp)
|
return 'banana'
|
||||||
if len(c) == 1:
|
|
||||||
return 'The decision is up to you!'
|
|
||||||
|
|
||||||
return random.choice(c).strip()
|
return random.choice(c).strip()
|
||||||
|
|
|
@ -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':
|
||||||
|
|
|
@ -34,10 +34,10 @@ def lastfm(inp, nick='', db=None, bot=None, notice=None):
|
||||||
api_key=api_key, user=user, limit=1)
|
api_key=api_key, user=user, limit=1)
|
||||||
|
|
||||||
if 'error' in response:
|
if 'error' in response:
|
||||||
return "Error: %s." % response["message"]
|
return "Error: {}.".format(response["message"])
|
||||||
|
|
||||||
if not "track" in response["recenttracks"] or len(response["recenttracks"]["track"]) == 0:
|
if not "track" in response["recenttracks"] or len(response["recenttracks"]["track"]) == 0:
|
||||||
return 'No recent tracks for user "%s" found.' % user
|
return 'No recent tracks for user "{}" found.'.format(user)
|
||||||
|
|
||||||
tracks = response["recenttracks"]["track"]
|
tracks = response["recenttracks"]["track"]
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ def lastfm(inp, nick='', db=None, bot=None, notice=None):
|
||||||
# lets see how long ago they listened to it
|
# lets see how long ago they listened to it
|
||||||
time_listened = datetime.fromtimestamp(int(track["date"]["uts"]))
|
time_listened = datetime.fromtimestamp(int(track["date"]["uts"]))
|
||||||
time_since = timesince.timesince(time_listened)
|
time_since = timesince.timesince(time_listened)
|
||||||
ending = ' (%s ago)' % time_since
|
ending = ' ({} ago)'.format(time_since)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
return "error: could not parse track listing"
|
return "error: could not parse track listing"
|
||||||
|
@ -64,11 +64,11 @@ def lastfm(inp, nick='', db=None, bot=None, notice=None):
|
||||||
album = track["album"]["#text"]
|
album = track["album"]["#text"]
|
||||||
artist = track["artist"]["#text"]
|
artist = track["artist"]["#text"]
|
||||||
|
|
||||||
out = '%s %s "%s"' % (user, status, title)
|
out = '{} {} "{}"'.format(user, status, title)
|
||||||
if artist:
|
if artist:
|
||||||
out += " by \x02%s\x0f" % artist
|
out += " by \x02{}\x0f".format(artist)
|
||||||
if album:
|
if album:
|
||||||
out += " from the album \x02%s\x0f" % album
|
out += " from the album \x02{}\x0f".format(album)
|
||||||
|
|
||||||
# append ending based on what type it was
|
# append ending based on what type it was
|
||||||
out += ending
|
out += ending
|
||||||
|
|
|
@ -6,7 +6,7 @@ from util import hook, web, http
|
||||||
def lmgtfy(inp):
|
def lmgtfy(inp):
|
||||||
"""lmgtfy [phrase] - Posts a google link for the specified phrase"""
|
"""lmgtfy [phrase] - Posts a google link for the specified phrase"""
|
||||||
|
|
||||||
link = "http://lmgtfy.com/?q=%s" % http.quote_plus(inp)
|
link = "http://lmgtfy.com/?q={}".format(http.quote_plus(inp))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
return web.isgd(link)
|
return web.isgd(link)
|
||||||
|
|
|
@ -29,7 +29,7 @@ def lyrics(inp):
|
||||||
lyrics = newsoup.find('div', {'style': 'margin-left:10px;margin-right:10px;'}).text.strip()
|
lyrics = newsoup.find('div', {'style': 'margin-left:10px;margin-right:10px;'}).text.strip()
|
||||||
pasteurl = " " + web.haste(lyrics)
|
pasteurl = " " + web.haste(lyrics)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
pasteurl = " (\x02Unable to paste lyrics\x02 [%s])" % str(e)
|
pasteurl = " (\x02Unable to paste lyrics\x02 [{}])".format(str(e))
|
||||||
else:
|
else:
|
||||||
pasteurl = ""
|
pasteurl = ""
|
||||||
artist = div.find('b').text.title()
|
artist = div.find('b').text.title()
|
||||||
|
@ -39,10 +39,10 @@ def lyrics(inp):
|
||||||
spurl = ""
|
spurl = ""
|
||||||
lyricsum = div.find('div').text
|
lyricsum = div.find('div').text
|
||||||
if "\r\n" in lyricsum.strip():
|
if "\r\n" in lyricsum.strip():
|
||||||
lyricsum = " / ".join(lyricsum.strip().split("\r\n")[0:4]) # truncate, format
|
lyricsum = " / ".join(lyricsum.strip().split("\r\n")[0:4]) # truncate, format
|
||||||
else:
|
else:
|
||||||
lyricsum = " / ".join(lyricsum.strip().split("\n")[0:4]) # truncate, format
|
lyricsum = " / ".join(lyricsum.strip().split("\n")[0:4]) # truncate, format
|
||||||
return "\x02%s\x02 by \x02%s\x02 %s%s%s - %s" % (
|
return "\x02{}\x02 by \x02{}\x02 {}{}{} - {}".format(title, artist, web.try_isgd(link), spurl, pasteurl,
|
||||||
title, artist, web.try_isgd(link), spurl, pasteurl, lyricsum[:-3])
|
lyricsum[:-3])
|
||||||
else:
|
else:
|
||||||
return "No song results. " + url + inp.replace(" ", "+")
|
return "No song results. " + url + inp.replace(" ", "+")
|
||||||
|
|
|
@ -36,7 +36,7 @@ def metacritic(inp):
|
||||||
|
|
||||||
title_safe = http.quote_plus(title)
|
title_safe = http.quote_plus(title)
|
||||||
|
|
||||||
url = 'http://www.metacritic.com/search/%s/%s/results' % (cat, title_safe)
|
url = 'http://www.metacritic.com/search/{}/{}/results'.format(cat, title_safe)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
doc = http.get_html(url)
|
doc = http.get_html(url)
|
||||||
|
@ -132,7 +132,6 @@ def metacritic(inp):
|
||||||
except IndexError:
|
except IndexError:
|
||||||
score = None
|
score = None
|
||||||
|
|
||||||
return '[%s] %s - \x02%s/100\x02, %s - %s' % (plat.upper(), name,
|
return '[{}] {} - \x02{}/100\x02, {} - {}'.format(plat.upper(), name, score or 'no score',
|
||||||
score or 'no score',
|
'release: \x02%s\x02' % release if release else 'unreleased',
|
||||||
'release: \x02%s\x02' % release if release else 'unreleased',
|
link)
|
||||||
link)
|
|
||||||
|
|
|
@ -27,13 +27,10 @@ def randombukkitplugin(inp, reply=None):
|
||||||
bukkitver = ", ".join(data['versions'][0]['game_versions'])
|
bukkitver = ", ".join(data['versions'][0]['game_versions'])
|
||||||
link = web.isgd(data['versions'][0]['link'])
|
link = web.isgd(data['versions'][0]['link'])
|
||||||
if description != "":
|
if description != "":
|
||||||
reply("\x02%s\x02, by \x02%s\x02 - %s - (%s) \x02%s"
|
reply("\x02{}\x02, by \x02{}\x02 - {} - ({}) \x02{}".format(name, authors, description, stage, url))
|
||||||
% (name, authors, description, stage, url))
|
|
||||||
else:
|
else:
|
||||||
reply("\x02%s\x02, by \x02%s\x02 (%s) \x02%s"
|
reply("\x02{}\x02, by \x02{}\x02 ({}) \x02{}".format(name, authors, stage, url))
|
||||||
% (name, authors, stage, url))
|
reply("Last release: \x02v{}\x02 for \x02{}\x02 at {} \x02{}\x02".format(lastVersion, bukkitver, lastUpdate, link))
|
||||||
reply("Last release: \x02v%s\x02 for \x02%s\x02 at %s \x02%s\x02"
|
|
||||||
% (lastVersion, bukkitver, lastUpdate, link))
|
|
||||||
|
|
||||||
|
|
||||||
@hook.command('bplugin')
|
@hook.command('bplugin')
|
||||||
|
@ -57,13 +54,10 @@ def bukkitplugin(inp, reply=None):
|
||||||
bukkitver = ", ".join(data['versions'][0]['game_versions'])
|
bukkitver = ", ".join(data['versions'][0]['game_versions'])
|
||||||
link = web.isgd(data['versions'][0]['link'])
|
link = web.isgd(data['versions'][0]['link'])
|
||||||
if description != "":
|
if description != "":
|
||||||
reply("\x02%s\x02, by \x02%s\x02 - %s - (%s) \x02%s"
|
reply("\x02{}\x02, by \x02{}\x02 - {} - ({}) \x02{}".format(name, authors, description, stage, url))
|
||||||
% (name, authors, description, stage, url))
|
|
||||||
else:
|
else:
|
||||||
reply("\x02%s\x02, by \x02%s\x02 (%s) \x02%s"
|
reply("\x02{}\x02, by \x02{}\x02 ({}) \x02{}".format(name, authors, stage, url))
|
||||||
% (name, authors, stage, url))
|
reply("Last release: \x02v{}\x02 for \x02{}\x02 at {} \x02{}\x02".format(lastVersion, bukkitver, lastUpdate, link))
|
||||||
reply("Last release: \x02v%s\x02 for \x02%s\x02 at %s \x02%s\x02"
|
|
||||||
% (lastVersion, bukkitver, lastUpdate, link))
|
|
||||||
|
|
||||||
|
|
||||||
def getplugininfo(inp):
|
def getplugininfo(inp):
|
||||||
|
@ -75,5 +69,5 @@ def getplugininfo(inp):
|
||||||
data = http.get_json("http://api.bukget.org/3/plugins/bukkit/%s/"
|
data = http.get_json("http://api.bukget.org/3/plugins/bukkit/%s/"
|
||||||
% slug)
|
% slug)
|
||||||
except HTTPError as e:
|
except HTTPError as e:
|
||||||
return "Got error: %s" % e
|
return "Got error: {}".format(e)
|
||||||
return data
|
return data
|
||||||
|
|
|
@ -61,16 +61,16 @@ def mcitem(input, reply=None):
|
||||||
|
|
||||||
for id, name in ids:
|
for id, name in ids:
|
||||||
if input == id:
|
if input == id:
|
||||||
results = ["\x02[%s]\x02 %s" % (id, name)]
|
results = ["\x02[{}]\x02 {}".format(id, name)]
|
||||||
break
|
break
|
||||||
elif input in name.lower():
|
elif input in name.lower():
|
||||||
results.append("\x02[%s]\x02 %s" % (id, name))
|
results.append("\x02[{}]\x02 {}".format(id, name))
|
||||||
|
|
||||||
if not results:
|
if not results:
|
||||||
return "No matches found."
|
return "No matches found."
|
||||||
|
|
||||||
if len(results) > 12:
|
if len(results) > 12:
|
||||||
reply("There are too many options, please narrow your search. (%s)" % len(results))
|
reply("There are too many options, please narrow your search. ({})".format(str(len(results))))
|
||||||
return
|
return
|
||||||
|
|
||||||
out = ", ".join(results)
|
out = ", ".join(results)
|
||||||
|
@ -91,7 +91,7 @@ def mcrecipe(input, reply=None):
|
||||||
return "No matches found."
|
return "No matches found."
|
||||||
|
|
||||||
if len(results) > 3:
|
if len(results) > 3:
|
||||||
reply("There are too many options, please narrow your search. (%s)" % len(results))
|
reply("There are too many options, please narrow your search. ({})".format(len(results)))
|
||||||
return
|
return
|
||||||
|
|
||||||
for result in results:
|
for result in results:
|
||||||
|
|
|
@ -50,8 +50,7 @@ def mcping_connect(host, port):
|
||||||
return message
|
return message
|
||||||
|
|
||||||
except:
|
except:
|
||||||
return "Error pinging " + host + ":" + str(port) + \
|
return "Error pinging {}:{}, is it up? Double-check your address!".format(host,str(port))
|
||||||
", is it up? Double-check your address!"
|
|
||||||
|
|
||||||
|
|
||||||
def srvData(domain):
|
def srvData(domain):
|
||||||
|
@ -91,8 +90,8 @@ def mcping(inp):
|
||||||
port = int(getdata[0])
|
port = int(getdata[0])
|
||||||
return format_motd(mcping_connect(host, port))
|
return format_motd(mcping_connect(host, port))
|
||||||
except:
|
except:
|
||||||
return "Error pinging %s, is it up? Double-check your address!" % inp
|
return "Error pinging {}, is it up? Double-check your address!".format(inp)
|
||||||
else:
|
else:
|
||||||
return "Error pinging %s, is it up? Double-check your address!" % inp
|
return "Error pinging {}, is it up? Double-check your address!".format(inp)
|
||||||
else:
|
else:
|
||||||
return rdata
|
return rdata
|
||||||
|
|
|
@ -24,6 +24,6 @@ def mcwiki(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, 200)
|
summary = text.truncate_str(summary, 200)
|
||||||
return "%s :: %s" % (summary, url)
|
return "{} :: {}".format(summary, url)
|
||||||
|
|
||||||
return "Unknown Error."
|
return "Unknown Error."
|
||||||
|
|
|
@ -9,7 +9,7 @@ mlia_cache = []
|
||||||
|
|
||||||
def refresh_cache():
|
def refresh_cache():
|
||||||
"""gets a page of random MLIAs and puts them into a dictionary """
|
"""gets a page of random MLIAs and puts them into a dictionary """
|
||||||
url = 'http://mylifeisaverage.com/%s' % random.randint(1, 11000)
|
url = 'http://mylifeisaverage.com/{}'.format(random.randint(1, 11000))
|
||||||
soup = http.get_soup(url)
|
soup = http.get_soup(url)
|
||||||
|
|
||||||
for story in soup.find_all('div', {'class': 'story '}):
|
for story in soup.find_all('div', {'class': 'story '}):
|
||||||
|
@ -27,7 +27,7 @@ def mlia(inp, reply=None):
|
||||||
# grab the last item in the mlia cache and remove it
|
# grab the last item in the mlia cache and remove it
|
||||||
id, text = mlia_cache.pop()
|
id, text = mlia_cache.pop()
|
||||||
# reply with the mlia we grabbed
|
# reply with the mlia we grabbed
|
||||||
reply('(%s) %s' % (id, text))
|
reply('({}) {}'.format(id, text))
|
||||||
# refresh mlia cache if its getting empty
|
# refresh mlia cache if its getting empty
|
||||||
if len(mlia_cache) < 3:
|
if len(mlia_cache) < 3:
|
||||||
refresh_cache()
|
refresh_cache()
|
||||||
|
|
|
@ -36,7 +36,7 @@ class NameGenerator(object):
|
||||||
|
|
||||||
for name_part in name_parts:
|
for name_part in name_parts:
|
||||||
part = random.choice(self.parts[name_part])
|
part = random.choice(self.parts[name_part])
|
||||||
name = name.replace("{%s}" % name_part, part)
|
name = name.replace("{{}}".format(name_part), part)
|
||||||
|
|
||||||
return name
|
return name
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ def ping(inp, reply=None):
|
||||||
# I assume it's no longer needed with the way we run the process
|
# I assume it's no longer needed with the way we run the process
|
||||||
# host = re.sub(r'([^\s\w\.])+', '', host)
|
# host = re.sub(r'([^\s\w\.])+', '', host)
|
||||||
|
|
||||||
reply("Attempting to ping %s %s times..." % (host, count))
|
reply("Attempting to ping {} {} times...".format(host, count))
|
||||||
|
|
||||||
pingcmd = subprocess.check_output(["ping", "-c", count, host])
|
pingcmd = subprocess.check_output(["ping", "-c", count, host])
|
||||||
if "request timed out" in pingcmd or "unknown host" in pingcmd:
|
if "request timed out" in pingcmd or "unknown host" in pingcmd:
|
||||||
|
|
|
@ -50,5 +50,5 @@ def potato(inp, me=None, input=None):
|
||||||
method = random.choice(['bakes', 'fries', 'boils', 'roasts'])
|
method = random.choice(['bakes', 'fries', 'boils', 'roasts'])
|
||||||
side_dish = random.choice(['side salad', 'dollop of sour cream', 'piece of chicken', 'bowl of shredded bacon'])
|
side_dish = random.choice(['side salad', 'dollop of sour cream', 'piece of chicken', 'bowl of shredded bacon'])
|
||||||
|
|
||||||
me("%s a %s %s %s potato for %s and serves it with a small %s!" % (
|
me("{} a {} {} {} potato for {} and serves it with a small {}!".format(method, flavor, size, potato_type, inp,
|
||||||
method, flavor, size, potato_type, inp, side_dish))
|
side_dish))
|
||||||
|
|
|
@ -20,7 +20,7 @@ def check_url(code):
|
||||||
|
|
||||||
|
|
||||||
def make_url(code):
|
def make_url(code):
|
||||||
return "http://puu.sh/" + code
|
return "http://puu.sh/{}".format(code)
|
||||||
|
|
||||||
|
|
||||||
@hook.command(autohelp=False)
|
@hook.command(autohelp=False)
|
||||||
|
|
|
@ -8,8 +8,8 @@ from util import hook
|
||||||
def format_quote(q, num, n_quotes):
|
def format_quote(q, num, n_quotes):
|
||||||
"""Returns a formatted string of a quote"""
|
"""Returns a formatted string of a quote"""
|
||||||
ctime, nick, msg = q
|
ctime, nick, msg = q
|
||||||
return "[%d/%d] <%s> %s" % (num, n_quotes,
|
return "[{}/{}] <{}> {}".format((num, n_quotes,
|
||||||
nick, msg)
|
nick, msg))
|
||||||
|
|
||||||
|
|
||||||
def create_table_if_not_exists(db):
|
def create_table_if_not_exists(db):
|
||||||
|
@ -45,12 +45,11 @@ def get_quote_num(num, count, name):
|
||||||
if num: # Make sure num is a number if it isn't false
|
if num: # Make sure num is a number if it isn't false
|
||||||
num = int(num)
|
num = int(num)
|
||||||
if count == 0: # Error on no quotes
|
if count == 0: # Error on no quotes
|
||||||
raise Exception("No quotes found for %s." % name)
|
raise Exception("No quotes found for {}.".format(name))
|
||||||
if num and num < 0: # Count back if possible
|
if num and num < 0: # Count back if possible
|
||||||
num = count + num + 1 if num + count > -1 else count + 1
|
num = count + num + 1 if num + count > -1 else count + 1
|
||||||
if num and num > count: # If there are not enough quotes, raise an error
|
if num and num > count: # If there are not enough quotes, raise an error
|
||||||
raise Exception("I only have %d quote%s for %s."
|
raise Exception("I only have {} quote{} for {}.".format(count, ('s', '')[count == 1], name))
|
||||||
% (count, ('s', '')[count == 1], name))
|
|
||||||
if num and num == 0: # If the number is zero, set it to one
|
if num and num == 0: # If the number is zero, set it to one
|
||||||
num = 1
|
num = 1
|
||||||
if not num: # If a number is not given, select a random one
|
if not num: # If a number is not given, select a random one
|
||||||
|
|
|
@ -15,5 +15,5 @@ def reddit_url(match):
|
||||||
timeago = thread.xpath("//div[@id='siteTable']//p[@class='tagline']/time/text()")[0]
|
timeago = thread.xpath("//div[@id='siteTable']//p[@class='tagline']/time/text()")[0]
|
||||||
comments = thread.xpath("//div[@id='siteTable']//a[@class='comments']/text()")[0]
|
comments = thread.xpath("//div[@id='siteTable']//a[@class='comments']/text()")[0]
|
||||||
|
|
||||||
return '\x02%s\x02 - posted by \x02%s\x02 %s ago - %s upvotes, %s downvotes - %s' % (
|
return '\x02{}\x02 - posted by \x02{}\x02 {} ago - {} upvotes, {} downvotes - {}'.format(
|
||||||
title, author, timeago, upvotes, downvotes, comments)
|
title, author, timeago, upvotes, downvotes, comments)
|
||||||
|
|
|
@ -31,4 +31,4 @@ def snopes(inp):
|
||||||
claim = re.sub(r"[\s\xa0]+", " ", claim) # compress whitespace
|
claim = re.sub(r"[\s\xa0]+", " ", claim) # compress whitespace
|
||||||
status = re.sub(r"[\s\xa0]+", " ", status)
|
status = re.sub(r"[\s\xa0]+", " ", status)
|
||||||
|
|
||||||
return "%s %s %s" % (claim, status, result_urls[0])
|
return "{} {} {}".format(claim, status, result_urls[0])
|
||||||
|
|
|
@ -63,8 +63,8 @@ def steamcalc(inp, nick='', db=None):
|
||||||
out += soup.findAll('h1', {'class': 'header-title'})[1].text.strip()
|
out += soup.findAll('h1', {'class': 'header-title'})[1].text.strip()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print e
|
print e
|
||||||
return u"\x02Unable to retrieve info for %s!\x02 Is it a valid SteamCommunity profile username (%s)? " \
|
return u"\x02Unable to retrieve info for {}!\x02 Is it a valid SteamCommunity profile username ({})? " \
|
||||||
"Check if your profile is private, or go here to search: %s" % (
|
"Check if your profile is private, or go here to search: {}".format(
|
||||||
inp, web.try_isgd("http://steamcommunity.com/id/%s" % inp), web.try_isgd(url))
|
inp, web.try_isgd("http://steamcommunity.com/id/%s" % inp), web.try_isgd(url))
|
||||||
|
|
||||||
nextone = False
|
nextone = False
|
||||||
|
@ -96,8 +96,8 @@ def steamcalc(inp, nick='', db=None):
|
||||||
notplayed = data[2].text.split(" ")[-1]
|
notplayed = data[2].text.split(" ")[-1]
|
||||||
nppercent = data[3].text.split(" ")[-1]
|
nppercent = data[3].text.split(" ")[-1]
|
||||||
time = data[4].text.split(" ")[-1].replace("h", "hours")
|
time = data[4].text.split(" ")[-1].replace("h", "hours")
|
||||||
out += " This account is worth \x02%s\x02, and they've spent \x02%s\x02 playing games! " % (money, time)
|
out += " This account is worth \x02{}\x02, and they've spent \x02{}\x02 playing games! ".format(money, time)
|
||||||
out += " They have \x02%s games\x02, but \x02%s of them haven't been touched\x02! That's \x02%s\x02! " % (
|
out += " They have \x02{} games\x02, but \x02{} of them haven't been touched\x02! That's \x02{}\x02! ".format(
|
||||||
totalgames, notplayed, nppercent)
|
totalgames, notplayed, nppercent)
|
||||||
|
|
||||||
if not dontsave:
|
if not dontsave:
|
||||||
|
|
|
@ -27,7 +27,7 @@ def stock(inp):
|
||||||
guess = guess[0]["symbol"]
|
guess = guess[0]["symbol"]
|
||||||
return stock(guess)
|
return stock(guess)
|
||||||
else:
|
else:
|
||||||
return "error: unable to get stock info for '%s'" % inp
|
return "error: unable to get stock info for '{}'".format(inp)
|
||||||
|
|
||||||
if results['last'] == '0.00':
|
if results['last'] == '0.00':
|
||||||
return "%(company)s - last known stock value was 0.00 %(currency)s" \
|
return "%(company)s - last known stock value was 0.00 %(currency)s" \
|
||||||
|
|
|
@ -24,9 +24,9 @@ def system(inp):
|
||||||
python_ver = platform.python_version()
|
python_ver = platform.python_version()
|
||||||
architecture = '-'.join(platform.architecture())
|
architecture = '-'.join(platform.architecture())
|
||||||
cpu = platform.machine()
|
cpu = platform.machine()
|
||||||
return "Hostname: \x02%s\x02, Operating System: \x02%s\x02, Python " \
|
return "Hostname: \x02{}\x02, Operating System: \x02{}\x02, Python " \
|
||||||
"Version: \x02%s %s\x02, Architecture: \x02%s\x02, CPU: \x02%s" \
|
"Version: \x02{} {}\x02, Architecture: \x02{}\x02, CPU: \x02{}" \
|
||||||
"\x02" % (hostname, os, python_imp, python_ver, architecture, cpu)
|
"\x02".format(hostname, os, python_imp, python_ver, architecture, cpu)
|
||||||
|
|
||||||
|
|
||||||
@hook.command(autohelp=False)
|
@hook.command(autohelp=False)
|
||||||
|
@ -41,9 +41,9 @@ def memory(inp):
|
||||||
data = [float(i.replace(' kB', '')) for i in data]
|
data = [float(i.replace(' kB', '')) for i in data]
|
||||||
strings = [convert_kilobytes(i) for i in data]
|
strings = [convert_kilobytes(i) for i in data]
|
||||||
# prepare the output
|
# prepare the output
|
||||||
out = "Threads: \x02%s\x02, Real Memory: \x02%s\x02, Allocated Memory: \x02%s\x02, Peak " \
|
out = "Threads: \x02{}\x02, Real Memory: \x02{}\x02, Allocated Memory: \x02{}\x02, Peak " \
|
||||||
"Allocated Memory: \x02%s\x02, Stack Size: \x02%s\x02, Heap " \
|
"Allocated Memory: \x02{}\x02, Stack Size: \x02{}\x02, Heap " \
|
||||||
"Size: \x02%s\x02" % (s['Threads'], strings[0], strings[1], strings[2],
|
"Size: \x02{}\x02".format(s['Threads'], strings[0], strings[1], strings[2],
|
||||||
strings[3], strings[4])
|
strings[3], strings[4])
|
||||||
# return output
|
# return output
|
||||||
return out
|
return out
|
||||||
|
@ -55,7 +55,7 @@ def memory(inp):
|
||||||
for amount in re.findall(r'([,0-9]+) K', out):
|
for amount in re.findall(r'([,0-9]+) K', out):
|
||||||
memory += float(amount.replace(',', ''))
|
memory += float(amount.replace(',', ''))
|
||||||
memory = convert_kilobytes(memory)
|
memory = convert_kilobytes(memory)
|
||||||
return "Memory Usage: \x02%s\x02" % memory
|
return "Memory Usage: \x02{}\x02".format(memory)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
return "Sorry, this command is not supported on your OS."
|
return "Sorry, this command is not supported on your OS."
|
||||||
|
@ -66,10 +66,10 @@ def uptime(inp, bot=None):
|
||||||
"""uptime -- Shows the bot's uptime."""
|
"""uptime -- Shows the bot's uptime."""
|
||||||
uptime_raw = round(time.time() - bot.start_time)
|
uptime_raw = round(time.time() - bot.start_time)
|
||||||
uptime = timedelta(seconds=uptime_raw)
|
uptime = timedelta(seconds=uptime_raw)
|
||||||
return "Uptime: \x02%s\x02" % uptime
|
return "Uptime: \x02{}\x02".format(uptime)
|
||||||
|
|
||||||
|
|
||||||
@hook.command(autohelp=False)
|
@hook.command(autohelp=False)
|
||||||
def pid(inp):
|
def pid(inp):
|
||||||
"""pid -- Prints the bot's PID."""
|
"""pid -- Prints the bot's PID."""
|
||||||
return "PID: \x02%s\x02" % os.getpid()
|
return "PID: \x02{}\x02".format(os.getpid())
|
||||||
|
|
|
@ -37,10 +37,10 @@ def tellinput(paraml, input=None, notice=None, db=None, bot=None, nick=None, con
|
||||||
user_from, message, time, chan = tells[0]
|
user_from, message, time, chan = tells[0]
|
||||||
reltime = timesince.timesince(time)
|
reltime = timesince.timesince(time)
|
||||||
|
|
||||||
reply = "%s sent you a message %s ago from %s: %s" % (user_from, reltime, chan,
|
reply = "{} sent you a message {} ago from {}: {}".format(user_from, reltime, chan,
|
||||||
message)
|
message)
|
||||||
if len(tells) > 1:
|
if len(tells) > 1:
|
||||||
reply += " (+%d more, %sshowtells to view)" % (len(tells) - 1, conn.conf["command_prefix"])
|
reply += " (+{} more, {}showtells to view)".format(len(tells) - 1, conn.conf["command_prefix"])
|
||||||
|
|
||||||
db.execute("delete from tell where user_to=lower(?) and message=?",
|
db.execute("delete from tell where user_to=lower(?) and message=?",
|
||||||
(nick, message))
|
(nick, message))
|
||||||
|
@ -63,7 +63,7 @@ def showtells(inp, nick='', chan='', notice=None, db=None):
|
||||||
for tell in tells:
|
for tell in tells:
|
||||||
user_from, message, time, chan = tell
|
user_from, message, time, chan = tell
|
||||||
past = timesince.timesince(time)
|
past = timesince.timesince(time)
|
||||||
notice("%s sent you a message %s ago from %s: %s" % (user_from, past, chan, message))
|
notice("{} sent you a message {} ago from {}: {}".format(user_from, past, chan, message))
|
||||||
|
|
||||||
db.execute("delete from tell where user_to=lower(?)",
|
db.execute("delete from tell where user_to=lower(?)",
|
||||||
(nick,))
|
(nick,))
|
||||||
|
@ -92,7 +92,7 @@ def tell(inp, nick='', chan='', db=None, input=None, notice=None):
|
||||||
|
|
||||||
if user_to.lower() == input.conn.nick.lower():
|
if user_to.lower() == input.conn.nick.lower():
|
||||||
# user is looking for us, being a smartass
|
# user is looking for us, being a smartass
|
||||||
notice("Thanks for the message, %s!" % user_from)
|
notice("Thanks for the message, {}!".format(user_from))
|
||||||
return
|
return
|
||||||
|
|
||||||
if not re.match("^[A-Za-z0-9_|.-\]\[]*$", user_to.lower()):
|
if not re.match("^[A-Za-z0-9_|.-\]\[]*$", user_to.lower()):
|
||||||
|
|
|
@ -9,7 +9,7 @@ api_url = 'http://api.wolframalpha.com/v2/query?format=plaintext'
|
||||||
def time_command(inp, bot=None):
|
def time_command(inp, bot=None):
|
||||||
"""time <area> -- Gets the time in <area>"""
|
"""time <area> -- Gets the time in <area>"""
|
||||||
|
|
||||||
query = "current time in %s" % inp
|
query = "current time in {}".format(inp)
|
||||||
|
|
||||||
api_key = bot.config.get("api_keys", {}).get("wolframalpha", None)
|
api_key = bot.config.get("api_keys", {}).get("wolframalpha", None)
|
||||||
if not api_key:
|
if not api_key:
|
||||||
|
@ -27,9 +27,9 @@ def time_command(inp, bot=None):
|
||||||
place = capitalize_first(" ".join(request.xpath("//pod[@"
|
place = capitalize_first(" ".join(request.xpath("//pod[@"
|
||||||
"title='Input interpretation']/subpod/plaintext/text()"))[
|
"title='Input interpretation']/subpod/plaintext/text()"))[
|
||||||
16:])
|
16:])
|
||||||
return "%s - \x02%s\x02" % (time, place)
|
return "{} - \x02{}\x02".format(time, place)
|
||||||
else:
|
else:
|
||||||
return "Could not get the time for '%s'." % inp
|
return "Could not get the time for '{}'.".format(inp)
|
||||||
|
|
||||||
|
|
||||||
@hook.command(autohelp=False)
|
@hook.command(autohelp=False)
|
||||||
|
|
|
@ -130,7 +130,7 @@ def todo(inp, nick='', chan='', db=None, notice=None, bot=None):
|
||||||
if not row:
|
if not row:
|
||||||
notice("No such entry.")
|
notice("No such entry.")
|
||||||
return
|
return
|
||||||
notice("[%d]: %s: %s" % (index, row[0], row[1]))
|
notice("[{}]: {}: {}".format(index, row[0], row[1]))
|
||||||
elif cmd == 'del' or cmd == 'delete' or cmd == 'remove':
|
elif cmd == 'del' or cmd == 'delete' or cmd == 'remove':
|
||||||
if not len(args):
|
if not len(args):
|
||||||
return "error"
|
return "error"
|
||||||
|
@ -146,7 +146,7 @@ def todo(inp, nick='', chan='', db=None, notice=None, bot=None):
|
||||||
|
|
||||||
rows = db_del(db, nick, index)
|
rows = db_del(db, nick, index)
|
||||||
|
|
||||||
notice("Deleted %d entries" % rows.rowcount)
|
notice("Deleted {} entries".format(rows.rowcount))
|
||||||
elif cmd == 'list':
|
elif cmd == 'list':
|
||||||
limit = -1
|
limit = -1
|
||||||
|
|
||||||
|
@ -163,11 +163,11 @@ def todo(inp, nick='', chan='', db=None, notice=None, bot=None):
|
||||||
found = False
|
found = False
|
||||||
|
|
||||||
for (index, row) in enumerate(rows):
|
for (index, row) in enumerate(rows):
|
||||||
notice("[%d]: %s: %s" % (index, row[0], row[1]))
|
notice("[{}]: {}: {}".format(index, row[0], row[1]))
|
||||||
found = True
|
found = True
|
||||||
|
|
||||||
if not found:
|
if not found:
|
||||||
notice("%s has no entries." % nick)
|
notice("{} has no entries.".format(nick))
|
||||||
elif cmd == 'search':
|
elif cmd == 'search':
|
||||||
if not len(args):
|
if not len(args):
|
||||||
notice("No search query given!")
|
notice("No search query given!")
|
||||||
|
@ -178,11 +178,11 @@ def todo(inp, nick='', chan='', db=None, notice=None, bot=None):
|
||||||
found = False
|
found = False
|
||||||
|
|
||||||
for (index, row) in enumerate(rows):
|
for (index, row) in enumerate(rows):
|
||||||
notice("[%d]: %s: %s" % (index, row[0], row[1]))
|
notice("[{}]: {}: {}".format(index, row[0], row[1]))
|
||||||
found = True
|
found = True
|
||||||
|
|
||||||
if not found:
|
if not found:
|
||||||
notice("%s has no matching entries for: %s" % (nick, query))
|
notice("{} has no matching entries for: {}".format(nick, query))
|
||||||
|
|
||||||
else:
|
else:
|
||||||
notice("Unknown command: %s" % cmd)
|
notice("Unknown command: {}".format(cmd))
|
||||||
|
|
|
@ -76,9 +76,9 @@ def get_episode_info(episode, api_key):
|
||||||
if episode_name == "TBA":
|
if episode_name == "TBA":
|
||||||
episode_name = None
|
episode_name = None
|
||||||
|
|
||||||
episode_desc = '%s' % episode_num
|
episode_desc = '{}'.format(episode_num)
|
||||||
if episode_name:
|
if episode_name:
|
||||||
episode_desc += ' - %s' % episode_name
|
episode_desc += ' - {}'.format(episode_name)
|
||||||
return first_aired, airdate, episode_desc
|
return first_aired, airdate, episode_desc
|
||||||
|
|
||||||
|
|
||||||
|
@ -100,7 +100,7 @@ def tv_next(inp, bot=None):
|
||||||
episodes = episodes["episodes"]
|
episodes = episodes["episodes"]
|
||||||
|
|
||||||
if ended:
|
if ended:
|
||||||
return "%s has ended." % series_name
|
return "{} has ended.".format(series_name)
|
||||||
|
|
||||||
next_eps = []
|
next_eps = []
|
||||||
today = datetime.date.today()
|
today = datetime.date.today()
|
||||||
|
@ -114,22 +114,22 @@ def tv_next(inp, bot=None):
|
||||||
(first_aired, airdate, episode_desc) = ep_info
|
(first_aired, airdate, episode_desc) = ep_info
|
||||||
|
|
||||||
if airdate > today:
|
if airdate > today:
|
||||||
next_eps = ['%s (%s)' % (first_aired, episode_desc)]
|
next_eps = ['{} ({})'.format(first_aired, episode_desc)]
|
||||||
elif airdate == today:
|
elif airdate == today:
|
||||||
next_eps = ['Today (%s)' % episode_desc] + next_eps
|
next_eps = ['Today ({})'.format(episode_desc)] + next_eps
|
||||||
else:
|
else:
|
||||||
#we're iterating in reverse order with newest episodes last
|
#we're iterating in reverse order with newest episodes last
|
||||||
#so, as soon as we're past today, break out of loop
|
#so, as soon as we're past today, break out of loop
|
||||||
break
|
break
|
||||||
|
|
||||||
if not next_eps:
|
if not next_eps:
|
||||||
return "There are no new episodes scheduled for %s." % series_name
|
return "There are no new episodes scheduled for {}.".format(series_name)
|
||||||
|
|
||||||
if len(next_eps) == 1:
|
if len(next_eps) == 1:
|
||||||
return "The next episode of %s airs %s" % (series_name, next_eps[0])
|
return "The next episode of {} airs {}".format(series_name, next_eps[0])
|
||||||
else:
|
else:
|
||||||
next_eps = ', '.join(next_eps)
|
next_eps = ', '.join(next_eps)
|
||||||
return "The next episodes of %s: %s" % (series_name, next_eps)
|
return "The next episodes of {}: {}".format(series_name, next_eps)
|
||||||
|
|
||||||
|
|
||||||
@hook.command
|
@hook.command
|
||||||
|
@ -163,11 +163,11 @@ def tv_last(inp, bot=None):
|
||||||
if airdate < today:
|
if airdate < today:
|
||||||
#iterating in reverse order, so the first episode encountered
|
#iterating in reverse order, so the first episode encountered
|
||||||
#before today was the most recently aired
|
#before today was the most recently aired
|
||||||
prev_ep = '%s (%s)' % (first_aired, episode_desc)
|
prev_ep = '{} ({})'.format(first_aired, episode_desc)
|
||||||
break
|
break
|
||||||
|
|
||||||
if not prev_ep:
|
if not prev_ep:
|
||||||
return "There are no previously aired episodes for %s." % series_name
|
return "There are no previously aired episodes for {}.".format(series_name)
|
||||||
if ended:
|
if ended:
|
||||||
return '%s ended. The last episode aired %s.' % (series_name, prev_ep)
|
return '{} ended. The last episode aired {}.'.format(series_name, prev_ep)
|
||||||
return "The last episode of %s aired %s." % (series_name, prev_ep)
|
return "The last episode of {} aired {}.".format(series_name, prev_ep)
|
||||||
|
|
|
@ -22,5 +22,5 @@ def validate(inp):
|
||||||
if status in ("valid", "invalid"):
|
if status in ("valid", "invalid"):
|
||||||
errorcount = info['x-w3c-validator-errors']
|
errorcount = info['x-w3c-validator-errors']
|
||||||
warningcount = info['x-w3c-validator-warnings']
|
warningcount = info['x-w3c-validator-warnings']
|
||||||
return "%s was found to be %s with %s errors and %s warnings." \
|
return "{} was found to be {} with {} errors and {} warnings." \
|
||||||
" see: %s" % (inp, status, errorcount, warningcount, url)
|
" see: {}".format(inp, status, errorcount, warningcount, url)
|
||||||
|
|
|
@ -37,7 +37,7 @@ def getSoundInfo(url, inp, jsondata=False):
|
||||||
else:
|
else:
|
||||||
text = textsplit[i]
|
text = textsplit[i]
|
||||||
if not jsondata:
|
if not jsondata:
|
||||||
return "%s - %s %s" % (newdata[0]["who"],
|
return "{} - {} {}".format(newdata[0]["who"],
|
||||||
text if len(text) < 325 else text[:325] + "...",
|
text if len(text) < 325 else text[:325] + "...",
|
||||||
web.try_isgd(
|
web.try_isgd(
|
||||||
url + newdata[0]["id"] if not dostream else url + "sound.php?id=" + newdata[0][
|
url + newdata[0]["id"] if not dostream else url + "sound.php?id=" + newdata[0][
|
||||||
|
|
|
@ -46,4 +46,4 @@ def wiki(inp):
|
||||||
|
|
||||||
desc = text.truncate_str(desc, 200)
|
desc = text.truncate_str(desc, 200)
|
||||||
|
|
||||||
return '%s :: %s' % (desc, http.quote(url, ':/'))
|
return '{} :: {}'.format(desc, http.quote(url, ':/'))
|
||||||
|
|
|
@ -54,4 +54,4 @@ def wolframalpha(inp, bot=None):
|
||||||
if not ret:
|
if not ret:
|
||||||
return 'No results.'
|
return 'No results.'
|
||||||
|
|
||||||
return "%s - %s" % (ret, short_url)
|
return "{} - {}".format(ret, short_url)
|
||||||
|
|
Reference in a new issue