new guild, new fixes. Now is more generic.
This commit is contained in:
parent
0822fe28d9
commit
f3f31ed8ca
|
@ -1,10 +1,11 @@
|
|||
#! /usr/bin/python3
|
||||
|
||||
import datetime
|
||||
import time
|
||||
import webhook
|
||||
import conf
|
||||
|
||||
wh = webhook.Webhook(conf.url_discord_webhook)
|
||||
wh = webhook.Webhook(conf.url_discord_webhook_news)
|
||||
|
||||
week = (int(datetime.datetime.now().strftime("%V")) % len(conf.affix_rotation)) - 1
|
||||
|
||||
|
@ -14,3 +15,4 @@ for s in conf.affix_rotation[week]:
|
|||
|
||||
wh.add_embed(webhook.embed(color=0x3f89ff, fields=f))
|
||||
wh.send("**[Affixes de esta semana](<https://mythicpl.us/>)**")
|
||||
time.sleep(2)
|
||||
|
|
62
conf.py
62
conf.py
|
@ -1,26 +1,28 @@
|
|||
|
||||
from tokens import *
|
||||
|
||||
icon_wowhead = "<:wowhead:283900950379233280>"
|
||||
icon_mmoc = "<:MMOChampion:283900921694650368>"
|
||||
icon_twitch = "<:twitch:332609778285019137>"
|
||||
icon_warcraftlogs = "<:Warcraftlogs:283906655484379138>"
|
||||
icon_wowhead = "<:wowhead:352756406925000704>"
|
||||
icon_mmoc = "<:MMOChampion:352756407109681153>"
|
||||
icon_twitch = "<:twitch:352756406904160257>"
|
||||
icon_warcraftlogs = "<:Warcraftlogs:352756407164076034>"
|
||||
|
||||
min_mythic = 10
|
||||
|
||||
affixes = {
|
||||
"Bullente": "<:m_teeming:278565188410802176>",
|
||||
"Detonante": "<:m_bursting:327109581048250369>",
|
||||
"Dolorosa": "<:m_grievous:327109581132136449>",
|
||||
"Explosiva": "<:m_explosive:327109581249576960>",
|
||||
"Furibunda": "<:m_raging:278565187986915328>",
|
||||
"Inquieta": "<:m_skittish:278565188087840768>",
|
||||
"Necrótica": "<:m_necro:278565187634593795>",
|
||||
"Potenciante": "<:m_bolstering:278565187987046400>",
|
||||
"Rebosante": "<:m_over:278565188033314816>",
|
||||
"Reforzada": "<:m_forti:278565187588456450>",
|
||||
"Sanguina": "<:m_sanguine:278565188020469760>",
|
||||
"Sísmica": "<:m_quaking:327109581236862976>",
|
||||
"Tiránica": "<:m_tyra:278565187852828674>",
|
||||
"Volcánica": "<:m_volcanic:278565188125458432>"
|
||||
"Bullente": "<:m_teeming:352756406514089994>",
|
||||
"Detonante": "<:m_bursting:352760092397010944>",
|
||||
"Dolorosa": "<:m_grievous:352760092472377344>",
|
||||
"Explosiva": "<:m_explosive:352760091981905932>",
|
||||
"Furibunda": "<:m_raging:352756406492987394>",
|
||||
"Inquieta": "<:m_skittish:352756406497181698>",
|
||||
"Necrótica": "<:m_necro:352756406333472769>",
|
||||
"Potenciante": "<:m_bolstering:352756406509633536>",
|
||||
"Rebosante": "<:m_over:352756406463758337>",
|
||||
"Reforzada": "<:m_forti:352756406497050624>",
|
||||
"Sanguina": "<:m_sanguine:352756406153379844>",
|
||||
"Sísmica": "<:m_quaking:352760093118300160>",
|
||||
"Tiránica": "<:m_tyra:352756406279208964>",
|
||||
"Volcánica": "<:m_volcanic:352756406341992449>"
|
||||
}
|
||||
|
||||
affix_human = {
|
||||
|
@ -86,18 +88,18 @@ timers = {
|
|||
}
|
||||
|
||||
class_icons = {
|
||||
"Character--WARRIOR": "<:class_warrior:278565187257237505>",
|
||||
"Character--DRUID": "<:class_druid:278565188381442048>",
|
||||
"Character--HUNTER": "<:class_hunter:278565187605364737>",
|
||||
"Character--DEATHKNIGHT": "<:class_deathknight:278565187903029248>",
|
||||
"Character--MAGE": "<:class_mage:278565187919937537>",
|
||||
"Character--DEMONHUNTER": "<:class_demonhunter:278565187500376065>",
|
||||
"Character--PRIEST": "<:class_priest:278565187970269184>",
|
||||
"Character--PALADIN": "<:class_paladin:278565187588587521>",
|
||||
"Character--SHAMAN": "<:class_shaman:278565187831726081>",
|
||||
"Character--ROGUE": "<:class_rogue:278565187940909056>",
|
||||
"Character--WARLOCK": "<:class_warlock:278565187596976130>",
|
||||
"Character--MONK": "<:class_monk:278565187618078722>"
|
||||
"Character--WARRIOR": "<:class_warrior:352756406232809483>",
|
||||
"Character--DRUID": "<:class_druid:352756406421815296>",
|
||||
"Character--HUNTER": "<:class_hunter:352756406278946827>",
|
||||
"Character--DEATHKNIGHT": "<:class_deathknight:352756406408970240>",
|
||||
"Character--MAGE": "<:class_mage:352756406035808258>",
|
||||
"Character--DEMONHUNTER": "<:class_demonhunter:352756406425878528>",
|
||||
"Character--PRIEST": "<:class_priest:352756406299918337>",
|
||||
"Character--PALADIN": "<:class_paladin:352756406446981130>",
|
||||
"Character--SHAMAN": "<:class_shaman:352756406459432960>",
|
||||
"Character--ROGUE": "<:class_rogue:352756406455107584>",
|
||||
"Character--WARLOCK": "<:class_warlock:352756406476341248>",
|
||||
"Character--MONK": "<:class_monk:352756406337798145>"
|
||||
}
|
||||
|
||||
#stop here!
|
||||
|
|
12
guild.py
12
guild.py
|
@ -9,13 +9,13 @@ import conf
|
|||
|
||||
now = time.time()
|
||||
|
||||
wh = webhook.Webhook(conf.url_discord_webhook)
|
||||
wh = webhook.Webhook(conf.url_discord_webhook_guild)
|
||||
|
||||
r = redis.StrictRedis(host='localhost', charset="utf-8", decode_responses=True)
|
||||
r = redis.StrictRedis(host='localhost', charset="utf-8", decode_responses=True, db=1)
|
||||
|
||||
bnet_achs = conf.battle_net_url("https://{0}.api.battle.net/wow/data/guild/achievements?locale=es_ES&apikey={1}")
|
||||
|
||||
bnet_guild = conf.battle_net_url("https://{0}.api.battle.net/wow/guild/dun%20modr/vagrant%20story?fields=news,members,achievements&locale=es_ES&apikey={1}")
|
||||
bnet_guild = conf.battle_net_url("https://{0}.api.battle.net/wow/guild/dun%20modr/farm%20and%20furious?fields=news,members,achievements&locale=es_ES&apikey={1}")
|
||||
|
||||
a = requests.get(url=bnet_achs).json()
|
||||
g = requests.get(url=bnet_guild).json()
|
||||
|
@ -38,10 +38,12 @@ for new in chars.difference(members):
|
|||
r.sadd("bot:members", new)
|
||||
members.add(new)
|
||||
wh.send(":inbox_tray: **{0}** ha entrado a la guild! 🎉".format(new))
|
||||
time.sleep(2)
|
||||
|
||||
for kick in members.difference(chars):
|
||||
r.srem("bot:members", kick)
|
||||
wh.send(":outbox_tray: **{0}** ha salido a la guild :confused:".format(kick))
|
||||
time.sleep(2)
|
||||
|
||||
|
||||
|
||||
|
@ -67,7 +69,6 @@ for news in g["news"]:
|
|||
continue
|
||||
|
||||
wh.send(push)
|
||||
|
||||
time.sleep(2) # prevent rate limit, for example with boss FK
|
||||
|
||||
|
||||
|
@ -107,7 +108,8 @@ for new in set(g["achievements"]["achievementsCompleted"]).difference(achievemen
|
|||
url = "http://es.wowhead.com/achievement={0}".format(new)
|
||||
icon = "https://wow.zamimg.com/images/wow/icons/large/{0}.jpg".format(ach["icon"])
|
||||
|
||||
wh.clear_embeds()
|
||||
wh.add_embed(webhook.embed(title=ach["title"], url="http://es.wowhead.com/achievement={0}".format(new), description=ach["description"], thumbnail=webhook.image(icon)))
|
||||
wh.send(":clap: Vagrant Story ha ganado un logro!")
|
||||
wh.send(":clap: La guild ha ganado un logro!")
|
||||
|
||||
time.sleep(2)
|
||||
|
|
10
loot.py
10
loot.py
|
@ -11,9 +11,9 @@ import conf
|
|||
|
||||
now = time.time()
|
||||
|
||||
wh = webhook.Webhook(conf.url_discord_webhook)
|
||||
wh = webhook.Webhook(conf.url_discord_webhook_guild)
|
||||
|
||||
r = redis.StrictRedis(host='localhost', charset="utf-8", decode_responses=True)
|
||||
r = redis.StrictRedis(host='localhost', charset="utf-8", decode_responses=True, db=1)
|
||||
|
||||
bnet_member = "https://{1}.api.battle.net/wow/character/dun%20modr/{0}?fields=feed,items&locale=es_ES&apikey={2}"
|
||||
|
||||
|
@ -35,16 +35,16 @@ for m in members:
|
|||
|
||||
if "feed" not in member:
|
||||
continue
|
||||
|
||||
|
||||
for feed in member["feed"]:
|
||||
if feed["type"] != "LOOT":
|
||||
continue
|
||||
|
||||
|
||||
fid = "{}-{}".format(m, feed["itemId"])
|
||||
|
||||
if feed["itemId"] in items and r.sadd("bot:legends", fid):
|
||||
#r.rpush("bot:rss:new", ":unicorn: **{0}** pilla legendario! **{1}**! <http://es.wowhead.com/item={2}>".format(member["name"], items[feed["itemId"]]["name_eses"], feed["itemId"]) )
|
||||
wh.send(":tangerine: **{0}** pilla legendario! **[{1}](<http://es.wowhead.com/item={2}>)**".format(member["name"], items[feed["itemId"]]["name_eses"], feed["itemId"]))
|
||||
time.sleep(2)
|
||||
|
||||
except:
|
||||
traceback.print_exc()
|
||||
|
|
12
mythics.py
12
mythics.py
|
@ -12,9 +12,9 @@ import conf
|
|||
|
||||
now = time.time()
|
||||
|
||||
wh = webhook.Webhook(conf.url_discord_webhook)
|
||||
wh = webhook.Webhook(conf.url_discord_webhook_guild)
|
||||
|
||||
r = redis.StrictRedis(host='localhost', charset="utf-8", decode_responses=True)
|
||||
r = redis.StrictRedis(host='localhost', charset="utf-8", decode_responses=True, db=1)
|
||||
|
||||
warcraft_api = "https://worldofwarcraft.com/es-es/game/pve/leaderboards/dun-modr/{}"
|
||||
|
||||
|
@ -31,7 +31,7 @@ for zone, instance in conf.zones.items():
|
|||
if len(top) < 3:
|
||||
print("no affix?")
|
||||
continue
|
||||
|
||||
|
||||
affix = "" if top[0] not in conf.affixes else conf.affixes[top[0]]
|
||||
affix += "" if top[1] not in conf.affixes else conf.affixes[top[1]]
|
||||
affix += "" if top[2] not in conf.affixes else conf.affixes[top[2]]
|
||||
|
@ -53,7 +53,7 @@ for zone, instance in conf.zones.items():
|
|||
inguild = False
|
||||
party = []
|
||||
|
||||
if lvl < 15 or r.zadd("bot:m+", now, k) == 0:
|
||||
if lvl < conf.min_mythic or r.zadd("bot:m+", now, k) == 0:
|
||||
continue
|
||||
|
||||
for player in team:
|
||||
|
@ -71,7 +71,7 @@ for zone, instance in conf.zones.items():
|
|||
for member in members:
|
||||
if "/{}".format(member).lower() in url and "dun-modr" in url:
|
||||
inguild = True
|
||||
|
||||
|
||||
if inguild:
|
||||
chests = 0
|
||||
for timer in conf.timers[zone]:
|
||||
|
@ -85,8 +85,8 @@ for zone, instance in conf.zones.items():
|
|||
#tip = "(piedra +{0} por {1})".format(chests, delta)
|
||||
tip = "(piedra +{0})".format(chests, delta)
|
||||
msg = ":mega: **[{0}](<{5}>) +{1}** hecha en **{2}** {3}, **rank {4}** de Dun Modr".format(instance, lvl, record, tip, pos, warcraft_api.format(zone))
|
||||
#r.rpush("bot:rss:new", msg)
|
||||
#print(msg)
|
||||
wh.clear_embeds()
|
||||
wh.add_embed(webhook.embed(title=", ".join(party)))
|
||||
wh.send(msg)
|
||||
|
||||
|
|
8
rss.py
8
rss.py
|
@ -9,9 +9,9 @@ import conf
|
|||
|
||||
now = time.time()
|
||||
|
||||
wh = webhook.Webhook(conf.url_discord_webhook)
|
||||
wh = webhook.Webhook(conf.url_discord_webhook_news)
|
||||
|
||||
r = redis.StrictRedis(host='localhost', charset="utf-8", decode_responses=True)
|
||||
r = redis.StrictRedis(host='localhost', charset="utf-8", decode_responses=True, db=1)
|
||||
r.zremrangebyscore("bot:rss", "-inf", now-(60*60*24*30*3)) # 3 meses de caché
|
||||
|
||||
url_feeds = [
|
||||
|
@ -25,7 +25,7 @@ for url in url_feeds:
|
|||
|
||||
if "items" not in feed or len(feed["items"]) < 3:
|
||||
continue
|
||||
|
||||
|
||||
for i in [0, 1, 2]: # 3 últimas noticias
|
||||
entry = feed["items"][i]
|
||||
fid = "{} {}".format(feed["feed"]["title"][0:20], entry["published"])
|
||||
|
@ -39,8 +39,8 @@ for url in url_feeds:
|
|||
else:
|
||||
icon = ":newspaper2:"
|
||||
|
||||
#r.rpush("bot:rss:new", "{2} {0}\n<{1}>".format(entry["title"], entry["link"], icon))
|
||||
wh.send("{2} [{0}](<{1}>)".format(entry["title"], entry["link"], icon))
|
||||
time.sleep(2)
|
||||
|
||||
except:
|
||||
print(url)
|
||||
|
|
|
@ -9,9 +9,9 @@ import conf
|
|||
|
||||
now = time.time()
|
||||
|
||||
wh = webhook.Webhook(conf.url_discord_webhook)
|
||||
wh = webhook.Webhook(conf.url_discord_webhook_news)
|
||||
|
||||
r = redis.StrictRedis(host='localhost', charset="utf-8", decode_responses=True)
|
||||
r = redis.StrictRedis(host='localhost', charset="utf-8", decode_responses=True, db=1)
|
||||
|
||||
twitch_api = "https://api.twitch.tv/kraken/streams/followed?oauth_token={0}".format(conf.twitch_token)
|
||||
|
||||
|
@ -27,5 +27,5 @@ for stream in t["streams"]:
|
|||
if r.zadd("bot:twitch", now, stream["channel"]["name"]) == 0:
|
||||
continue
|
||||
|
||||
#r.rpush("bot:rss:new", ":projector: **{0}** está stremeando <{1}>".format(stream["channel"]["name"], stream["channel"]["url"]))
|
||||
wh.send("{3} **{0}** está stremeando: [{2}](<{1}>)".format(stream["channel"]["name"], stream["channel"]["url"], stream["channel"]["status"], conf.icon_twitch))
|
||||
time.sleep(2)
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
|
||||
url_discord_webhook_guild = "https://discordapp.com/api/webhooks/???/???????"
|
||||
url_discord_webhook_news = "https://discordapp.com/api/webhooks/???/???????"
|
||||
|
||||
battle_net_region = "eu"
|
||||
battle_net_apikey = "????"
|
||||
|
||||
twitch_token = "?????"
|
||||
|
||||
warcraftlogs_token = "???????"
|
|
@ -1,9 +0,0 @@
|
|||
|
||||
url_discord_webhook = "https://discordapp.com/api/webhooks/???/???????"
|
||||
|
||||
battle_net_region = "eu"
|
||||
battle_net_apikey = "????"
|
||||
|
||||
twitch_token = "?????"
|
||||
|
||||
warcraftlogs_token = "???????"
|
|
@ -8,12 +8,12 @@ import conf
|
|||
|
||||
now = time.time()
|
||||
|
||||
wh = webhook.Webhook(conf.url_discord_webhook)
|
||||
wh = webhook.Webhook(conf.url_discord_webhook_guild)
|
||||
|
||||
r = redis.StrictRedis(host='localhost', charset="utf-8", decode_responses=True)
|
||||
r = redis.StrictRedis(host='localhost', charset="utf-8", decode_responses=True, db=1)
|
||||
r.zremrangebyscore("bot:warcraftlogs", "-inf", now-(60*60*24*30*12)) # 12 meses
|
||||
|
||||
wl_api = "https://www.warcraftlogs.com/v1/reports/guild/vagrant%20story/dun-modr/eu?api_key={0}".format(conf.warcraftlogs_token)
|
||||
wl_api = "https://www.warcraftlogs.com/v1/reports/guild/farm%20and%20furious/dun-modr/eu?api_key={0}".format(conf.warcraftlogs_token)
|
||||
|
||||
wl = requests.get(url=wl_api).json()
|
||||
|
||||
|
@ -25,5 +25,5 @@ for report in wl:
|
|||
continue
|
||||
|
||||
url = "https://www.warcraftlogs.com/reports/{0}".format(report["id"])
|
||||
#r.rpush("bot:rss:new", "<:Warcraftlogs:283906655484379138> Log en vivo! **{2}** por **{0}** en <{1}>".format(report["owner"], url, report["title"]))
|
||||
wh.send("{3} Logs! **[{2}](<{1}>)** por **{0}**".format(report["owner"], url, report["title"], conf.icon_warcraftlogs))
|
||||
time.sleep(2)
|
||||
|
|
16
webhook.py
16
webhook.py
|
@ -13,8 +13,8 @@ class Webhook():
|
|||
def __init__(self, url, **kwargs):
|
||||
self.url = url
|
||||
self.wh = {
|
||||
"username": kwargs.get("username", None),
|
||||
"avatar_url": kwargs.get("avatar_url", None),
|
||||
#"username": kwargs.get("username", None),
|
||||
#"avatar_url": kwargs.get("avatar_url", None),
|
||||
"content": None,
|
||||
"embeds": []
|
||||
}
|
||||
|
@ -34,8 +34,16 @@ class Webhook():
|
|||
|
||||
r = self.requests.post(self.url, json=self.wh)
|
||||
|
||||
if "X-RateLimit-Remaining" in r.headers and int(r.headers["X-RateLimit-Remaining"]) <= 5:
|
||||
raise Exception("RateLimit {0}/{1}, reset in ~{2}s".format(r.headers["X-RateLimit-Remaining"], r.headers["X-RateLimit-Limit"], int(r.headers["X-RateLimit-Reset"])-int(now)))
|
||||
if "X-RateLimit-Remaining" in r.headers and int(r.headers["X-RateLimit-Remaining"]) <= 1:
|
||||
wait = int(r.headers["X-RateLimit-Reset"])-int(now)
|
||||
raise Exception("RateLimit {0}/{1}, reset in ~{2}s".format(r.headers["X-RateLimit-Remaining"], r.headers["X-RateLimit-Limit"], wait))
|
||||
|
||||
"""rl = "RateLimit {0}/{1}, reset in ~{2}s".format(r.headers["X-RateLimit-Remaining"], r.headers["X-RateLimit-Limit"], wait)
|
||||
if wait < 600:
|
||||
print(rl)
|
||||
time.sleep(wait+1)
|
||||
else:
|
||||
raise Exception(rl)"""
|
||||
|
||||
if r.text != "":
|
||||
raise Exception("Webhook error: {0}".format(r.text))
|
||||
|
|
|
@ -8,11 +8,11 @@ import conf
|
|||
|
||||
now = time.time()
|
||||
|
||||
wh = webhook.Webhook(conf.url_discord_webhook)
|
||||
wh = webhook.Webhook(conf.url_discord_webhook_guild)
|
||||
|
||||
r = redis.StrictRedis(host='localhost', charset="utf-8", decode_responses=True)
|
||||
r = redis.StrictRedis(host='localhost', charset="utf-8", decode_responses=True, db=1)
|
||||
|
||||
wp_api = "http://www.wowprogress.com/guild/eu/dun-modr/VaGRaNT+SToRY/json_rank"
|
||||
wp_api = "http://www.wowprogress.com/guild/eu/dun-modr/Farm+and+Furious/json_rank"
|
||||
|
||||
rank = requests.get(url=wp_api).json()
|
||||
|
||||
|
@ -22,18 +22,19 @@ if rank is not None and "realm_rank" in rank:
|
|||
msg = None
|
||||
|
||||
if last is None:
|
||||
msg = ":arrow_right: Vagrant entra en el ranking de Dun Modr: **{0}**".format(realm)
|
||||
msg = ":arrow_right: La guild entra en el ranking de Dun Modr: **{0}**".format(realm)
|
||||
|
||||
elif int(last) > int(rank["realm_rank"]):
|
||||
msg = ":arrow_up: Vagrant sube en el ranking de Dun Modr: **{0}** (+{1})".format(realm, int(last)-int(realm))
|
||||
msg = ":arrow_up: La guild sube en el ranking de Dun Modr: **{0}** (+{1})".format(realm, int(last)-int(realm))
|
||||
|
||||
elif int(last) < int(realm):
|
||||
msg = ":arrow_down: Vagrant baja en el ranking de Dun Modr: **{0}** (-{1})".format(realm, int(realm)-int(last))
|
||||
msg = ":arrow_down: La guild baja en el ranking de Dun Modr: **{0}** (-{1})".format(realm, int(realm)-int(last))
|
||||
|
||||
elif int(last) == int(realm):
|
||||
msg = ":ok_hand: Vagrant se mantiene en el ranking de Dun Modr: **{0}**".format(realm)
|
||||
msg = ":ok_hand: La guild se mantiene en el ranking de Dun Modr: **{0}**".format(realm)
|
||||
|
||||
r.set("bot:wowprogress", realm)
|
||||
|
||||
if msg:
|
||||
wh.send(msg)
|
||||
time.sleep(2)
|
||||
|
|
Loading…
Reference in New Issue