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)
评论列表
文章目录