Tweaks to twitter
This commit is contained in:
parent
2b5f5e925d
commit
29b25e0b1f
|
@ -35,7 +35,7 @@ def twitter(inp, bot=None):
|
|||
if e[0][0]['code'] == 34:
|
||||
return "Could not find tweet."
|
||||
else:
|
||||
return "Error {}: {}".format(e[0][0]['code'], e[0][0]['message'])
|
||||
return u"Error {}: {}".format(e[0][0]['code'], e[0][0]['message'])
|
||||
|
||||
user = tweet.user
|
||||
|
||||
|
@ -59,21 +59,21 @@ def twitter(inp, bot=None):
|
|||
if e[0][0]['code'] == 34:
|
||||
return "Could not find user."
|
||||
else:
|
||||
return "Error {}: {}".format(e[0][0]['code'], e[0][0]['message'])
|
||||
return u"Error {}: {}".format(e[0][0]['code'], e[0][0]['message'])
|
||||
|
||||
# get the users tweets
|
||||
user_timeline = api.user_timeline(id=user.id, count=tweet_number + 1)
|
||||
|
||||
# if the timeline is empty, return an error
|
||||
if not user_timeline:
|
||||
return "The user \x02{}\x02 has no tweets.".format(user.screen_name)
|
||||
return u"The user \x02{}\x02 has no tweets.".format(user.screen_name)
|
||||
|
||||
# grab the newest tweet from the users timeline
|
||||
try:
|
||||
tweet = user_timeline[tweet_number]
|
||||
except IndexError:
|
||||
tweet_count = len(user_timeline)
|
||||
return "The user \x02{}\x02 only has \x02{}\x02 tweets.".format(user.screen_name, tweet_count)
|
||||
return u"The user \x02{}\x02 only has \x02{}\x02 tweets.".format(user.screen_name, tweet_count)
|
||||
|
||||
elif re.match(r'^#\w+$', inp):
|
||||
# user is searching by hashtag
|
||||
|
@ -88,7 +88,7 @@ def twitter(inp, bot=None):
|
|||
text = " ".join(tweet.text.split())
|
||||
|
||||
if user.verified:
|
||||
prefix = "+"
|
||||
prefix = u"\u2713 "
|
||||
else:
|
||||
prefix = ""
|
||||
|
||||
|
@ -126,17 +126,17 @@ def twuser(inp, bot=None):
|
|||
return "Unknown error"
|
||||
|
||||
if user.verified:
|
||||
prefix = "+"
|
||||
prefix = u"\u2713 "
|
||||
else:
|
||||
prefix = ""
|
||||
|
||||
if user.location:
|
||||
loc_str = " is located in \x02{}\x02 and".format(user.location)
|
||||
loc_str = u" is located in \x02{}\x02 and".format(user.location)
|
||||
else:
|
||||
loc_str = ""
|
||||
|
||||
if user.description:
|
||||
desc_str = " The users description is \"{}\"".format(user.description)
|
||||
desc_str = u" The users description is \"{}\"".format(user.description)
|
||||
else:
|
||||
desc_str = ""
|
||||
|
||||
|
|
Reference in New Issue