A dash of PEP-8
This commit is contained in:
parent
398b34fad5
commit
6cc7554cd8
|
@ -35,7 +35,8 @@ exchanges = {
|
|||
@hook.command("btc", autohelp=False)
|
||||
@hook.command(autohelp=False)
|
||||
def bitcoin(inp):
|
||||
"""bitcoin <exchange> -- Gets current exchange rate for bitcoins from several exchanges, default is Blockchain. Supports MtGox, Bitpay, Coinbase and BitStamp."""
|
||||
"""bitcoin <exchange> -- Gets current exchange rate for bitcoins from several exchanges, default is Blockchain.
|
||||
Supports MtGox, Bitpay, Coinbase and BitStamp."""
|
||||
inp = inp.lower()
|
||||
|
||||
if inp:
|
||||
|
@ -58,4 +59,4 @@ def litecoin(inp, message=None):
|
|||
data = http.get_json("https://btc-e.com/api/2/ltc_usd/ticker")
|
||||
ticker = data['ticker']
|
||||
message("Current: \x0307${:,.2f}\x0f - High: \x0307${:,.2f}\x0f"
|
||||
" - Low: \x0307${:,.2f}\x0f - Volume: {:,.2f} LTC".format(ticker['buy'], ticker['high'], ticker['low'], ticker['vol_cur']))
|
||||
" - Low: \x0307${:,.2f}\x0f - Volume: {:,.2f} LTC".format(ticker['buy'], ticker['high'], ticker['low'], ticker['vol_cur']))
|
|
@ -49,7 +49,7 @@ def dice(inp):
|
|||
|
||||
spec = whitespace_re.sub('', inp)
|
||||
if not valid_diceroll_re.match(spec):
|
||||
return "Invalid diceroll"
|
||||
return "Invalid dice roll"
|
||||
groups = sign_re.findall(spec)
|
||||
|
||||
total = 0
|
||||
|
@ -73,13 +73,13 @@ def dice(inp):
|
|||
side = int(side)
|
||||
try:
|
||||
if count > 0:
|
||||
dice = nrolls(count, side)
|
||||
rolls += map(str, dice)
|
||||
total += sum(dice)
|
||||
d = nrolls(count, side)
|
||||
rolls += map(str, d)
|
||||
total += sum(d)
|
||||
else:
|
||||
dice = nrolls(-count, side)
|
||||
rolls += [str(-x) for x in dice]
|
||||
total -= sum(dice)
|
||||
d = nrolls(-count, side)
|
||||
rolls += [str(-x) for x in d]
|
||||
total -= sum(d)
|
||||
except OverflowError:
|
||||
return "Thanks for overflowing a float, jerk >:["
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ def domainr(inp):
|
|||
except (http.URLError, http.HTTPError) as e:
|
||||
return "Unable to get data for some reason. Try again later."
|
||||
if data['query'] == "":
|
||||
return "An error occurrred: {status} - {message}".format(**data['error'])
|
||||
return "An error occurred: {status} - {message}".format(**data['error'])
|
||||
domains = ""
|
||||
for domain in data['results']:
|
||||
domains += ("\x034" if domain['availability'] == "taken" else (
|
||||
|
|
|
@ -13,7 +13,7 @@ with open("plugins/data/8ball_responses.txt") as f:
|
|||
|
||||
|
||||
@hook.command('8ball')
|
||||
def eightball(input, action=None):
|
||||
def eightball(inp, action=None):
|
||||
"""8ball <question> -- The all knowing magic eight ball,
|
||||
in electronic form. Ask and it shall be answered!"""
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# Plugin by Lukeroge
|
||||
from util import hook, text, textgen
|
||||
import json
|
||||
import os
|
||||
|
@ -10,13 +9,13 @@ GEN_DIR = "./plugins/data/name_files/"
|
|||
def get_generator(_json):
|
||||
data = json.loads(_json)
|
||||
return textgen.TextGenerator(data["templates"],
|
||||
data["parts"], default_templates=data["default_templates"])
|
||||
data["parts"], default_templates=data["default_templates"])
|
||||
|
||||
|
||||
@hook.command(autohelp=False)
|
||||
def namegen(inp, notice=None):
|
||||
"namegen [generator] -- Generates some names using the chosen generator. " \
|
||||
"'namegen list' will display a list of all generators."
|
||||
"""namegen [generator] -- Generates some names using the chosen generator.
|
||||
'namegen list' will display a list of all generators."""
|
||||
|
||||
# clean up the input
|
||||
inp = inp.strip().lower()
|
||||
|
|
|
@ -21,11 +21,11 @@ def format_item(item, show_url=True):
|
|||
# format the rating nicely if it exists
|
||||
if not item["ReviewSummary"]["TotalReviews"] == "[]":
|
||||
rating = "Rated {}/5 ({} ratings)".format(item["ReviewSummary"]["Rating"],
|
||||
item["ReviewSummary"]["TotalReviews"][1:-1])
|
||||
item["ReviewSummary"]["TotalReviews"][1:-1])
|
||||
else:
|
||||
rating = "No Ratings"
|
||||
|
||||
if not item["FinalPrice"] == item["OriginalPrice"]:
|
||||
if not item["FinalPrice"] == item["OriginalPrice"]:
|
||||
price = "{FinalPrice}, was {OriginalPrice}".format(**item)
|
||||
else:
|
||||
price = item["FinalPrice"]
|
||||
|
@ -46,17 +46,17 @@ def format_item(item, show_url=True):
|
|||
if item["IsShellShockerItem"]:
|
||||
tags.append("\x02SHELL SHOCKER®\x02")
|
||||
|
||||
# join all the tags together in a comma seperated string ("tag1, tag2, tag3")
|
||||
# join all the tags together in a comma separated string ("tag1, tag2, tag3")
|
||||
tag_text = u", ".join(tags)
|
||||
|
||||
if show_url:
|
||||
# create the item URL and shorten it
|
||||
url = web.try_isgd(ITEM_URL.format(item["NeweggItemNumber"]))
|
||||
return u"\x02{}\x02 ({}) - {} - {} - {}".format(title, price, rating,
|
||||
tag_text, url)
|
||||
tag_text, url)
|
||||
else:
|
||||
return u"\x02{}\x02 ({}) - {} - {}".format(title, price, rating,
|
||||
tag_text)
|
||||
tag_text)
|
||||
|
||||
|
||||
## HOOK FUNCTIONS
|
||||
|
@ -80,8 +80,8 @@ def newegg(inp):
|
|||
|
||||
# submit the search request
|
||||
r = http.get_json(
|
||||
'http://www.ows.newegg.com/Search.egg/Advanced',
|
||||
post_data = json.dumps(request)
|
||||
'http://www.ows.newegg.com/Search.egg/Advanced',
|
||||
post_data=json.dumps(request)
|
||||
)
|
||||
|
||||
# get the first result
|
||||
|
|
|
@ -39,10 +39,10 @@ def password(inp, notice=None):
|
|||
if not okay:
|
||||
okay = okay + list(string.ascii_lowercase)
|
||||
|
||||
password = ""
|
||||
pw = ""
|
||||
|
||||
# generates password
|
||||
for x in range(length):
|
||||
password = password + random.choice(okay)
|
||||
pw = pw + random.choice(okay)
|
||||
|
||||
notice(password)
|
||||
notice(pw)
|
||||
|
|
|
@ -5,7 +5,7 @@ import datetime
|
|||
@hook.command("scene")
|
||||
@hook.command
|
||||
def pre(inp):
|
||||
'pre <query> -- searches scene releases using orlydb.com'
|
||||
"""pre <query> -- searches scene releases using orlydb.com"""
|
||||
|
||||
try:
|
||||
h = http.get_html("http://orlydb.com/", q=inp)
|
||||
|
|
|
@ -52,7 +52,7 @@ def reddit(inp):
|
|||
data = data["data"]["children"]
|
||||
|
||||
# get the requested/random post
|
||||
if id_num != None:
|
||||
if id_num is not None:
|
||||
try:
|
||||
item = data[id_num]["data"]
|
||||
except IndexError:
|
||||
|
@ -64,14 +64,14 @@ def reddit(inp):
|
|||
item["title"] = text.truncate_str(item["title"], 50)
|
||||
item["link"] = short_url.format(item["id"])
|
||||
|
||||
rawtime = datetime.fromtimestamp(int(item["created_utc"]))
|
||||
item["timesince"] = timesince.timesince(rawtime)
|
||||
raw_time = datetime.fromtimestamp(int(item["created_utc"]))
|
||||
item["timesince"] = timesince.timesince(raw_time)
|
||||
|
||||
if item["over_18"]:
|
||||
item["warning"] = " \x02NSFW\x02"
|
||||
else:
|
||||
item["warning"] = ""
|
||||
|
||||
return u'\x02{title} : {subreddit}\x02 - posted by \x02{author}\x02' \
|
||||
' {timesince} ago - {ups} upvotes, {downs} downvotes -' \
|
||||
' {link}{warning}'.format(**item)
|
||||
return u"\x02{title} : {subreddit}\x02 - posted by \x02{author}\x02" \
|
||||
" {timesince} ago - {ups} upvotes, {downs} downvotes -" \
|
||||
" {link}{warning}".format(**item)
|
||||
|
|
|
@ -26,7 +26,7 @@ def get_api(bot):
|
|||
@hook.regex(*TWITTER_RE)
|
||||
def twitter_url(match, bot=None):
|
||||
tweet_id = match.group(1)
|
||||
|
||||
|
||||
api = get_api(bot)
|
||||
if not api:
|
||||
return
|
||||
|
@ -46,7 +46,7 @@ def twitter_url(match, bot=None):
|
|||
time = timesince.timesince(tweet.created_at, datetime.utcnow())
|
||||
|
||||
return u"{}@\x02{}\x02 ({}): {} ({} ago)".format(prefix, user.screen_name, user.name, text, time)
|
||||
|
||||
|
||||
|
||||
@hook.command("tw")
|
||||
@hook.command("twatter")
|
||||
|
|
|
@ -9,7 +9,6 @@ from util import hook, http, text, web
|
|||
@hook.command
|
||||
def wolframalpha(inp, bot=None):
|
||||
"""wa <query> -- Computes <query> using Wolfram Alpha."""
|
||||
|
||||
api_key = bot.config.get("api_keys", {}).get("wolframalpha", None)
|
||||
|
||||
if not api_key:
|
||||
|
|
Reference in New Issue