Auto trainer for Rabona

in #rabona4 years ago (edited)

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": "<posting_key>>"
    },
    {
        "username": "klopp",
        "auto_train_type": "4231",
        "posting_key": "<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

Sort:  

.

well, considering most of the players play default 4-3-3, I'd go with 4-2-3-1. :)

next step: determine the best training type...

I already have that one ;)

.

This is very useful.

I have been learning a bit of Python recently so let me see if I can deploy this script succesfully,

Congratulations @emrebeyler! You received a personal badge!

Happy Hive Birthday! You are on the Hive blockchain for 3 years!

You can view your badges on your board and compare yourself to others in the Ranking

Do not miss the last post from @hivebuzz:

Feedback from the October 1st Hive Power Up Day

I've no idea how to do that so I'll just win the league the old fashioned way. Hard work and determination. 😂

Or the new way and buy up lots of top players to win like man city.

Thank you! I was looking for something like this.