Tweaks to twitter
This commit is contained in:
parent
2b5f5e925d
commit
29b25e0b1f
2 changed files with 8 additions and 8 deletions
0
plugins/bitcoin.py → plugins/coins.py
Executable file → Normal file
0
plugins/bitcoin.py → plugins/coins.py
Executable file → Normal file
|
@ -35,7 +35,7 @@ def twitter(inp, bot=None):
|
||||||
if e[0][0]['code'] == 34:
|
if e[0][0]['code'] == 34:
|
||||||
return "Could not find tweet."
|
return "Could not find tweet."
|
||||||
else:
|
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
|
user = tweet.user
|
||||||
|
|
||||||
|
@ -59,21 +59,21 @@ def twitter(inp, bot=None):
|
||||||
if e[0][0]['code'] == 34:
|
if e[0][0]['code'] == 34:
|
||||||
return "Could not find user."
|
return "Could not find user."
|
||||||
else:
|
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
|
# get the users tweets
|
||||||
user_timeline = api.user_timeline(id=user.id, count=tweet_number + 1)
|
user_timeline = api.user_timeline(id=user.id, count=tweet_number + 1)
|
||||||
|
|
||||||
# if the timeline is empty, return an error
|
# if the timeline is empty, return an error
|
||||||
if not user_timeline:
|
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
|
# grab the newest tweet from the users timeline
|
||||||
try:
|
try:
|
||||||
tweet = user_timeline[tweet_number]
|
tweet = user_timeline[tweet_number]
|
||||||
except IndexError:
|
except IndexError:
|
||||||
tweet_count = len(user_timeline)
|
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):
|
elif re.match(r'^#\w+$', inp):
|
||||||
# user is searching by hashtag
|
# user is searching by hashtag
|
||||||
|
@ -88,7 +88,7 @@ def twitter(inp, bot=None):
|
||||||
text = " ".join(tweet.text.split())
|
text = " ".join(tweet.text.split())
|
||||||
|
|
||||||
if user.verified:
|
if user.verified:
|
||||||
prefix = "+"
|
prefix = u"\u2713 "
|
||||||
else:
|
else:
|
||||||
prefix = ""
|
prefix = ""
|
||||||
|
|
||||||
|
@ -126,17 +126,17 @@ def twuser(inp, bot=None):
|
||||||
return "Unknown error"
|
return "Unknown error"
|
||||||
|
|
||||||
if user.verified:
|
if user.verified:
|
||||||
prefix = "+"
|
prefix = u"\u2713 "
|
||||||
else:
|
else:
|
||||||
prefix = ""
|
prefix = ""
|
||||||
|
|
||||||
if user.location:
|
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:
|
else:
|
||||||
loc_str = ""
|
loc_str = ""
|
||||||
|
|
||||||
if user.description:
|
if user.description:
|
||||||
desc_str = " The users description is \"{}\"".format(user.description)
|
desc_str = u" The users description is \"{}\"".format(user.description)
|
||||||
else:
|
else:
|
||||||
desc_str = ""
|
desc_str = ""
|
||||||
|
|
||||||
|
|
Reference in a new issue