fixed
This commit is contained in:
parent
651db7168f
commit
52f6260e1c
|
@ -35,19 +35,18 @@ def reddit(inp):
|
|||
|
||||
# find the requested post number (if any)
|
||||
if len(parts) > 1:
|
||||
subreddit = parts[0]
|
||||
url = base_url.format(parts[0].strip())
|
||||
try:
|
||||
id_num = int(parts[1]) - 1
|
||||
except ValueError:
|
||||
return "Invalid post number."
|
||||
else:
|
||||
subreddit = parts[0]
|
||||
url = base_url.format(parts[0].strip())
|
||||
else:
|
||||
subreddit = "all"
|
||||
url = "http://reddit.com/.json"
|
||||
|
||||
try:
|
||||
data = http.get_json(base_url.format(subreddit.strip()),
|
||||
user_agent=http.ua_chrome)
|
||||
data = http.get_json(url, user_agent=http.ua_chrome)
|
||||
except Exception as e:
|
||||
return "Error: " + str(e)
|
||||
data = data["data"]["children"]
|
||||
|
@ -74,9 +73,6 @@ def reddit(inp):
|
|||
else:
|
||||
item["warning"] = ""
|
||||
|
||||
if not item["subreddit"]:
|
||||
item["subreddit"] = subreddit
|
||||
|
||||
return u'\x02{title} : {subreddit}\x02 - posted by \x02{author}\x02' \
|
||||
' {timesince} ago - {ups} upvotes, {downs} downvotes -' \
|
||||
' {link}{warning}'.format(**item)
|
||||
|
|
Reference in a new issue