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
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
|
|
|
|
""" 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:
|
|
|
|
|
|
|
|
helpers._error(
|
2018-09-06 15:15:08 +02:00
|
|
|
'__main__ => No tweets fetched.')
|
2018-08-20 18:15:12 +02:00
|
|
|
|
|
|
|
sys.exit()
|
|
|
|
|
|
|
|
helpers._info('__main__ => ' + str(len(tweets)) + ' tweets fetched.')
|
|
|
|
|
|
|
|
for tweet in tweets:
|
|
|
|
|
2018-09-06 15:15:08 +02:00
|
|
|
if social.tootTheTweet(tweet):
|
2018-08-20 18:15:12 +02:00
|
|
|
|
|
|
|
helpers._info('__main__ => Tooted "' + tweet['text'] + '"')
|
|
|
|
helpers._info(
|
|
|
|
'__main__ => Tooting less is tooting more. Sleeping...')
|
|
|
|
|
|
|
|
sys.exit()
|