First pass at boss spawn monitoring
This commit is contained in:
parent
c6e968e8ac
commit
0762d79db3
@ -1,10 +1,9 @@
|
||||
from bs4 import BeautifulSoup
|
||||
from discord import option
|
||||
from discord.ext import commands, tasks
|
||||
from discord.ext import commands
|
||||
import discord
|
||||
import os
|
||||
import requests
|
||||
import json
|
||||
|
||||
import core_utils
|
||||
import star_citizen
|
||||
|
@ -1,6 +1,6 @@
|
||||
from datetime import datetime
|
||||
from bs4 import BeautifulSoup
|
||||
from discord.ext import commands
|
||||
from datetime import datetime
|
||||
from discord.ext import commands, tasks
|
||||
import core_utils
|
||||
import discord
|
||||
import os
|
||||
@ -18,9 +18,44 @@ else:
|
||||
class Tarkov(commands.Cog):
|
||||
def __init__(self, bot):
|
||||
self.bot: commands.Bot = bot
|
||||
self.check_boss_spawns.start()
|
||||
|
||||
tarkov = discord.SlashCommandGroup("tarkov", "Tarkov related commands")
|
||||
|
||||
@tasks.loop(seconds=10)
|
||||
async def check_boss_spawns(self):
|
||||
# Wait until the bot is ready before we actually start executing code
|
||||
await self.bot.wait_until_ready()
|
||||
|
||||
levels = tarkov.tarkov_boss_info()
|
||||
|
||||
if os.path.exists("/tmp/boss_spawns.txt"):
|
||||
|
||||
current_spawns = eval(open("/tmp/boss_spawns.txt", "r").read())
|
||||
|
||||
if levels != current_spawns:
|
||||
print("Boss spawns have changed")
|
||||
|
||||
embed = discord.Embed(
|
||||
description="-------", color=discord.Color.blue(), type="rich"
|
||||
)
|
||||
embed.set_author(name="🎲 Boss Spawns have updated 🎲")
|
||||
for key, value in current_spawns.items():
|
||||
embed.add_field(
|
||||
name=key,
|
||||
value="\n".join(
|
||||
f"{k}: {v['spawnChance']}" for k, v in value.items()
|
||||
),
|
||||
inline=False,
|
||||
)
|
||||
|
||||
open("/tmp/boss_spawns.txt", "w").write(str(levels))
|
||||
|
||||
await self.bot.get_channel(channel_id).send(embed=embed)
|
||||
|
||||
else:
|
||||
open("/tmp/boss_spawns.txt", "w").write(str(levels))
|
||||
|
||||
async def get_all_bosses(ctx: discord.AutocompleteContext):
|
||||
"""
|
||||
Returns a list of boss names to be used in auto complete
|
||||
@ -53,8 +88,6 @@ class Tarkov(commands.Cog):
|
||||
}
|
||||
}
|
||||
"""
|
||||
|
||||
headers = {"Content-Type": "application/json"}
|
||||
response = tarkov.query_tarkov_api(query)["traders"]
|
||||
|
||||
# Loop through the dataset
|
||||
@ -167,7 +200,7 @@ class Tarkov(commands.Cog):
|
||||
description="-------", color=discord.Color.blue(), type="rich"
|
||||
)
|
||||
|
||||
embed.set_author(name="Boss Spawn chances by map")
|
||||
embed.set_author(name="🎲 Boss Spawn chances by map 🎲")
|
||||
embed.set_thumbnail(url="https://i.ytimg.com/vi/Yis5rmgo_bM/maxresdefault.jpg")
|
||||
|
||||
levels = tarkov.tarkov_boss_info()
|
||||
@ -178,7 +211,7 @@ class Tarkov(commands.Cog):
|
||||
value="\n".join(f"{k}: {v['spawnChance']}" for k, v in value.items()),
|
||||
inline=False,
|
||||
)
|
||||
embed.set_footer(text=f"Pulled from the api")
|
||||
embed.set_footer(text="Pulled from the api")
|
||||
|
||||
await ctx.send_followup(embed=embed)
|
||||
|
||||
|
@ -64,7 +64,6 @@ def tarkov_boss_info():
|
||||
"USEC",
|
||||
"Rogue",
|
||||
]
|
||||
headers = {"Content-Type": "application/json"}
|
||||
response = query_tarkov_api(query)["maps"]
|
||||
|
||||
# Wasteful, but make a new dict to hold the info we care about
|
||||
|
Loading…
x
Reference in New Issue
Block a user