reconnect on socket.error, PEP8
This commit is contained in:
parent
339d853258
commit
a4d70df463
|
@ -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
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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)
|
||||
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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'] == '':
|
||||
|
|
|
@ -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 <series> -- get the next episode of <series> from thetvdb.com"
|
||||
".tv_next <series> -- get the next episode of <series>"
|
||||
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 <series> -- get the most recently aired episode of <series> from thetvdb.com"
|
||||
".tv_last <series> -- gets the most recently aired episode of <series>"
|
||||
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)
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Reference in New Issue