mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2025-01-19 00:40:42 -06:00
Added 403 and 404 error handling for viewing tweets
This commit is contained in:
parent
2279e14623
commit
f71506adf8
@ -249,14 +249,22 @@ class baseBufferController(bufferController):
|
|||||||
uri = None
|
uri = None
|
||||||
if tweet.has_key("long_uri"):
|
if tweet.has_key("long_uri"):
|
||||||
uri = tweet["long_uri"]
|
uri = tweet["long_uri"]
|
||||||
|
try:
|
||||||
tweet = self.session.twitter.twitter.show_status(id=tweet_id)
|
tweet = self.session.twitter.twitter.show_status(id=tweet_id)
|
||||||
|
except TwythonError as e:
|
||||||
|
utils.twitter_error(e)
|
||||||
|
return
|
||||||
if uri != None:
|
if uri != None:
|
||||||
tweet["text"] = twishort.get_full_text(uri)
|
tweet["text"] = twishort.get_full_text(uri)
|
||||||
l = tweets.is_long(tweet)
|
l = tweets.is_long(tweet)
|
||||||
while l != False:
|
while l != False:
|
||||||
tweetsList.append(tweet)
|
tweetsList.append(tweet)
|
||||||
id = tweets.get_id(l)
|
id = tweets.get_id(l)
|
||||||
|
try:
|
||||||
tweet = self.session.twitter.twitter.show_status(id=id)
|
tweet = self.session.twitter.twitter.show_status(id=id)
|
||||||
|
except TwythonError as e:
|
||||||
|
utils.twitter_error(e)
|
||||||
|
continue
|
||||||
l = tweets.is_long(tweet)
|
l = tweets.is_long(tweet)
|
||||||
if l == False:
|
if l == False:
|
||||||
tweetsList.append(tweet)
|
tweetsList.append(tweet)
|
||||||
|
@ -118,3 +118,10 @@ def is_allowed(tweet, clients):
|
|||||||
allowed = False
|
allowed = False
|
||||||
log.exception("Tuit not allowed: %s" % (tweet["text"],))
|
log.exception("Tuit not allowed: %s" % (tweet["text"],))
|
||||||
return allowed
|
return allowed
|
||||||
|
|
||||||
|
def twitter_error(error):
|
||||||
|
if error.error_code == 403:
|
||||||
|
msg = _(u"Sorry, you are not authorised to see this status.")
|
||||||
|
elif error.error_code == 404:
|
||||||
|
msg = _(u"No status found with that ID")
|
||||||
|
output.speak(msg)
|
Loading…
x
Reference in New Issue
Block a user