added loop functionality
This commit is contained in:
parent
91cd12c2b4
commit
b8d23ee58e
37
lgfbot.py
37
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
|
Loading…
Reference in New Issue