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