diff --git a/default.toml b/default.toml index 21f589b..c01b268 100644 --- a/default.toml +++ b/default.toml @@ -34,6 +34,12 @@ remove_trackers_from_urls = false # Default is "" footer = "" +# If specified, also diplay a timestamp on the "Original Tweet" line +# in the given format e.g. "%D %b %Y %H:%M" +# see https://docs.python.org/3/library/datetime.html#strftime-strptime-behavior +# Default is "" (tweet timestamp is not displayed) +tweet_time_format = "" + # Do not add reference to "Original tweet" on toots # default is false remove_original_tweet_ref = false diff --git a/twoot.py b/twoot.py index 2a7a40f..e2b18a5 100755 --- a/twoot.py +++ b/twoot.py @@ -90,7 +90,8 @@ def build_config(args): 'skip_retweets': False, 'remove_link_redirections': False, 'remove_trackers_from_urls': False, - 'footer': '', + 'footer': "", + 'tweet_time_format': "", 'remove_original_tweet_ref': False, 'tweet_max_age': float(1), 'tweet_delay': float(0), @@ -790,6 +791,7 @@ def main(argv): logging.info(' remove_link_redirections : ' + str(TOML['options']['remove_link_redirections'])) logging.info(' remove_trackers_from_urls: ' + str(TOML['options']['remove_trackers_from_urls'])) logging.info(' footer : ' + TOML['options']['footer']) + logging.info(' tweet_time_format : ' + TOML['options']['tweet_time_format']) logging.info(' remove_original_tweet_ref: ' + str(TOML['options']['remove_original_tweet_ref'])) logging.info(' update_profile : ' + str(TOML['options']['update_profile'])) logging.info(' tweet_max_age : ' + str(TOML['options']['tweet_max_age'])) @@ -980,9 +982,9 @@ def main(argv): else: tweet_text += '\n\nOriginal tweet: ' + substitute_source(full_status_url) - # Check what timestamp would look like - logging.debug("TEST TIMESTAMP " + str(time_string)) - logging.debug(tweet_text + ' (' + datetime.strftime(timestamp, '%x %X') + ')') + # Add timestamp to the "Original Tweet" line + if TOML['options']['tweet_time_format'] != "": + tweet_text += ' (' + datetime.strftime(timestamp, TOML['options']['tweet_time_format']) + ')' # If no media was specifically added in the tweet, try to get the first picture # with "twitter:image" meta tag in first linked page in tweet text