From b8d23ee58e740761e12b1c6eb068085df87096a7 Mon Sep 17 00:00:00 2001 From: Wardyn Date: Mon, 23 Jan 2023 16:34:45 -0800 Subject: [PATCH] added loop functionality --- lgfbot.py | 37 +++++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/lgfbot.py b/lgfbot.py index f83da0e..c6195fb 100644 --- a/lgfbot.py +++ b/lgfbot.py @@ -6,6 +6,19 @@ import json from getpass import getpass import os from urllib.parse import urlencode +import argparse +import time + +parser = argparse.ArgumentParser() +parser.add_argument('-l', '--loop', + action='store', + type=float, + help='Loop command every x hours', + default=None, + dest='loop' +) +args = parser.parse_args() +loop = args.loop #Ensure Credentials parent = os.path.dirname(os.path.realpath(__file__)) @@ -61,15 +74,23 @@ with open('adjectives.txt') as f: with open('verbs.txt') as f: verbs = list(map(str.rstrip, f)) -postform = random.choice(( + +formats = ( '{adjective} {gender} who {verb}', '{adjective} {gender}', '{gender} who {verb}', -)) +) +genders = ('lgf', 'lbf', 'elf') -gender = random.choice(('lgf', 'lbf', 'elf')) -verb = random.choice(verbs) -adjective = random.choice(adjectives) -content = postform.format(adjective=adjective, gender=gender, verb=verb) -print(content) -session.post(instance + '/api/v1/statuses', data={'status':content, 'visibility':'unlisted'}) +while True: + postform = random.choice(formats) + gender = random.choice(genders) + verb = random.choice(verbs) + adjective = random.choice(adjectives) + content = postform.format(adjective=adjective, gender=gender, verb=verb) + print(content) + session.post(instance + '/api/v1/statuses', data={'status':content, 'visibility':'unlisted'}) + if loop: + time.sleep(loop * 3600) + else: + break \ No newline at end of file