diff options
author | Sean B. Palmer <http://inamidst.com/sbp/> | 2008-09-11 17:18:44 +0100 |
---|---|---|
committer | Sean B. Palmer <http://inamidst.com/sbp/> | 2008-09-11 17:18:44 +0100 |
commit | b91de3886ecb38b6621dc35fa18a4c7f10fde780 (patch) | |
tree | bae59574d4d07b054907dfc207e28dc7768bf2fe /modules/head.py | |
parent | 31d107c0bd7fa2e172b09cce9560f3a10c1091af (diff) | |
download | bot-b91de3886ecb38b6621dc35fa18a4c7f10fde780.tar.gz bot-b91de3886ecb38b6621dc35fa18a4c7f10fde780.tar.bz2 bot-b91de3886ecb38b6621dc35fa18a4c7f10fde780.zip |
Added oblique.py, a new web services module.
Diffstat (limited to 'modules/head.py')
-rwxr-xr-x | modules/head.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/modules/head.py b/modules/head.py index 4cb19e3..8158958 100755 --- a/modules/head.py +++ b/modules/head.py @@ -7,7 +7,7 @@ Licensed under the Eiffel Forum License 2. http://inamidst.com/phenny/ """ -import re, urllib, urlparse, time +import re, urllib, httplib, urlparse, time from htmlentitydefs import name2codepoint import web from tools import deprecated @@ -24,11 +24,17 @@ def head(phenny, input): try: uri = phenny.last_seen_uri[input.sender] except KeyError: return phenny.say('?') + if not uri.startswith('htt'): + uri = 'http://' + uri + try: info = web.head(uri) except IOError: return phenny.say("Can't connect to %s" % uri) + except httplib.InvalidURL: return phenny.say("Not a valid URI, sorry.") if not isinstance(info, list): - info = dict(info) + try: info = dict(info) + except TypeError: + return phenny.reply('Try .head http://example.org/ [optional header]') info['Status'] = '200' else: newInfo = dict(info[0]) |