raider.io api for m+ rotation

This commit is contained in:
Sergio Álvarez 2018-01-16 11:00:12 +01:00
parent b6f077aab8
commit df7fcb4236
1 changed files with 11 additions and 7 deletions

View File

@ -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))
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](<https://mythicpl.us/>)**")