This commit is contained in:
melonhead 2010-03-05 16:43:15 +00:00
commit 6fe89c873e
3 changed files with 13 additions and 7 deletions

View File

@ -23,7 +23,12 @@ class Input(dict):
params=params, nick=nick, user=user, host=host, params=params, nick=nick, user=user, host=host,
paraml=paraml, msg=msg, server=conn.server, chan=chan, paraml=paraml, msg=msg, server=conn.server, chan=chan,
say=say, reply=reply, pm=pm, bot=bot) say=say, reply=reply, pm=pm, bot=bot)
self.__dict__ = self # permits attribute access to values
def __getattr__(self, key):
return self[key]
def __setattr__(self, key, value):
self[key] = value
def run(func, input): def run(func, input):

View File

@ -7,8 +7,8 @@ import urllib2
from util import hook from util import hook
api_url = "http://encyclopediadramatica.com/api.php?action=opensearch&search=%s" api_url = "http://encyclopediadramatica.com/api.php?action=opensearch&search="
ed_url = "http://encyclopediadramatica.com/%s" ed_url = "http://encyclopediadramatica.com/"
ua_header = ('User-Agent','Skybot/1.0 http://bitbucket.org/Scaevolus/skybot/') ua_header = ('User-Agent','Skybot/1.0 http://bitbucket.org/Scaevolus/skybot/')
@ -21,7 +21,7 @@ def drama(inp):
if not inp: if not inp:
return drama.__doc__ return drama.__doc__
q = api_url % (urllib2.quote(inp, safe='')) q = api_url + (urllib2.quote(inp, safe=''))
request = urllib2.Request(q) request = urllib2.Request(q)
request.add_header(*ua_header) request.add_header(*ua_header)
j = json.loads(urllib2.build_opener().open(request).read()) j = json.loads(urllib2.build_opener().open(request).read())
@ -29,7 +29,7 @@ def drama(inp):
return 'no results found' return 'no results found'
article_name = j[1][0].replace(' ', '_') article_name = j[1][0].replace(' ', '_')
url = ed_url % (urllib2.quote(article_name)) url = ed_url + (urllib2.quote(article_name))
request = urllib2.Request(url) request = urllib2.Request(url)
request.add_header(*ua_header) request.add_header(*ua_header)
page = html.fromstring(urllib2.build_opener().open(request).read()) page = html.fromstring(urllib2.build_opener().open(request).read())

View File

@ -43,7 +43,8 @@ def gmtime(format):
def beautify(input): def beautify(input):
format = formats.get(input.command, '%(raw)s') format = formats.get(input.command, '%(raw)s')
args = vars(input) args = dict(input)
leng = len(args['paraml']) leng = len(args['paraml'])
for n, p in enumerate(args['paraml']): for n, p in enumerate(args['paraml']):
args['param' + str(n)] = p args['param' + str(n)] = p