Change the dollar sign to AUEC sign for star citizen, also remove palworld rcon pass env var

This commit is contained in:
Luke Robles 2024-07-07 08:27:11 -07:00
parent 320bfb25a1
commit 23f614243c
7 changed files with 90 additions and 28 deletions

View File

@ -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 🎰🎲",

56
app/cogs/warframe.py Executable file
View File

@ -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))

View File

@ -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(),

View File

@ -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")]

22
app/warframe.py Executable file
View File

@ -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])

View File

@ -91,4 +91,3 @@ secrets:
twitch_token: twitch_token
uexcorp_key: uexcorp_key
wolfram_token: wolfram_token
pal_rcon_pass: pal_rcon_pass

View File

@ -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 = []