bot restart needed. added support for timeouts to http.py, adjusted steam_calc timeout
This commit is contained in:
parent
909306cfbe
commit
143cd8dc96
2 changed files with 8 additions and 4 deletions
plugins
|
@ -25,14 +25,15 @@ def unicode_dictreader(utf8_data, **kwargs):
|
|||
|
||||
@hook.command('sc')
|
||||
@hook.command
|
||||
def steamcalc(inp):
|
||||
def steamcalc(inp, reply=None):
|
||||
"""steamcalc <username> [currency] - Gets value of steam account and
|
||||
total hours played. Uses steamcommunity.com/id/<nickname>. """
|
||||
|
||||
name = inp.strip()
|
||||
|
||||
try:
|
||||
http.get(gauge_url.format(name))
|
||||
reply("Collecting data, this may take a few seconds.")
|
||||
http.get(gauge_url.format(name), timeout=15, get_method='HEAD')
|
||||
request = http.get(api_url.format(name))
|
||||
except (http.HTTPError, http.URLError):
|
||||
return "Could not get data for this user."
|
||||
|
|
|
@ -52,7 +52,7 @@ def get_json(*args, **kwargs):
|
|||
|
||||
|
||||
def open(url, query_params=None, user_agent=None, post_data=None,
|
||||
referer=None, get_method=None, cookies=False, **kwargs):
|
||||
referer=None, get_method=None, cookies=False, timeout=None, **kwargs):
|
||||
if query_params is None:
|
||||
query_params = {}
|
||||
|
||||
|
@ -78,7 +78,10 @@ def open(url, query_params=None, user_agent=None, post_data=None,
|
|||
else:
|
||||
opener = urllib2.build_opener()
|
||||
|
||||
return opener.open(request)
|
||||
if timeout:
|
||||
return opener.open(request, timeout=timeout)
|
||||
else:
|
||||
return opener.open(request)
|
||||
|
||||
|
||||
def prepare_url(url, queries):
|
||||
|
|
Reference in a new issue