diff --git a/plugins/brainfuck.py b/plugins/brainfuck.py index 1c68b57..a7dc12e 100644 --- a/plugins/brainfuck.py +++ b/plugins/brainfuck.py @@ -1,5 +1,5 @@ -'''brainfuck interpreter adapted from (public domain) code at -http://brainfuck.sourceforge.net/brain.py''' +"""brainfuck interpreter adapted from (public domain) code at +http://brainfuck.sourceforge.net/brain.py""" import re import random diff --git a/plugins/fact.py b/plugins/fact.py index ab05f17..1d48ae7 100644 --- a/plugins/fact.py +++ b/plugins/fact.py @@ -2,7 +2,7 @@ from util import hook, http, web @hook.command(autohelp=False) -def fact(inp, say=False, nick=False): +def fact(inp): """fact -- Gets a random fact from OMGFACTS.""" attempts = 0 @@ -20,10 +20,10 @@ def fact(inp, say=False, nick=False): response = soup.find('a', {'class': 'surprise'}) link = response['href'] - fact = ''.join(response.find(text=True)) + fact_data = ''.join(response.find(text=True)) - if fact: - fact = fact.strip() + if fact_data: + fact_data = fact_data.strip() break else: if attempts > 2: @@ -34,4 +34,4 @@ def fact(inp, say=False, nick=False): url = web.try_isgd(link) - return "{} - {}".format(fact, url) + return "{} - {}".format(fact_data, url) diff --git a/plugins/help.py b/plugins/help.py index 4a4fd47..08001a5 100644 --- a/plugins/help.py +++ b/plugins/help.py @@ -3,7 +3,7 @@ from util import hook @hook.command(autohelp=False) -def help(inp, notice=None, input=None, conn=None, bot=None): +def help(inp, notice=None, conn=None, bot=None): """help -- Gives a list of commands/help for a command.""" funcs = {} diff --git a/plugins/hulu.py b/plugins/hulu.py index 0b69788..46d31ee 100644 --- a/plugins/hulu.py +++ b/plugins/hulu.py @@ -10,7 +10,7 @@ def hulu_url(match): data = http.get_json("http://www.hulu.com/api/oembed.json?url=http://www.hulu.com" + match.group(3)) showname = data['title'].split("(")[-1].split(")")[0] title = data['title'].split(" (")[0] - return "{}: {} - {}".format(showname, title, timeformat.timeformat(int(data['duration']))) + return "{}: {} - {}".format(showname, title, timeformat.format_time(int(data['duration']))) @hook.command('hulu') @@ -21,7 +21,7 @@ def hulu_search(inp): data = result.find('results').find('videos').find('video') showname = data.find('show').find('name').text title = data.find('title').text - duration = timeformat.timeformat(int(float(data.find('duration').text))) + duration = timeformat.format_time(int(float(data.find('duration').text))) description = data.find('description').text rating = data.find('content-rating').text return "{}: {} - {} - {} ({}) {}".format(showname, title, description, duration, rating, diff --git a/plugins/imgur.py b/plugins/imgur.py index 80efbca..8db3b96 100644 --- a/plugins/imgur.py +++ b/plugins/imgur.py @@ -18,7 +18,7 @@ def is_valid(data): @hook.command(autohelp=False) def imgur(inp): - "imgur [subreddit] -- Gets the first page of imgur images from [subreddit] and returns a link to them. If [subreddit] is undefined, return any imgur images" + """imgur [subreddit] -- Gets the first page of imgur images from [subreddit] and returns a link to them. If [subreddit] is undefined, return any imgur images""" if inp: # see if the input ends with "nsfw" show_nsfw = inp.endswith(" nsfw") diff --git a/plugins/isup.py b/plugins/isup.py index 454b8f5..5fc95d6 100644 --- a/plugins/isup.py +++ b/plugins/isup.py @@ -5,7 +5,7 @@ from util import hook, http, urlnorm @hook.command def isup(inp): - "isup -- uses isup.me to see if a site is up or not" + """isup -- uses isup.me to see if a site is up or not""" # slightly overcomplicated, esoteric URL parsing scheme, auth, path, query, fragment = urlparse.urlsplit(inp.strip()) diff --git a/plugins/metacritic.py b/plugins/metacritic.py index e32059d..92d0933 100644 --- a/plugins/metacritic.py +++ b/plugins/metacritic.py @@ -41,36 +41,6 @@ def metacritic(inp): except HTTPError: return 'error fetching results' - ''' result format: - -- game result, with score - -- subsequent results are the same structure, without first_result class -
  • -
    - Game - WII -
    -
    -
    -
    -

    ...

    -
    -
    - Metascore: - 87 -
    -
    -
    -
    ...
    -
    -
    -
  • - - -- other platforms are the same basic layout - -- if it doesn't have a score, there is no div.basic_score - -- the
    changes content for non-games: -
    Movie
    - ''' - # get the proper result element we want to pull data from result = None diff --git a/plugins/mlia.py b/plugins/mlia.py index c155a3e..7153081 100644 --- a/plugins/mlia.py +++ b/plugins/mlia.py @@ -23,7 +23,7 @@ refresh_cache() @hook.command(autohelp=False) def mlia(inp, reply=None): - "mlia -- Gets a random quote from MyLifeIsAverage.com." + """mlia -- Gets a random quote from MyLifeIsAverage.com.""" # grab the last item in the mlia cache and remove it id, text = mlia_cache.pop() # reply with the mlia we grabbed diff --git a/plugins/newegg.py b/plugins/newegg.py index 76b2a70..00271f8 100644 --- a/plugins/newegg.py +++ b/plugins/newegg.py @@ -44,7 +44,7 @@ def format_item(item, show_url=True): tags.append("\x02Featured\x02") if item["IsShellShockerItem"]: - tags.append("\x02SHELL SHOCKER®\x02") + tags.append(u"\x02SHELL SHOCKER\u00AE\x02") # join all the tags together in a comma separated string ("tag1, tag2, tag3") tag_text = u", ".join(tags) diff --git a/plugins/notes.py b/plugins/notes.py index 6c6e450..ac85f48 100644 --- a/plugins/notes.py +++ b/plugins/notes.py @@ -4,7 +4,7 @@ import re db_inited = False -def cleanSQL(sql): +def clean_sql(sql): return re.sub(r'\s+', " ", sql).strip() @@ -20,7 +20,7 @@ def db_init(db): """).fetchone()[0] == 1 if not exists: - db.execute(cleanSQL(""" + db.execute(clean_sql(""" create virtual table todos using fts4( user, text, @@ -91,7 +91,7 @@ def db_search(db, nick, query): @hook.command("notes") @hook.command def note(inp, nick='', chan='', db=None, notice=None, bot=None): - "note(s) args -- Manipulates your list of notes." + """note(s) args -- Manipulates your list of notes.""" db_init(db) diff --git a/plugins/tell.py b/plugins/tell.py index 5e54c77..e8a06bb 100644 --- a/plugins/tell.py +++ b/plugins/tell.py @@ -50,7 +50,7 @@ def tellinput(paraml, input=None, notice=None, db=None, bot=None, nick=None, con @hook.command(autohelp=False) def showtells(inp, nick='', chan='', notice=None, db=None): - "showtells -- View all pending tell messages (sent in a notice)." + """showtells -- View all pending tell messages (sent in a notice).""" db_init(db) diff --git a/plugins/twitter.py b/plugins/twitter.py index 2ea8ab8..1499470 100644 --- a/plugins/twitter.py +++ b/plugins/twitter.py @@ -52,7 +52,7 @@ def twitter_url(match, bot=None): @hook.command("twatter") @hook.command def twitter(inp, bot=None): - "twitter [n] -- Gets last/[n]th tweet from " + """twitter [n] -- Gets last/[n]th tweet from """ api = get_api(bot) if not api: @@ -117,6 +117,9 @@ def twitter(inp, bot=None): tweet = random.choice(search) user = tweet.user + else: + # ??? + return "Unknown Error" text = " ".join(tweet.text.split()) diff --git a/plugins/utility.py b/plugins/utility.py index baa215b..c0a1659 100644 --- a/plugins/utility.py +++ b/plugins/utility.py @@ -89,7 +89,7 @@ def checkbase64(inp): recoded = decoded.encode('base64').strip() is_base64 = recoded == inp except: - is_base64 = False + return '"{}" is not base64 encoded'.format(inp) if is_base64: return '"{}" is base64 encoded'.format(recoded) diff --git a/requirements.txt b/requirements.txt index 94832f2..d436010 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ +Crypto BeautifulSoup==3.2.1 lxml==3.1beta1 pyenchant==1.6.5