I've extended my auto-heal script to handle red-cards. This script now checks if there are blocked players in your team, and automatically unblock them via RBN. config.py *** ``` ACCOUNTS = [ { "username": "your_user", "posting_key": "<pkey>" }, { "username": "other_user", "posting_key": "<pkey>", } ] ``` *** auto-heal-unlock.py ``` import json import logging from lighthive.client import Client from lighthive.datastructures import Operation from rabona_python import RabonaClient from config import ACCOUNTS logger = logging.getLogger("Auto heal") logger.setLevel(logging.DEBUG) logFormatter = logging.Formatter( '%(asctime)s %(name)s %(levelname)s: %(message)s') consoleHandler = logging.StreamHandler() fileHandler = logging.FileHandler("autoheal.log") consoleHandler.setFormatter(logFormatter) fileHandler.setFormatter(logFormatter) logger.addHandler(consoleHandler) logger.addHandler(fileHandler) r = RabonaClient() def create_custom_json_op(username, pid, heal=True): if heal: custom_json_type = "heal_for_RBN" else: custom_json_type = "unblock_for_RBN" train_json = json.dumps( { "username": username, "type": custom_json_type, "command": {"tr_var1": pid} } ) train_op = Operation('custom_json', { 'required_auths': [], 'required_posting_auths': [username, ], 'id': 'rabona', 'json': train_json, }) return train_op def auto_heal_and_unblock(team, pk): rbn_balance = r.userinfo(user=team).get("currency") logger.info("Checking \"%s\" for injured and blocked players.", team) players = r.team(user=team).get("players", []) # players[0]["games_blocked"] = 1 injured_players = [p for p in players if int(p["games_injured"]) > 0] blocked_players = [p for p in players if int(p["games_blocked"]) > 0] if not injured_players and not blocked_players: logger.info( "\t\"%s\" doesnt have any injured or blocked players. Skipping.", team, ) return else: logger.info("\tAvailable RBN: %s", round(rbn_balance)) max_heal_games = round(rbn_balance) / 10000 for p in injured_players: logger.info( "\t%s (%s) is injured for %s matches. Trying to heal." % ( p["name"], p["uid"], p["games_injured"] )) if p["games_injured"] <= max_heal_games: op = create_custom_json_op(team, p["uid"]) c = Client(keys=[pk, ]) c.broadcast(op=op) logger.info("\t Transaction is broadcasted. Enjoy.") max_heal_games -= p["games_injured"] * 10000 else: logger.info( "\tNot enough RBN to heal %s (%s) for %s matches.", p["name"], p["uid"], p["games_injured"] ) max_unblock_games = round(rbn_balance) / 10000 for p in blocked_players: logger.info( "\t%s (%s) is blocked for %s matches. Trying to unblock." % ( p["name"], p["uid"], p["games_blocked"] )) if p["games_blocked"] <= max_unblock_games: op = create_custom_json_op(team, p["uid"], heal=False) c = Client(keys=[pk, ]) c.broadcast(op=op) logger.info("\t Transaction is broadcasted. Enjoy.") max_heal_games -= p["games_injured"] * 10000 else: logger.info( "\tNot enough RBN to unblock %s (%s) for %s matches.", p["name"], p["uid"], p["games_blocked"] ) def main(): for team in ACCOUNTS: auto_heal_and_unblock(team["username"], team["posting_key"]) main() ``` *** Example output: ***  *** Requires Python3.6. `lighthive`, `rabona_client` python libraries must be installed. I use it with a crontab entry - so it checks injured/blocked players once every hour. #### Vote for my witness *** If you like what I do, consider casting a vote on [Hivesigner](https://hivesigner.com/sign/account-witness-vote?witness=emrebeyler&approve=1) or on [PeakD](https://peakd.com/witnesses).
author | emrebeyler |
---|---|
permlink | auto-unblock-for-rabona |
category | hive-169321 |
json_metadata | {"tags":["rabona","python","programming"],"image":["https://images.hive.blog/DQma7jdV1HJHhJrJTxBC9wxpQJTEZpU87TfVf4z6Ab5BVdR/Screenshot%202021-02-16%20at%2015.21.26.png"],"app":"hiveblog/0.1","format":"markdown","links":["https://hivesigner.com/sign/account-witness-vote?witness=emrebeyler&approve=1"]} |
created | 2021-02-16 14:22:24 |
last_update | 2021-02-16 14:24:30 |
depth | 0 |
children | 0 |
last_payout | 2021-02-23 14:22:24 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 8.660 HBD |
curator_payout_value | 6.132 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 4,473 |
author_reputation | 448,535,049,068,622 |
root_title | "Auto Unblock for Rabona" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 101,904,795 |
net_rshares | 34,207,128,525,356 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
tombstone | 0 | 19,186,381,487 | 0.9% | ||
boatymcboatface | 0 | 157,175,256,830 | 10% | ||
onealfa | 0 | 561,807,051,515 | 7.52% | ||
kingscrown | 0 | 42,623,582,193 | 10% | ||
acidyo | 0 | 3,263,131,089,080 | 30% | ||
theshell | 0 | 42,167,398,504 | 10% | ||
yury-vas | 0 | 272,884,031,441 | 100% | ||
laoyao | 0 | 44,753,379,821 | 100% | ||
somebody | 0 | 79,492,106 | 100% | ||
midnightoil | 0 | 157,224,624,702 | 100% | ||
xiaohui | 0 | 889,827,312,495 | 100% | ||
oflyhigh | 0 | 5,727,065,826,406 | 100% | ||
djennyfloro | 0 | 1,301,207,738 | 10% | ||
helene | 0 | 1,170,496,712,747 | 100% | ||
funnyman | 0 | 1,043,650,493,339 | 20% | ||
justyy | 0 | 56,414,145,050 | 5% | ||
rishi556 | 0 | 22,873,487,980 | 100% | ||
edb | 0 | 129,455,722,286 | 50% | ||
doodleman | 0 | 551,527,800 | 9.8% | ||
blackbunny | 0 | 70,272,894,125 | 100% | ||
rahul.stan | 0 | 11,621,615,525 | 15% | ||
da-dawn | 0 | 56,446,505,117 | 23% | ||
schamangerbert | 0 | 317,073,704,992 | 30% | ||
lingfei | 0 | 72,356,687,040 | 100% | ||
damla | 0 | 19,260,329,627 | 55% | ||
roomservice | 0 | 3,318,121,755 | 2.25% | ||
exec | 0 | 239,115,823,046 | 100% | ||
eval | 0 | 818,572,048 | 100% | ||
ruel.cedeno | 0 | 4,670,129,002 | 100% | ||
ew-and-patterns | 0 | 106,408,973,514 | 9% | ||
jacekw | 0 | 62,403,933,491 | 100% | ||
themarkymark | 0 | 2,660,971,960,500 | 12% | ||
free999enigma | 0 | 170,901,384,506 | 100% | ||
crokkon | 0 | 47,305,956,279 | 100% | ||
buildawhale | 0 | 7,570,111,752,817 | 12% | ||
voxmonkey | 0 | 250,785,694 | 100% | ||
therealwolf | 0 | 1,064,316,283,322 | 3% | ||
revisesociology | 0 | 275,423,710,936 | 20% | ||
omra-sky | 0 | 102,739,811,853 | 40% | ||
makerhacks | 0 | 31,589,622,419 | 12% | ||
murattatar | 0 | 1,056,818,570 | 20% | ||
anadolu | 0 | 38,437,053,715 | 100% | ||
aykutpurde | 0 | 868,609,416 | 100% | ||
unforgettable | 0 | 3,978,868,571 | 100% | ||
emrebeyler | 0 | 3,147,342,476,132 | 100% | ||
smartsteem | 0 | 183,894,956,778 | 3% | ||
not-a-bird | 0 | 11,361,553,172 | 50% | ||
ugurarslanboga | 0 | 1,305,087,476 | 80% | ||
mevsuf | 0 | 1,345,586,821 | 40% | ||
evilest-fiend | 0 | 1,263,739,749 | 50% | ||
forkonti | 0 | 562,281,658 | 100% | ||
fourfourfun | 0 | 7,790,608,072 | 25% | ||
upmyvote | 0 | 7,275,421,334 | 12% | ||
tinowhale | 0 | 21,215,482,134 | 49% | ||
hayirhah | 0 | 1,281,450,929 | 50% | ||
fromhell2sky | 0 | 9,701,924,451 | 24.5% | ||
tugbabeauty | 0 | 16,028,961,598 | 100% | ||
hhaskana | 0 | 882,773,868 | 50% | ||
baycan | 0 | 1,687,170,738 | 20% | ||
coinmeria | 0 | 771,632,135 | 35% | ||
soyrosa | 0 | 342,143,445,653 | 100% | ||
chorock | 0 | 87,310,861,313 | 10% | ||
tobias-g | 0 | 682,765,245 | 9% | ||
icuz | 0 | 443,177,930 | 50% | ||
lidiceml | 0 | 570,883,880 | 49% | ||
semihbalkanli | 0 | 853,584,757 | 100% | ||
ahmetmertugrul | 0 | 832,386,610 | 100% | ||
sudefteri | 0 | 21,083,395,901 | 100% | ||
tdogvoid | 0 | 571,980,657 | 100% | ||
agememnon | 0 | 2,626,153,339 | 90% | ||
tipitip | 0 | 802,877,928 | 100% | ||
ahmeterbay | 0 | 10,361,381,341 | 100% | ||
raoul.poenar | 0 | 3,576,703,865 | 100% | ||
cst90 | 0 | 96,293,579,747 | 100% | ||
movement19 | 0 | 967,627,275 | 3% | ||
steempampanga | 0 | 538,991,077 | 10% | ||
siphon | 0 | 71,901,141,325 | 50% | ||
thomasthewolf | 0 | 63,103,080,371 | 90% | ||
backinblackdevil | 0 | 47,202,715,649 | 75% | ||
ruh | 0 | 816,273,267 | 100% | ||
frassman | 0 | 4,226,397,100 | 25% | ||
nervi | 0 | 5,996,382,091 | 100% | ||
bulent1976 | 0 | 652,028,240 | 100% | ||
muratkbesiroglu | 0 | 1,765,299,136 | 4% | ||
ahmetchef | 0 | 967,311,381 | 50% | ||
mahyulmaulana | 0 | 3,203,550,285 | 100% | ||
manniman | 0 | 132,731,746,827 | 22% | ||
sereze | 0 | 117,719,030,961 | 100% | ||
sbi2 | 0 | 178,967,401,933 | 49.55% | ||
jan23com | 0 | 7,052,829,878 | 90% | ||
emotionalsea | 0 | 787,630,938 | 27.5% | ||
genoner | 0 | 1,421,219,319 | 46.55% | ||
choco11oreo11 | 0 | 3,672,809,496 | 90% | ||
ecotone | 0 | 9,127,369,142 | 100% | ||
jumbot | 0 | 69,741,253,809 | 100% | ||
promobot | 0 | 83,107,163,972 | 100% | ||
aliriera | 0 | 23,567,675,586 | 50% | ||
enforcer48 | 0 | 114,854,898,710 | 15% | ||
bilimkurgu | 0 | 20,278,731,181 | 100% | ||
kahvesizlik | 0 | 1,235,974,997 | 100% | ||
moneybaby | 0 | 832,587,839 | 2.5% | ||
luciomcabee | 0 | 674,496,620 | 100% | ||
tahirozgen | 0 | 4,362,092,847 | 100% | ||
thedailysneak | 0 | 3,288,478,239 | 3.58% | ||
thehive | 0 | 183,738,733,638 | 70% | ||
elmauza | 0 | 1,129,057,988 | 100% | ||
littleshadow | 0 | 6,549,697,926 | 90% | ||
london65 | 0 | 787,496,414 | 9% | ||
ozeryilmaz | 0 | 550,643,864 | 50% | ||
emaillisahere | 0 | 6,395,551,076 | 75% | ||
buzzbee | 0 | 1,074,228,728 | 50% | ||
altonos | 0 | 90,521,836,118 | 15% | ||
gabbynhice | 0 | 4,509,682,057 | 100% | ||
caoimhin | 0 | 988,814,585 | 100% | ||
steemituplife | 0 | 654,456,242 | 25% | ||
marshalmugi | 0 | 79,218,393,136 | 85% | ||
podg3 | 0 | 1,370,599,508 | 90% | ||
cryptosman | 0 | 817,404,200 | 50% | ||
steemwhalepower | 0 | 946,560,739 | 100% | ||
mister-meeseeks | 0 | 12,336,442,454 | 15% | ||
misstaken | 0 | 4,569,729,556 | 90% | ||
sbi-booster | 0 | 105,069,684,048 | 100% | ||
bluedwains | 0 | 963,790,968 | 50% | ||
jussbren | 0 | 1,491,676,345 | 90% | ||
the.nervi | 0 | 450,614,362 | 100% | ||
starrouge | 0 | 1,029,384,992 | 50% | ||
rasalom | 0 | 15,485,702,261 | 100% | ||
wherein | 0 | 303,615,917,612 | 100% | ||
bluerobo | 0 | 111,367,806,012 | 100% | ||
cnstm | 0 | 239,573,566,414 | 100% | ||
likuang007 | 0 | 665,860,519 | 100% | ||
ctime | 0 | 263,033,227,503 | 4% | ||
dpoll.curation | 0 | 61,503,103,395 | 100% | ||
lianjingmedia | 0 | 1,004,005,509 | 100% | ||
dpoll.sponsors | 0 | 6,216,132,910 | 100% | ||
stratton.npc | 0 | 1,098,656,023 | 100% | ||
director.rar | 0 | 1,149,962,658 | 100% | ||
samflow | 0 | 613,299,703 | 100% | ||
realgoodcontent | 0 | 969,177,564 | 100% | ||
cooperfelix | 0 | 1,627,265,458 | 15% | ||
abbenay | 0 | 1,296,696,336 | 6% | ||
sm-skynet | 0 | 2,180,034,651 | 100% | ||
angelanichole | 0 | 950,836,346 | 50% | ||
thelogicaldude | 0 | 13,709,632,955 | 10% | ||
gamzekablan23 | 0 | 622,108,677 | 50% | ||
bitcoinator | 0 | 1,586,602,985 | 50% | ||
korle | 0 | 2,095,266,684 | 100% | ||
actifit-devil | 0 | 1,459,264,014 | 100% | ||
samujaeger | 0 | 31,800,050,105 | 100% | ||
epicdice | 0 | 2,303,908,438 | 0.9% | ||
raspibot | 0 | 1,341,343,989 | 100% | ||
likwid | 0 | 12,965,245,858 | 100% | ||
tinyhousecryptos | 0 | 520,613,290 | 5% | ||
suigener1s | 0 | 551,643,151 | 100% | ||
yeswecan | 0 | 24,100,613,508 | 90% | ||
sbi-tokens | 0 | 1,217,769,384 | 7.16% | ||
acta | 0 | 29,989,774,334 | 100% | ||
the-table | 0 | 21,502,063,650 | 90% | ||
cardtrader | 0 | 1,686,835,983 | 100% | ||
thehouse | 0 | 1,950,386,182 | 90% | ||
dpoll.witness | 0 | 17,242,708,633 | 100% | ||
silverquest | 0 | 154,346,805,029 | 90% | ||
honeychip | 0 | 11,575,721,959 | 85% | ||
gmlrecordz | 0 | 583,912,999 | 50% | ||
kgsupport | 0 | 2,228,116,701 | 50% | ||
theisacoin | 0 | 1,519,060,595 | 100% | ||
dapplr | 0 | 3,382,914,709 | 20% | ||
quello | 0 | 873,957,750 | 9% | ||
agnerthenx | 0 | 3,583,152,740 | 100% | ||
hextech | 0 | 14,843,684,593 | 66% | ||
hivelist | 0 | 28,333,272,370 | 3% | ||
fakegod | 0 | 796,340,187 | 100% | ||
ghaazi | 0 | 1,343,592,336 | 30% | ||
poshbot | 0 | 6,623,319,748 | 12% | ||
rabona | 0 | 722,865,287,397 | 100% | ||
hivecur2 | 0 | 1,793,712,805 | 10% | ||
recoveryinc | 0 | 24,281,042,703 | 6% | ||
dying | 0 | 3,626,240,872 | 6% | ||
vtol79 | 0 | 190,103,713 | 100% | ||
miner.wkoin | 0 | 7,865,032,916 | 5% | ||
banko | 0 | 37,609,623,798 | 25% | ||
ballsy | 0 | 3,684,961,696 | 100% |