[enh] README + dry_run

This commit is contained in:
Alban Crommer 2019-06-15 22:43:31 +02:00 committed by root
parent e141d20594
commit 388735dc2b
2 changed files with 46 additions and 3 deletions

41
README.md Normal file
View File

@ -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
```

View File

@ -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: