diff --git a/core/irc.py b/core/irc.py index a5f3567..6dbbb0a 100644 --- a/core/irc.py +++ b/core/irc.py @@ -73,7 +73,7 @@ class crlf_tcp(object): self.socket.close() return time.sleep(1) - except self.get_timeout_exception_type(), e: + except (self.get_timeout_exception_type(), socket.error) as e: if self.handle_receive_exception(e, last_timestamp): return continue diff --git a/plugins/lastfm.py b/plugins/lastfm.py index c7278ae..89f590d 100644 --- a/plugins/lastfm.py +++ b/plugins/lastfm.py @@ -1,9 +1,11 @@ from util import hook, http + api_key = "" api_url = "http://ws.audioscrobbler.com/2.0/?format=json" + @hook.command def lastfm(inp, nick='', say=None): if inp: diff --git a/plugins/metacritic.py b/plugins/metacritic.py index 8f6df8d..1f78ef1 100644 --- a/plugins/metacritic.py +++ b/plugins/metacritic.py @@ -1,10 +1,10 @@ # metacritic.com scraper -from util import hook, http - import re from urllib2 import HTTPError +from util import hook, http + @hook.command('mc') def metacritic(inp): @@ -16,7 +16,7 @@ def metacritic(inp): args = inp.strip() game_platforms = ('x360', 'ps3', 'pc', 'ds', 'wii', '3ds', 'gba') - all_platforms = game_platforms + ('all','movie','tv','album') + all_platforms = game_platforms + ('all', 'movie', 'tv', 'album') try: plat, title = args.split(' ', 1) @@ -53,10 +53,10 @@ def metacritic(inp):

...

