2018-09-24 11:20:05 +02:00
|
|
|
import encodings.idna
|
2018-08-20 18:15:12 +02:00
|
|
|
import helpers
|
2018-09-06 15:15:08 +02:00
|
|
|
import social
|
2018-08-20 18:15:12 +02:00
|
|
|
import sys
|
|
|
|
|
|
|
|
|
2019-12-11 11:08:48 +01:00
|
|
|
if __name__ == "__main__":
|
2018-08-20 18:15:12 +02:00
|
|
|
|
|
|
|
""" It all starts here...
|
|
|
|
|
|
|
|
This function will get a new Tweet from the configured Twitter account and publish to the configured Mastodon instance.
|
|
|
|
It will only toot once per invokation to avoid flooding the instance.
|
|
|
|
"""
|
|
|
|
|
2018-09-06 15:15:08 +02:00
|
|
|
tweets = social.getTweets()
|
2018-08-20 18:15:12 +02:00
|
|
|
|
|
|
|
if not tweets:
|
2019-12-11 11:08:48 +01:00
|
|
|
helpers._error("__main__ => No tweets fetched.")
|
2018-08-20 18:15:12 +02:00
|
|
|
sys.exit()
|
|
|
|
|
2019-12-11 11:08:48 +01:00
|
|
|
helpers._info(f"__main__ => {len(tweets)} tweets fetched.")
|
2018-08-20 18:15:12 +02:00
|
|
|
|
|
|
|
for tweet in tweets:
|
2018-09-06 15:15:08 +02:00
|
|
|
if social.tootTheTweet(tweet):
|
2019-12-11 11:08:48 +01:00
|
|
|
helpers._info(f'__main__ => Tooted "{tweet["text"]}"')
|
|
|
|
helpers._info("__main__ => Tooting less is tooting more. Sleeping...")
|
2018-08-20 18:15:12 +02:00
|
|
|
sys.exit()
|