From df7fcb423670c03ddd42fa9cbbd77eedd1431f74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20=C3=81lvarez?= Date: Tue, 16 Jan 2018 11:00:12 +0100 Subject: [PATCH] raider.io api for m+ rotation --- affixes.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/affixes.py b/affixes.py index ee80c01..49f89e4 100755 --- a/affixes.py +++ b/affixes.py @@ -3,17 +3,21 @@ Affixes Cron """ -import datetime +import requests import webhook import conf wh = webhook.Webhook(conf.url_discord_webhook_news) -week = (int(datetime.datetime.now().strftime("%V")) % len(conf.affix_rotation)) - 1 +rio_api = "https://raider.io/api/v1/mythic-plus/affixes?region=eu&locale=es" +api = requests.get(url=rio_api).json() -f = [] -for s in conf.affix_rotation[week]: - f.append(webhook.field("{1} {0}".format(s, conf.affixes[s]), conf.affix_human[s], True)) +if api is not None and "affix_details" in api: + fields = [] -wh.add_embed(webhook.embed(color=0x3f89ff, fields=f)) -wh.send("**[Affixes de esta semana]()**") + for d in api["affix_details"]: + name = d["name"] + fields.append(webhook.field("{1} {0}".format(name, conf.affixes[name]), conf.affix_human[name], True)) + + wh.add_embed(webhook.embed(color=0x3f89ff, fields=fields)) + wh.send("**[Affixes de esta semana]()**")