im so dumb. fix the docker file
Fix order of comparisons Update app/tarkov.py Fix order of boss spawn comparison Trying to fix the spawn rate logic agani I dont even know anymore man some more funky shit for the boss sapwn comaprison I dunno man, what the fuck is a kilometer Flip percents again Try flipping it AGAIN fuck man i dont know Dont cache boss spawns
This commit is contained in:
parent
2a441454c1
commit
ea6d09b350
@ -1,8 +1,8 @@
|
||||
FROM python:3.10-rc AS build
|
||||
ADD app/requirements.txt /requirements.txt
|
||||
ADD https://astral.sh/uv/install.sh /install.sh
|
||||
RUN bash /install.sh && rm /install.sh
|
||||
RUN /root/.cargo/bin/uv pip install --system --no-cache-dir -r requirements.txt
|
||||
RUN bash /install.sh && rm /install.sh && chmod +x /root/.local/bin/uv
|
||||
RUN /root/.local/bin/uv pip install --system --no-cache-dir -r requirements.txt
|
||||
|
||||
FROM python:3.10-rc-slim
|
||||
RUN apt update && \
|
||||
|
@ -2,14 +2,13 @@ FROM python:3.10-rc AS build
|
||||
ADD app/requirements.txt /requirements.txt
|
||||
ADD --chmod=755 https://astral.sh/uv/install.sh /install.sh
|
||||
RUN /install.sh && rm /install.sh
|
||||
RUN /root/.cargo/bin/uv pip install --system --verbose -r requirements.txt
|
||||
RUN /root/.local/bin/uv pip install --system --verbose -r requirements.txt
|
||||
|
||||
FROM python:3.10-rc-slim
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends imagemagick vim jq curl
|
||||
|
||||
ADD --chmod=755 https://astral.sh/uv/install.sh /install.sh
|
||||
RUN /install.sh && rm /install.sh
|
||||
RUN /root/.cargo/bin/uv pip install --system black && echo "find . -name "*sync-conflict*" -print -delete; black .; ./bot.py" >/usr/local/bin/start && chmod +x /usr/local/bin/start
|
||||
copy --from=0 /root/.local/bin/uv /root/.local/bin/uv
|
||||
RUN /root/.local/bin/uv pip install --system black && echo "find . -name "*sync-conflict*" -print -delete; black .; ./bot.py" >/usr/local/bin/start && chmod +x /usr/local/bin/start
|
||||
COPY --from=0 /usr/local/lib/python3.10/site-packages /usr/local/lib/python3.10/site-packages
|
||||
ADD app /app
|
||||
WORKDIR /app
|
||||
|
@ -4,6 +4,7 @@ from discord.ext import commands, tasks
|
||||
import core_utils
|
||||
import discord
|
||||
import os
|
||||
import json
|
||||
import random
|
||||
import requests
|
||||
|
||||
@ -29,34 +30,36 @@ class Tarkov(commands.Cog):
|
||||
# Wait until the bot is ready before we actually start executing code
|
||||
await self.bot.wait_until_ready()
|
||||
|
||||
most_recent_spawns = tarkov.tarkov_boss_info()
|
||||
local_spawn_rates = "/tmp/boss_spawns.json"
|
||||
spawns_from_api = tarkov.get_tarkov_boss_info()
|
||||
|
||||
if os.path.exists("/tmp/boss_spawns.txt"):
|
||||
if os.path.exists(local_spawn_rates):
|
||||
embed = discord.Embed(
|
||||
description="-------", color=discord.Color.blue(), type="rich"
|
||||
)
|
||||
known_spawns = eval(open("/tmp/boss_spawns.txt", "r").read())
|
||||
with open(local_spawn_rates, "r") as f:
|
||||
known_spawns = json.load(f)
|
||||
|
||||
changes_dict = tarkov.compare_boss_spawns(most_recent_spawns, known_spawns)
|
||||
|
||||
if most_recent_spawns != known_spawns:
|
||||
if spawns_from_api != known_spawns:
|
||||
embed.set_author(name="🎲 Boss spawn chances have updated 🎲")
|
||||
# for key, value in most_recent_spawns.items():
|
||||
|
||||
changes_dict = tarkov.compare_boss_spawns(known_spawns, spawns_from_api)
|
||||
|
||||
for level, boss in changes_dict.items():
|
||||
for mob, change in boss.items():
|
||||
for boss_name, change in boss.items():
|
||||
embed.add_field(
|
||||
name=level,
|
||||
value=f"{mob}: {change}",
|
||||
value=f"{boss_name}: {change}",
|
||||
inline=False,
|
||||
)
|
||||
|
||||
open("/tmp/boss_spawns.txt", "w").write(str(most_recent_spawns))
|
||||
|
||||
await self.bot.get_channel(channel_id).send(embed=embed)
|
||||
with open(local_spawn_rates, "w") as f:
|
||||
json.dump(spawns_from_api, f)
|
||||
|
||||
else:
|
||||
open("/tmp/boss_spawns.txt", "w").write(str(most_recent_spawns))
|
||||
with open(local_spawn_rates, "w") as f:
|
||||
json.dump(spawns_from_api, f)
|
||||
|
||||
async def get_all_bosses(ctx: discord.AutocompleteContext):
|
||||
"""
|
||||
@ -205,7 +208,7 @@ class Tarkov(commands.Cog):
|
||||
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()
|
||||
levels = tarkov.get_tarkov_boss_info()
|
||||
|
||||
for key, value in levels.items():
|
||||
embed.add_field(
|
||||
@ -242,7 +245,7 @@ class Tarkov(commands.Cog):
|
||||
response = requests.get(wiki_url + boss_name).text
|
||||
soup = BeautifulSoup(response, "html.parser")
|
||||
|
||||
# boss_info = tarkov.tarkov_boss_info()
|
||||
# boss_info = tarkov.get_tarkov_boss_info()
|
||||
# for k, v in boss_info.items():
|
||||
# if boss_name in v:
|
||||
# print(k, v)
|
||||
|
27
app/diff.py
Executable file
27
app/diff.py
Executable file
@ -0,0 +1,27 @@
|
||||
import json
|
||||
from deepdiff import DeepDiff
|
||||
|
||||
|
||||
with open("/tmp/boss_spawns.json", "r") as f:
|
||||
old_spawns = json.load(f)
|
||||
|
||||
with open("/tmp/spawn.json", "r") as f:
|
||||
new_spawns = json.load(f)
|
||||
|
||||
diff = DeepDiff(old_spawns, new_spawns, ignore_order=True, verbose_level=2)
|
||||
|
||||
# Get the differences between the two JSON blobs
|
||||
# Iterate through the diff to find spawnChance differences
|
||||
for key, changes in diff.items():
|
||||
if key == "values_changed":
|
||||
for path, change in changes.items():
|
||||
# Access the level and boss name directly from the path
|
||||
level, boss = (
|
||||
path.split("[")[1].split("]")[0],
|
||||
path.split("[")[2].split("]")[0],
|
||||
)
|
||||
# Print the relevant difference in spawnChance
|
||||
if "new_value" in change:
|
||||
print(
|
||||
f"Level: {level}, Boss: {boss}, Diff in spawnChance: {change['old_value']} -> {change['new_value']}"
|
||||
)
|
@ -1,6 +1,7 @@
|
||||
from bs4 import BeautifulSoup
|
||||
import requests
|
||||
import random
|
||||
import json
|
||||
|
||||
|
||||
def request_wiki(url, heading):
|
||||
@ -30,7 +31,7 @@ def query_tarkov_api(query):
|
||||
).json()["data"]
|
||||
|
||||
|
||||
def tarkov_boss_info():
|
||||
def get_tarkov_boss_info():
|
||||
"""
|
||||
Returns a dict of boss spawn chances per map, and their escorts
|
||||
"""
|
||||
@ -84,22 +85,34 @@ def tarkov_boss_info():
|
||||
return levels
|
||||
|
||||
|
||||
def compare_boss_spawns(dict1, dict2):
|
||||
def compare_boss_spawns(known_spawns: dict, spawns_from_api: dict) -> dict:
|
||||
changes = {} # To store the changes
|
||||
|
||||
for level in dict1:
|
||||
# diff = DeepDiff(known_spawns, spawns_from_api, ignore_order=True, verbose_level=2)
|
||||
|
||||
# # Get the differences between the two JSON blobs
|
||||
# # Iterate through the diff to find spawnChance differences
|
||||
# for key, changes in diff.items():
|
||||
# if key == 'values_changed':
|
||||
# for path, change in changes.items():
|
||||
# # Access the level and boss name directly from the path
|
||||
# level, boss = path.split('[')[1].split(']')[0], path.split('[')[2].split(']')[0]
|
||||
# # Print the relevant difference in spawnChance
|
||||
# if 'new_value' in change:
|
||||
# print(f"Level: {level}, Boss: {boss}, Diff in spawnChance: {change['old_value']} -> {change['new_value']}")
|
||||
|
||||
for level in known_spawns:
|
||||
level_changes = {} # Store changes for each level
|
||||
for boss in dict1.get(level, {}):
|
||||
boss_info_1 = dict1[level].get(boss, {})
|
||||
boss_info_2 = dict2[level].get(boss, {})
|
||||
for boss in known_spawns.get(level, {}):
|
||||
known_boss_info = known_spawns[level].get(boss, {})
|
||||
api_boss_info = spawns_from_api[level].get(boss, {})
|
||||
|
||||
spawnChance_1 = boss_info_1.get("spawnChance", "N/A")
|
||||
spawnChance_2 = boss_info_2.get("spawnChance", "N/A")
|
||||
old = known_boss_info.get("spawnChance", "**0%**")
|
||||
new = api_boss_info.get("spawnChance", "**0%**")
|
||||
|
||||
if spawnChance_1 != spawnChance_2:
|
||||
level_changes[boss] = f"{spawnChance_1} -> {spawnChance_2}"
|
||||
if new != old:
|
||||
level_changes[boss] = f"{old} -> {new}"
|
||||
|
||||
if level_changes:
|
||||
changes[level] = level_changes
|
||||
|
||||
return changes
|
||||
|
1825
install.sh
Normal file
1825
install.sh
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user