From 388735dc2b14fb11b547163844369b924bd73672 Mon Sep 17 00:00:00 2001 From: Alban Crommer Date: Sat, 15 Jun 2019 22:43:31 +0200 Subject: [PATCH] [enh] README + dry_run --- README.md | 41 +++++++++++++++++++++++++++++++++++++++++ reboostTag.py | 8 +++++--- 2 files changed, 46 insertions(+), 3 deletions(-) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..d1658d0 --- /dev/null +++ b/README.md @@ -0,0 +1,41 @@ +# Activity Pub Tag Booster = + +Automatically boost messages on the fediverse based on tags aka. hashtags. + +Based on the pip3 toot library, with a hackish way to pilot it. + +## How to install and run + +```bash + +# clone project +git clone https://git.lelab.fr/alban/ActiPubTagBooster + +# load depencies +git submodule init +git submodule update +cd toot.src/ +pip3 install -r requirements.txt +cd .. + +# choose instance and accept a new app +./toot-cli login + +# pick your tag +TAG="photo" + +# pick your cache DIR +CACHE_DIR="$HOME/.cache/ActiPubTagBooster" +mkdir -p "$CACHE_DIR" + +# It should work +./reboostTag.py --help + +# run a first time with the --dry-run flag, or reboost all toots +./reboostTag.py -d -c 1 -t $TAG -p "$CACHE_DIR" + +# add to your crontab +*/5 * * * * /usr/bin/python3 :PATH:/ActiPubTagBooster/reboostTag.py -c 1 -t weeklyphotochallenge &>> :LOG_PATH:/ActiPubTagBooster.log +# or to cron.d/ActiPubTagBooster +*/5 * * * * :USER: /usr/bin/python3 :PATH:/ActiPubTagBooster/reboostTag.py -c 1 -t weeklyphotochallenge &>> :LOG_PATH:/ActiPubTagBooster.log +``` diff --git a/reboostTag.py b/reboostTag.py index 41ad427..9870ea3 100755 --- a/reboostTag.py +++ b/reboostTag.py @@ -16,13 +16,15 @@ from toot.console import main # Command line Arguments from argparse import ArgumentParser parser = ArgumentParser() +parser.add_argument("-d", "--dry-run", default=False, action="store_true", help="Don't reboost") parser.add_argument("-c", "--count", type=int, help="How many toots to read") parser.add_argument("-t", "--tag", type=str, help="Which tag to follow") -parser.add_argument("-p", "--cache-path", type=str, default="/var/cache/reboostTag", help="Which path to use for storing ") +parser.add_argument("-p", "--cache-path", type=str, default="/var/cache/ActiPubTagBooster", help="Which path to use for storing ") args = parser.parse_args() # Variables +dry_run = args.dry_run # The safe mode tag = args.tag # The tag to reboost count = args.count # The number of toots to load cache_path = args.cache_path # The tag file cache path @@ -73,14 +75,14 @@ for item in itemList: most_recent = item['id'] # if never seen, and therefore recent, reboost - if( last_seen != item['id'] ): + if( last_seen != item['id'] and dry_run != True ): print("Reboosting item#{}".format(item['id']) ) # Build a fake list of args to run the toot main() function on sim_args = [sys.argv[0], 'reblog', str(item['id'])] sys.argv = sim_args - #main() + main() # We've seen you already that toot, break else: