import argparse
import random
import time
from concurrent.futures import ThreadPoolExecutor as Executor
from ragnar import log
from ragnar.bot import Bot
from ragnar.victoria import vic
def parse_args():
parser = argparse.ArgumentParser(description="Process username and password.")
parser.add_argument("-u", "--username", required=True, help="Your username")
parser.add_argument("-p", "--password", required=True, help="Your password")
return parser.parse_args()
def bot_task(username, password):
log.info(f"Created new bot runniner. Username: {username}")
while True:
try:
time.sleep(random.randint(1, 50))
bot = Bot(username=username, password=password)
bot.login()
bot.fight()
except Exception as ex:
log.critical(ex, exc_info=True)
def main():
args = parse_args()
usernames = vic.get_friends()
with Executor(len(usernames)) as executor:
for username in usernames:
executor.submit(bot_task, f"{username}@molodetz.nl", args.password)
executor.shutdown(wait=True)
def run():
main()