From 9c08863667550a907c57b58b11bfb13bd3834c48 Mon Sep 17 00:00:00 2001 From: Luke Robles Date: Sat, 23 Dec 2023 14:11:23 -0800 Subject: [PATCH] Adding buy location back to the /ship command --- .drone.yml | 0 .gitignore | 0 .pre-commit-config.yaml | 0 Makefile | 1 + README.md | 0 app/animals.py | 0 app/bot.py | 0 app/cogs/actual_utils.py | 0 app/cogs/animal_functions.py | 0 app/cogs/markov.py | 0 app/cogs/poll.py | 0 app/cogs/server_utils.py | 0 app/cogs/stable_diffusion.py | 0 app/cogs/star_citizen.py | 0 app/cogs/user_functions.py | 0 app/get_from_reddit.py | 0 app/star_citizen.py | 49 ++++++++++++++++++------------------ dalebot-overview.py | 0 helm/.helmignore | 0 helm/Chart.yaml | 0 helm/templates/_helpers.tpl | 0 helm/templates/hpa.yaml | 0 helm/templates/ingress.yaml | 0 23 files changed, 25 insertions(+), 25 deletions(-) mode change 100644 => 100755 .drone.yml mode change 100644 => 100755 .gitignore mode change 100644 => 100755 .pre-commit-config.yaml mode change 100644 => 100755 Makefile mode change 100644 => 100755 README.md mode change 100644 => 100755 app/animals.py mode change 100644 => 100755 app/bot.py mode change 100644 => 100755 app/cogs/actual_utils.py mode change 100644 => 100755 app/cogs/animal_functions.py mode change 100644 => 100755 app/cogs/markov.py mode change 100644 => 100755 app/cogs/poll.py mode change 100644 => 100755 app/cogs/server_utils.py mode change 100644 => 100755 app/cogs/stable_diffusion.py mode change 100644 => 100755 app/cogs/star_citizen.py mode change 100644 => 100755 app/cogs/user_functions.py mode change 100644 => 100755 app/get_from_reddit.py mode change 100644 => 100755 app/star_citizen.py mode change 100644 => 100755 dalebot-overview.py mode change 100644 => 100755 helm/.helmignore mode change 100644 => 100755 helm/Chart.yaml mode change 100644 => 100755 helm/templates/_helpers.tpl mode change 100644 => 100755 helm/templates/hpa.yaml mode change 100644 => 100755 helm/templates/ingress.yaml diff --git a/.drone.yml b/.drone.yml old mode 100644 new mode 100755 diff --git a/.gitignore b/.gitignore old mode 100644 new mode 100755 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml old mode 100644 new mode 100755 diff --git a/Makefile b/Makefile old mode 100644 new mode 100755 index ad28f84d..b776097d --- a/Makefile +++ b/Makefile @@ -2,6 +2,7 @@ include .env # https://github.com/psf/black/issues/1106#issuecomment-547230844 format: + chmod -R 755 ${PWD} docker run --rm -ti -v ${PWD}:/tmp/python/app pyfound/black:latest_release sh -c "black /tmp/python" clean: diff --git a/README.md b/README.md old mode 100644 new mode 100755 diff --git a/app/animals.py b/app/animals.py old mode 100644 new mode 100755 diff --git a/app/bot.py b/app/bot.py old mode 100644 new mode 100755 diff --git a/app/cogs/actual_utils.py b/app/cogs/actual_utils.py old mode 100644 new mode 100755 diff --git a/app/cogs/animal_functions.py b/app/cogs/animal_functions.py old mode 100644 new mode 100755 diff --git a/app/cogs/markov.py b/app/cogs/markov.py old mode 100644 new mode 100755 diff --git a/app/cogs/poll.py b/app/cogs/poll.py old mode 100644 new mode 100755 diff --git a/app/cogs/server_utils.py b/app/cogs/server_utils.py old mode 100644 new mode 100755 diff --git a/app/cogs/stable_diffusion.py b/app/cogs/stable_diffusion.py old mode 100644 new mode 100755 diff --git a/app/cogs/star_citizen.py b/app/cogs/star_citizen.py old mode 100644 new mode 100755 diff --git a/app/cogs/user_functions.py b/app/cogs/user_functions.py old mode 100644 new mode 100755 diff --git a/app/get_from_reddit.py b/app/get_from_reddit.py old mode 100644 new mode 100755 diff --git a/app/star_citizen.py b/app/star_citizen.py old mode 100644 new mode 100755 index 28f8de04..b4c10d12 --- a/app/star_citizen.py +++ b/app/star_citizen.py @@ -144,6 +144,16 @@ async def get_ship(ship_name): description="-------", color=discord.Color.blue(), type="rich" ) + try: + item_uuid = ( + soup.find("div", {"class": "infobox__label"}, string="UUID") + .findNext("div", {"class": "infobox__data"}) + .text + ) + except Exception: + item_uuid = "N/A" + embed.set_footer(text="item UUID: %s" % item_uuid) + try: description = ( soup.find("section", {"class": "citizen-section-collapsible"}) @@ -186,15 +196,6 @@ async def get_ship(ship_name): ship_role = "" embed.add_field(name="**Role**", value=ship_role) - try: - item_uuid = ( - soup.find("div", {"class": "infobox__label"}, string="UUID") - .findNext("div", {"class": "infobox__data"}) - .text - ) - except Exception: - item_uuid = "N/A" - embed.set_footer(text="item UUID: %s" % item_uuid) try: ingame_price = requests.get( @@ -202,17 +203,16 @@ async def get_ship(ship_name): ).text price_soup = BeautifulSoup(ingame_price, "html.parser") - table = price_soup.find("div", class_="pricetab").find_next("table") + price_table = price_soup.find("div", class_="pricetab").find_next("table") - second_row = table.find_all("tr")[1] + second_row = price_table.find_all("tr")[1] ingame_price = ( second_row.find_all("td")[1].get_text(strip=True).replace(" ", ",") ) - price = "[%s](%s%s#Universe_availability)" % ( + price = "[%s](https://finder.cstone.space/ShipShops1/%s)" % ( ingame_price, - wiki_url, - wiki_ship_name, + item_uuid, ) if "Not available" in ingame_price: @@ -266,18 +266,17 @@ async def get_ship(ship_name): pass try: - buy_location = ( - soup.find("span", {"id": "Universe_availability"}) - .findNext("tbody") - .find_all("td", {"class", "Location smwtype_wpg"}) - ) + price_table = price_soup.find("div", class_="pricetab").find_next("table") - if len(buy_location): - embed.add_field( - name="**Buyable At**", - value=", ".join(str(x.text) for x in buy_location), - inline=True, - ) + second_row = price_table.find_all("tr")[1] + buy_location = ( + second_row.find_all("td")[0].get_text(strip=True).split("-")[-1] + ) + embed.add_field( + name="**Buyable At**", + value=buy_location, + inline=True, + ) except Exception: pass diff --git a/dalebot-overview.py b/dalebot-overview.py old mode 100644 new mode 100755 diff --git a/helm/.helmignore b/helm/.helmignore old mode 100644 new mode 100755 diff --git a/helm/Chart.yaml b/helm/Chart.yaml old mode 100644 new mode 100755 diff --git a/helm/templates/_helpers.tpl b/helm/templates/_helpers.tpl old mode 100644 new mode 100755 diff --git a/helm/templates/hpa.yaml b/helm/templates/hpa.yaml old mode 100644 new mode 100755 diff --git a/helm/templates/ingress.yaml b/helm/templates/ingress.yaml old mode 100644 new mode 100755