posters.py 文件源码

python
阅读 30 收藏 0 点赞 0 评论 0

项目:meteosangue 作者: meteosangue 项目源码 文件源码
def tweet_status(status, image_path=None):
    try:
        auth = tweepy.OAuthHandler(settings.CONSUMER_KEY, settings.CONSUMER_SECRET)
        auth.set_access_token(settings.ACCESS_TOKEN, settings.ACCESS_TOKEN_SECRET)
        api = tweepy.API(auth)
        if image_path:
            new_tweet = api.update_with_media(image_path, status=status)
        else:
            new_tweet = api.update_status(status)
    except tweepy.TweepError as ex:
        raise MeteoSangueException(ex)

    try:
        mention = '{0} {1}'.format(
            ' '.join([ass['twitter_id'] for ass in settings.BLOOD_ASSOCIATIONS if 'twitter_id' in ass]),
            'Nuovo bollettino meteo ?',
        )
        api.update_status(mention, in_reply_to_status_id=new_tweet.id)
    except tweepy.TweepError as ex:
        pass #Mention is allowed to fail silently
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号