def post_tweet(data):
try:
post = Post.objects.get(title=data['title'])
tags = await get_tags(post=post)
media = await get_media(post=post)
sentiment = post.sentiment or "N/A"
if not (tags is None):
status = "{0} [{1}]: {2}{3}/ {4}".format(post.title[:80], sentiment, settings.DOMAIN, post.slug, tags)
else:
status = "{0} [{1}]: {2}{3}/".format(post.title[:80], sentiment, settings.DOMAIN, post.slug)
if not (media is None):
api.PostUpdate(status=status, media=media)
else:
api.PostUpdate(status=status, media=None)
print(colored.green("Sent tweet {}.".format(status)))
except Exception as e:
print(colored.red("At Twitter post: {0}".format(e)))
评论列表
文章目录