From f589133d80234be7613e8345ef173264c6677b27 Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Mon, 4 Jun 2012 02:41:19 +1200 Subject: [PATCH] Fixed .urban, added % to stock.py - Thank you @Atheuz :) (original commit: https://github.com/Atheuz/skybot/commit/68e5535ca44303dcfbd6548cbe0ab3dd640b413c) --- plugins/data/kills.txt | 4 ++-- plugins/stock.py | 2 +- plugins/urban.py | 2 +- plugins/util/http.py | 5 ++++- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/plugins/data/kills.txt b/plugins/data/kills.txt index c71d9ed..9e20cb2 100755 --- a/plugins/data/kills.txt +++ b/plugins/data/kills.txt @@ -4,12 +4,12 @@ grabs a machine gun and riddles 's body with bullets. gags and ties then throws them off a bridge. crushes with a huge spiked boulder. glares at until they die of boredom. -shivs in the multiple times. +shivs in the a few times. rams a rocket launcher up 's ass and lets off a few rounds. crushes 's skull in with a spiked mace. unleashes the armies of Isengard on . gags and ties then throws them off a building to their death. -reaches out and punches right though 's chest. +reaches out and punches right through 's chest. slices 's off with a sharpened Katana. throws to Cthulu and watches them get ripped to shreds. feeds to an owlbear who then proceeds to maul them violently. diff --git a/plugins/stock.py b/plugins/stock.py index 87d006b..4b727d6 100755 --- a/plugins/stock.py +++ b/plugins/stock.py @@ -28,7 +28,7 @@ def stock(inp): results['color'] = "3" ret = "%(company)s - %(last)s %(currency)s " \ - "\x03%(color)s%(change)s (%(perc_change)s)\x03 " \ + "\x03%(color)s%(change)s (%(perc_change)s%%)\x03 " \ "as of %(trade_timestamp)s" % results if results['delay'] != '0': diff --git a/plugins/urban.py b/plugins/urban.py index 45620b3..146dc8f 100755 --- a/plugins/urban.py +++ b/plugins/urban.py @@ -23,7 +23,7 @@ def urban(inp): # fetch the definitions url = 'http://www.urbandictionary.com/iphone/search/define' - page = http.get_json(url, term=input) + page = http.get_json(url, term=input, referer="http://m.urbandictionary.com") defs = page['list'] if page['result_type'] == 'no_results': diff --git a/plugins/util/http.py b/plugins/util/http.py index fcfd6d0..b420311 100755 --- a/plugins/util/http.py +++ b/plugins/util/http.py @@ -42,7 +42,7 @@ def get_json(*args, **kwargs): def open(url, query_params=None, user_agent=None, post_data=None, - get_method=None, cookies=False, **kwargs): + referer=None, get_method=None, cookies=False, **kwargs): if query_params is None: query_params = {} @@ -60,6 +60,9 @@ def open(url, query_params=None, user_agent=None, post_data=None, request.get_method = lambda: get_method request.add_header('User-Agent', user_agent) + + if referer is not None: + request.add_header('Referer', referer) if cookies: opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar))