def post_tweet(twitter_api, tweet_text, reply_id=None, media_ids=None):
'''post a tweet to the timeline, trims tweet if appropriate
Args:
twitter_api (:class:`tweepy.API`): the Twitter API instance to use
tweet_text (string): the status text to tweet
reply_id (int): optional, nests the tweet as reply to that tweet (use id_str element from a tweet)
media_ids (list of media_ids): optional, media to attach to the tweet
Returns:
bool: True if posted successfully, False otherwise
'''
tweet_text = trim_tweet_text(tweet_text)
try:
twitter_api.update_status(tweet_text, reply_id, media_ids=media_ids)
return True
except tweepy.error.TweepError as e:
cozmo.logger.error("post_tweet Error: " + str(e))
return False
评论列表
文章目录