tools.py 文件源码

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

项目:jarvis 作者: anqxyr 项目源码 文件源码
def _get_post_data(api):
    tweets = api.user_timeline(count=100)
    tweets = [i for i in tweets if i.source == core.config.twitter.name]
    urls = [i.entities['urls'] for i in tweets]
    urls = [i[0]['expanded_url'] for i in urls if i]
    posted = [p for p in core.pages if p.url in urls]
    not_posted = [p for p in core.pages if p not in posted]

    new = _get_new_article(not_posted)
    if new:
        # post new articles if there are any
        return (lex.post_on_twitter.new, new)

    if tweets and tweets[0].created_at == arrow.now().naive:
        # if we posted an old article today already, don't post anything
        return None

    if any('scp' in p.tags for p in posted[:2]):
        # post tale, tale, tale, scp, tale, tale, tale, scp, tale...
        old = _get_old_article(not_posted, scp=False)
    else:
        old = _get_old_article(not_posted, scp=True)
    return (lex.post_on_twitter.old, old)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号