-
- Metascore: - 87 -
+
+ Metascore: + 87 +
...
@@ -129,10 +129,7 @@ def metacritic(inp): except IndexError: score = None - - result = '[%s] %s - %s, %s -- %s' % (plat.upper(), name, + return '[%s] %s - %s, %s -- %s' % (plat.upper(), name, score or 'no score', 'release: %s' % release if release else 'unreleased', link) - - return result diff --git a/plugins/misc.py b/plugins/misc.py index 50c4c68..4546f42 100644 --- a/plugins/misc.py +++ b/plugins/misc.py @@ -15,9 +15,13 @@ def get_version(): revnumber = len(stdout.splitlines()) - ret = stdout.split(None, 1)[0] + shorthash = stdout.split(None, 1)[0] + + http.ua_skybot = 'Skybot/r%d %s (http://github.com/rmmh/skybot)' \ + % (revnumber, shorthash) + + return shorthash, revnumber - return ret, revnumber #autorejoin channels @hook.event('KICK') @@ -55,11 +59,10 @@ def onjoin(paraml, conn=None): # set user-agent ident, rev = get_version() - http.ua_skybot = 'Skybot/r%d %s http://github.com/rmmh/skybot' % (rev, ident) + @hook.regex(r'^\x01VERSION\x01$') def version(inp, notice=None): ident, rev = get_version() notice('\x01VERSION skybot %s r%d - http://github.com/rmmh/' 'skybot/\x01' % (ident, rev)) - http.ua_skybot = 'Skybot/r%d %s http://github.com/rmmh/skybot' % (rev, ident) diff --git a/plugins/quote.py b/plugins/quote.py index bdb93ab..37c69d7 100644 --- a/plugins/quote.py +++ b/plugins/quote.py @@ -17,6 +17,7 @@ def del_quote(db, chan, nick, add_nick, msg): chan=? and lower(nick)=lower(?) and msg=msg''') db.commit() + def get_quotes_by_nick(db, chan, nick): return db.execute("select time, nick, msg from quote where deleted!=1 " "and chan=? and lower(nick)=lower(?) order by time", diff --git a/plugins/sieve.py b/plugins/sieve.py index b087ced..108390e 100644 --- a/plugins/sieve.py +++ b/plugins/sieve.py @@ -13,11 +13,10 @@ def sieve_suite(bot, input, func, kind, args): if input.trigger in bot.config.get('disabled_commands', []): return None - ignored = bot.config.get('ignored', []); + ignored = bot.config.get('ignored', []) if input.host in ignored or input.nick in ignored: return None - fn = re.match(r'^plugins.(.+).py$', func._filename) disabled = bot.config.get('disabled_plugins', []) if fn and fn.group(1).lower() in disabled: diff --git a/plugins/snopes.py b/plugins/snopes.py index 397d1d3..75adfd3 100644 --- a/plugins/snopes.py +++ b/plugins/snopes.py @@ -24,7 +24,7 @@ def snopes(inp): if status is not None: status = status.group(0).strip() - else: # new-style statuses + else: # new-style statuses status = "Status: %s." % re.search(r"FALSE|TRUE|MIXTURE|UNDETERMINED", snopes_text).group(0).title() diff --git a/plugins/stock.py b/plugins/stock.py index 4af6665..5b28c60 100644 --- a/plugins/stock.py +++ b/plugins/stock.py @@ -15,7 +15,8 @@ def stock(inp): return "error getting stock info" # Stuff the results in a dict for easy string formatting - results = dict((el.tag, el.attrib['data']) for el in parsed.xpath('//finance/*')) + results = dict((el.tag, el.attrib['data']) + for el in parsed.xpath('//finance/*')) # if we dont get a company name back, the symbol doesn't match a company if results['company'] == '': diff --git a/plugins/tvdb.py b/plugins/tvdb.py index 08edea6..75c1212 100644 --- a/plugins/tvdb.py +++ b/plugins/tvdb.py @@ -24,13 +24,14 @@ def get_zipped_xml(*args, **kwargs): zip_buffer = StringIO(http.get(*args, **kwargs)) return etree.parse(ZipFile(zip_buffer, "r").open(path)) + def get_episodes_for_series(seriesname): - res = {"error":None, "ended":False, "episodes":None, "name":None} + res = {"error": None, "ended": False, "episodes": None, "name": None} # http://thetvdb.com/wiki/index.php/API:GetSeries try: query = http.get_xml(base_url + 'GetSeries.php', seriesname=seriesname) except URLError: - res["error"]="error contacting thetvdb.com" + res["error"] = "error contacting thetvdb.com" return res series_id = query.xpath('//seriesid/text()') @@ -57,6 +58,7 @@ def get_episodes_for_series(seriesname): res["name"] = series_name return res + def get_episode_info(episode): first_aired = episode.findtext("FirstAired") @@ -79,10 +81,11 @@ def get_episode_info(episode): episode_desc += ' - %s' % episode_name return (first_aired, airdate, episode_desc) + @hook.command @hook.command('tv') def tv_next(inp): - ".tv_next -- get the next episode of from thetvdb.com" + ".tv_next -- get the next episode of " episodes = get_episodes_for_series(inp) if episodes["error"]: @@ -128,7 +131,7 @@ def tv_next(inp): @hook.command @hook.command('tv_prev') def tv_last(inp): - ".tv_last -- get the most recently aired episode of from thetvdb.com" + ".tv_last -- gets the most recently aired episode of " episodes = get_episodes_for_series(inp) if episodes["error"]: @@ -158,5 +161,5 @@ def tv_last(inp): if not prev_ep: return "there are no previously aired episodes for %s" % series_name if ended: - return '%s has ended. The last episode aired %s' % (series_name, prev_ep) + return '%s ended. The last episode aired %s' % (series_name, prev_ep) return "the last episode of %s aired %s" % (series_name, prev_ep) diff --git a/plugins/vimeo.py b/plugins/vimeo.py index 3596382..6d0564d 100644 --- a/plugins/vimeo.py +++ b/plugins/vimeo.py @@ -1,6 +1,5 @@ -import re +from util import hook, http -from util import http,hook @hook.regex(r'vimeo.com/([0-9]+)') def vimeo_url(match):