diff --git a/app/cogs/tarkov.py b/app/cogs/tarkov.py index 8a956e74..fc74f439 100755 --- a/app/cogs/tarkov.py +++ b/app/cogs/tarkov.py @@ -1,8 +1,6 @@ -from discord import option -from discord.ext import commands, tasks +from discord.ext import commands import core_utils import discord -import json import os import random @@ -29,13 +27,13 @@ class Tarkov(commands.Cog): weapons = tarkov.request_wiki("Weapons", "Weapons") armors = tarkov.request_wiki("Armor_vests", "Armor vests") helmet = tarkov.request_wiki("Headwear", "Headwear") - chest_rigs = tarkov.request_wiki("Chest_rigs", "Chest rigs") + tarkov.request_wiki("Chest_rigs", "Chest rigs") backpacks = tarkov.request_wiki("Backpacks", "Backpacks") gun_mods_trader_level = [ "Use it as it comes from a trader", tarkov.allowed_level_roll(), ] - armor_trader_level = tarkov.allowed_level_roll() + tarkov.allowed_level_roll() embed = discord.Embed( title="🎲🎰 Loadout Lottery 🎰🎲", diff --git a/app/cogs/warframe.py b/app/cogs/warframe.py new file mode 100755 index 00000000..b49f7eae --- /dev/null +++ b/app/cogs/warframe.py @@ -0,0 +1,56 @@ +from bs4 import BeautifulSoup +from discord import option +from discord.ext import commands, tasks +import discord +import json +import os +import queue +import requests +import threading + +import core_utils +import warframe + + +class Warframe(commands.Cog): + def __init__(self, bot): + self.bot: commands.Bot = bot + + warframe = discord.SlashCommandGroup("warframe", "Warframe related commands") + + async def get_all_mods(ctx: discord.AutocompleteContext): + threads = [] + q = queue.Queue(maxsize=0) + for letter in [chr(i) for i in range(ord("a"), ord("z") + 1)]: + t = threading.Thread(target=warframe.query_wiki, args=(letter, q)) + t.start() + threads.append(t) + + # Block until all threads / queues are done working + q.join() + for x in threads: + x.join() + + return sorted([item for sublist in list(q.queue) for item in sublist]) + + @warframe.command( + guild_ids=core_utils.my_guilds, + name="mod", + description="Query the warframe wiki for a mod", + ) + async def get_warframe_mod( + self, + ctx: commands.Context, + mod: discord.Option( + str, + autocomplete=discord.utils.basic_autocomplete(get_all_mods), + description="The mod to look up", + ), + ): + await ctx.defer() + # embed = await star_citizen.get_ship(ship_name=ship) + await ctx.send_followup(f"you picked {mod}") + + +def setup(bot): + bot.add_cog(Warframe(bot)) diff --git a/app/star_citizen.py b/app/star_citizen.py index d5f5c5d4..cf7b6154 100755 --- a/app/star_citizen.py +++ b/app/star_citizen.py @@ -1,6 +1,5 @@ from bs4 import BeautifulSoup import discord -import json import os import re import requests @@ -482,8 +481,8 @@ async def calculate_trade_profits(commodity, scu=None): url="https://media.starcitizen.tools/thumb/b/bb/Shubin_logo_circle.png/120px-Shubin_logo_circle.png" ) - price_origin = response["price_origin"] - price_destination = response["price_destination"] + # price_origin = response["price_origin"] + response["price_destination"] margin = response["price_margin"] investment = response["investment"] profit = response["profit"] @@ -503,14 +502,14 @@ async def calculate_trade_profits(commodity, scu=None): embed.add_field( name="Initial Investment", - value="${:20,.2f} aUEC".format(investment), + value="¤{:20,.2f} aUEC".format(investment), inline=False, ) embed.add_field( - name="Total Profit", value="${:20,.2f} aUEC".format(profit), inline=True + name="Total Profit", value="¤{:20,.2f} aUEC".format(profit), inline=True ) embed.add_field( - name="Margin", value="${:20,.2f} aUEC/scu".format(margin), inline=True + name="Margin", value="¤{:20,.2f} aUEC/scu".format(margin), inline=True ) return embed @@ -550,7 +549,7 @@ async def get_price(commodity, scu): embed.add_field( name="Best place to sell %s of %s" % (scu_string, commodity), - value="%s: $%s" + value="%s: ¤%s" % ( max(profits, key=profits.get), "{:20,.2f}".format(profits[max(profits, key=profits.get)]).strip(), diff --git a/app/tarkov.py b/app/tarkov.py index 2c5c5b99..bccbe5ea 100755 --- a/app/tarkov.py +++ b/app/tarkov.py @@ -8,7 +8,7 @@ def request_wiki(url, heading): "https://escapefromtarkov.fandom.com/wiki/Category:" + url, timeout=25 ).text soup = BeautifulSoup(response, "html.parser") - h2_heading = soup.find(f"h2", string=f'Pages in category "{heading}"') + h2_heading = soup.find("h2", string=f'Pages in category "{heading}"') return [link.text for link in h2_heading.find_next("div").find_all("a")] diff --git a/app/warframe.py b/app/warframe.py new file mode 100755 index 00000000..b9a19c43 --- /dev/null +++ b/app/warframe.py @@ -0,0 +1,22 @@ +from bs4 import BeautifulSoup +import json +import queue +import requests +import threading + + +def query_wiki(letter, q: queue.Queue): + """ + returns a list of all ships in the game, which can then be passed to the /ship command for auto complete + """ + # Step through the alphabet, and query each page + url = f"https://warframe.fandom.com/wiki/Category:Mods?from={letter}" + response = requests.get(url) + soup = BeautifulSoup(response.text, "html.parser") + + # Find the div element with the specified class + div_element = soup.find("div", {"class": "category-page__members"}).find_all("li") + + # add them all to the main list + q.put([li.text.strip() for li in div_element if "Category" not in li.text]) + return sorted([item for sublist in list(q.queue) for item in sublist]) diff --git a/helm/values.yaml b/helm/values.yaml index 0431e60a..9d6029f3 100755 --- a/helm/values.yaml +++ b/helm/values.yaml @@ -91,4 +91,3 @@ secrets: twitch_token: twitch_token uexcorp_key: uexcorp_key wolfram_token: wolfram_token - pal_rcon_pass: pal_rcon_pass diff --git a/scratchpad/get_warframe_mods.py b/scratchpad/get_warframe_mods.py index 151af84d..d8c41fac 100755 --- a/scratchpad/get_warframe_mods.py +++ b/scratchpad/get_warframe_mods.py @@ -5,28 +5,16 @@ import queue def get_all_mods(letter, q: queue.Queue): - all_mods = [] # Step through the alphabet, and query each page url = f"https://warframe.fandom.com/wiki/Category:Mods?from={letter}" response = requests.get(url) soup = BeautifulSoup(response.text, "html.parser") # Find the div element with the specified class - div_element = soup.find("div", {"class": "category-page__members"}) - - # Find all the li elements within the div - li_elements = div_element.find_all("li") + div_element = soup.find("div", {"class": "category-page__members"}).find_all("li") # add them all to the main list - q.put( - [ - li.text.strip() - for li in soup.find("div", {"class": "category-page__members"}).find_all( - "li" - ) - if "Category" not in li.text - ] - ) + q.put([li.text.strip() for li in div_element if "Category" not in li.text]) threads = []