Auto trainer for Rabona

Words
77
Reading
1 min
Listen
Play
6y

So, you have one free training in Rabona every day. It's important to train everyday and don't miss the timings. This script automatically executes your preset training when the daily training is available for your team.


import json

from rabona_python import RabonaClient
from lighthive.datastructures import Operation
from lighthive.client import Client
from datetime import datetime

# possible train types
# 433, 442, 352, 451, 4231, shot,dribbling, passing, defending,
# headball, speed, endurance.


ACCOUNTS = [
    {
        "username": "emrebeyler",
        "auto_train_type": "433",
        "posting_key": ">"
    },
    {
        "username": "klopp",
        "auto_train_type": "4231",
        "posting_key": ">"
    },
]


def create_custom_json_op(username, auto_train_type):
    train_json = json.dumps(
         {
             "username": username,
             "type": "train",
             "command": {"tr_var1": auto_train_type}}
    )

    train_op = Operation('custom_json', {
        'required_auths': [],
        'required_posting_auths': [username, ],
        'id': 'rabona',
        'json': train_json,
    })
    return train_op


def main():
    r = RabonaClient()
    for account in ACCOUNTS:
        # check if we can train, first.
        userinfo = r.userinfo(user=account["username"])
        if not userinfo.get("training_possible"):
            # training is not possible, wait.
            dt_delta = datetime.fromtimestamp(
                userinfo.get("training_busy_until")) - datetime.now()
            hours_left = int(dt_delta.total_seconds() / 3600)
            print("[%s] %d hours left for the training. Waiting." % (
                account["username"],
                hours_left
            ))
        else:
            op = create_custom_json_op(
                account["username"], account["auto_train_type"])
            c = Client(keys=[account["posting_key"]])
            c.broadcast(op=op)
            print("[%s] [Training: %s] Done." % (
                account["username"], account["auto_train_type"]))


if __name__ == '__main__':
    main()

Repository: https://github.com/emre/rabona-scripts/blob/main/auto-train/main.py

Notes


  • Just fill the corresponding information at the ACCOUNTS dictionary and execute it via a cron entry.
  • It requires lighthive and rabona_python libraries, installed.
  • You need to be familiar with Python & servers to work this out.

Bonus: Forza Galatasaray 💪


Screen Shot 2020-10-05 at 13.18.37.png

Auto trainer for Rabona | Ecency