Moar tweakage
This commit is contained in:
parent
a2bfaf6ca5
commit
9c27f3ac06
1 changed files with 14 additions and 13 deletions
|
@ -6,6 +6,7 @@ import random
|
||||||
import re
|
import re
|
||||||
from time import strftime, strptime
|
from time import strftime, strptime
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
from util.timesince import timesince
|
from util.timesince import timesince
|
||||||
|
|
||||||
|
|
||||||
|
@ -104,25 +105,25 @@ def twitter(inp):
|
||||||
url = 'http://search.twitter.com/search.atom?q=%23' + inp[1:]
|
url = 'http://search.twitter.com/search.atom?q=%23' + inp[1:]
|
||||||
searching_hashtag = True
|
searching_hashtag = True
|
||||||
else:
|
else:
|
||||||
return 'error: invalid request'
|
return 'Error: Invalid request.'
|
||||||
|
|
||||||
try:
|
try:
|
||||||
tweet = http.get_xml(url)
|
tweet = http.get_xml(url)
|
||||||
except http.HTTPError as e:
|
except http.HTTPError as e:
|
||||||
errors = {400: 'bad request (ratelimited?)',
|
errors = {400: 'Bad request (ratelimited?)',
|
||||||
401: 'tweet is private',
|
401: 'Tweet is private',
|
||||||
403: 'tweet is private',
|
403: 'Tweet is private',
|
||||||
404: 'invalid user/id',
|
404: 'Invalid user/id',
|
||||||
500: 'twitter is broken',
|
500: 'Twitter is broken',
|
||||||
502: 'twitter is down ("getting upgraded")',
|
502: 'Twitter is down ("getting upgraded")',
|
||||||
503: 'twitter is overloaded (lol, RoR)'}
|
503: 'Twitter is overloaded'}
|
||||||
if e.code == 404:
|
if e.code == 404:
|
||||||
return 'error: invalid ' + ['username', 'tweet id'][getting_id]
|
return 'error: invalid ' + ['username', 'tweet id'][getting_id]
|
||||||
if e.code in errors:
|
if e.code in errors:
|
||||||
return 'error: ' + errors[e.code]
|
return 'Error: %s.' % errors[e.code]
|
||||||
return 'error: unknown %s' % e.code
|
return 'Unknown Error: %s' % e.code
|
||||||
except http.URLError as e:
|
except http.URLError as e:
|
||||||
return 'error: timeout'
|
return 'Error: Request timed out.'
|
||||||
|
|
||||||
if searching_hashtag:
|
if searching_hashtag:
|
||||||
ns = '{http://www.w3.org/2005/Atom}'
|
ns = '{http://www.w3.org/2005/Atom}'
|
||||||
|
|
Reference in a new issue