more little things

This commit is contained in:
Luke Rogers 2014-02-14 16:30:38 +13:00
parent b4d7e200a3
commit 4447e6cd1f
9 changed files with 25 additions and 22 deletions

View File

@ -1,7 +1,7 @@
# BING translation plugin by Lukeroge and neersighted
from util import hook
from util import http
import re
import re
import htmlentitydefs
import mygengo

View File

@ -13,7 +13,7 @@ details_url = base_url + "plugins/bukkit/{}"
categories = http.get_json("http://api.bukget.org/3/categories")
count_total = sum([cat["count"] for cat in categories])
count_categories = {cat["name"].lower() : int(cat["count"]) for cat in categories} # dict comps!
count_categories = {cat["name"].lower(): int(cat["count"]) for cat in categories} # dict comps!
class BukgetError(Exception):
@ -88,7 +88,7 @@ def format_output(data):
current_version = data['versions'][0]
last_update = time.strftime('%d %B %Y %H:%M',
time.gmtime(current_version['date']))
time.gmtime(current_version['date']))
version_number = data['versions'][0]['version']
bukkit_versions = ", ".join(current_version['game_versions'])

View File

@ -42,29 +42,29 @@ with open("plugins/data/itemids.txt") as f:
if line.startswith("//"):
continue
parts = line.strip().split()
id = parts[0]
itemid = parts[0]
name = " ".join(parts[1:])
ids.append((id, name))
ids.append((itemid, name))
@hook.command("mcid")
@hook.command
def mcitem(input, reply=None):
def mcitem(inp, reply=None):
"""mcitem <item/id> -- gets the id from an item or vice versa"""
input = input.lower().strip()
inp = inp.lower().strip()
if input == "":
if inp == "":
reply("error: no input.")
return
results = []
for id, name in ids:
if input == id:
results = ["\x02[{}]\x02 {}".format(id, name)]
for item_id, item_name in ids:
if inp == item_id:
results = ["\x02[{}]\x02 {}".format(item_id, item_name)]
break
elif input in name.lower():
results.append("\x02[{}]\x02 {}".format(id, name))
elif inp in item_name.lower():
results.append("\x02[{}]\x02 {}".format(item_id, item_name))
if not results:
return "No matches found."
@ -80,12 +80,12 @@ def mcitem(input, reply=None):
@hook.command("mccraft")
@hook.command
def mcrecipe(input, reply=None):
def mcrecipe(inp, reply=None):
"""mcrecipe <item> -- gets the crafting recipe for an item"""
input = input.lower().strip()
inp = inp.lower().strip()
results = [recipe.line for recipe in recipelist
if input in recipe.output]
if inp in recipe.output]
if not results:
return "No matches found."

View File

@ -1,3 +1,4 @@
# TODO: Rewrite this whole mess
from util import hook
import socket
import struct

View File

@ -25,9 +25,9 @@ refresh_cache()
def mlia(inp, reply=None):
"""mlia -- Gets a random quote from MyLifeIsAverage.com."""
# grab the last item in the mlia cache and remove it
id, text = mlia_cache.pop()
mlia_id, text = mlia_cache.pop()
# reply with the mlia we grabbed
reply('({}) {}'.format(id, text))
reply('({}) {}'.format(mlia_id, text))
# refresh mlia cache if its getting empty
if len(mlia_cache) < 3:
refresh_cache()

View File

@ -1,4 +1,5 @@
# based on password generation code by TheNoodle
# TODO: Add some kind of pronounceable password generation
# TODO: Improve randomness
from util import hook
import string
import random

View File

@ -13,6 +13,7 @@ def ping(inp, reply=None):
if os.name == "nt":
return "Sorry, this command is not supported on Windows systems."
# TODO: Rewrite this entire command to work on Windows, somehow
args = inp.split(' ')
host = args[0]

View File

@ -51,4 +51,4 @@ def potato(inp, action=None, input=None):
side_dish = random.choice(['side salad', 'dollop of sour cream', 'piece of chicken', 'bowl of shredded bacon'])
action("{} a {} {} {} potato for {} and serves it with a small {}!".format(method, flavor, size, potato_type, inp,
side_dish))
side_dish))

View File

@ -8,9 +8,9 @@ def qrcode(inp):
"""qrcode [link] returns a link for a QR code."""
args = {
"cht": "qr", # chart type
"cht": "qr", # chart type (QR)
"chs": "200x200", # dimensions
"chl": inp
"chl": inp # data
}
link = http.prepare_url("http://chart.googleapis.com/chart", args)