Fixing the incdient code and also /ship
This commit is contained in:
parent
9bd591e102
commit
9d1549559a
@ -3,7 +3,7 @@ ADD app/requirements.txt /requirements.txt
|
|||||||
RUN pip install --disable-pip-version-check --verbose -r requirements.txt
|
RUN pip install --disable-pip-version-check --verbose -r requirements.txt
|
||||||
|
|
||||||
FROM python:3.10-rc-slim
|
FROM python:3.10-rc-slim
|
||||||
RUN apt-get update && apt-get install -y --no-install-recommends imagemagick
|
RUN apt-get update && apt-get install -y --no-install-recommends imagemagick vim jq
|
||||||
RUN pip install black && echo "black .; ./bot.py" >/usr/local/bin/start && chmod +x /usr/local/bin/start
|
RUN pip install black && echo "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
|
COPY --from=0 /usr/local/lib/python3.10/site-packages /usr/local/lib/python3.10/site-packages
|
||||||
ADD app /app
|
ADD app /app
|
||||||
|
0
app/cogs/actual_utils.py
Executable file → Normal file
0
app/cogs/actual_utils.py
Executable file → Normal file
0
app/cogs/markov.py
Executable file → Normal file
0
app/cogs/markov.py
Executable file → Normal file
0
app/cogs/poll.py
Executable file → Normal file
0
app/cogs/poll.py
Executable file → Normal file
0
app/cogs/server_utils.py
Executable file → Normal file
0
app/cogs/server_utils.py
Executable file → Normal file
0
app/cogs/stable_diffusion.py
Executable file → Normal file
0
app/cogs/stable_diffusion.py
Executable file → Normal file
139
app/cogs/star_citizen.py
Executable file → Normal file
139
app/cogs/star_citizen.py
Executable file → Normal file
@ -69,10 +69,9 @@ class StarCitizen(commands.Cog):
|
|||||||
|
|
||||||
response = requests.get(url).text
|
response = requests.get(url).text
|
||||||
soup = BeautifulSoup(response, "html.parser")
|
soup = BeautifulSoup(response, "html.parser")
|
||||||
|
h2_heading = soup.find("h2", text='Pages in category "Ships"')
|
||||||
|
|
||||||
all_ships = [
|
all_ships = [link.text for link in h2_heading.find_next("div").find_all("a")]
|
||||||
a.text for a in soup.select("div.mw-category.mw-category-columns a")
|
|
||||||
]
|
|
||||||
|
|
||||||
return all_ships
|
return all_ships
|
||||||
|
|
||||||
@ -225,60 +224,72 @@ class StarCitizen(commands.Cog):
|
|||||||
response = requests.get(status_url).text
|
response = requests.get(status_url).text
|
||||||
soup = BeautifulSoup(response, "html.parser")
|
soup = BeautifulSoup(response, "html.parser")
|
||||||
|
|
||||||
current_status = soup.find("div", {"class": "global-status"}).findNext("span")
|
|
||||||
|
|
||||||
rsi_incident_file = "/tmp/rsi_incident"
|
rsi_incident_file = "/tmp/rsi_incident"
|
||||||
|
current_status = soup.find("div", {"class": "summary"})
|
||||||
|
|
||||||
if current_status.text != "Operational":
|
if current_status.text.strip() != "No issues detectedd":
|
||||||
# Find the lastest incident
|
# Find the lastest incident
|
||||||
latest_incident = current_status.findNext("h2")
|
latest_incident = current_status.findNext("h3")
|
||||||
current_incident_url = status_url + latest_incident.findNext("a")["href"]
|
|
||||||
details = latest_incident.findNext("div", {"class": "markdown"}).text
|
current_incident_url = (
|
||||||
|
latest_incident.find_next("div", class_="issue no-underline")
|
||||||
|
.get("onclick")
|
||||||
|
.split("=")[-1]
|
||||||
|
.replace("\\", "")
|
||||||
|
)
|
||||||
|
|
||||||
|
details = latest_incident.findNext("span", {"class": "issue__content"}).text
|
||||||
|
|
||||||
if os.path.exists(rsi_incident_file):
|
if os.path.exists(rsi_incident_file):
|
||||||
file_contents = json.loads(open(rsi_incident_file).read())
|
file_contents = json.loads(open(rsi_incident_file).read())
|
||||||
deets = file_contents["details"]
|
deets = file_contents["details"]
|
||||||
incident_link = file_contents["incident_link"]
|
incident_link = file_contents["incident_link"]
|
||||||
|
|
||||||
if current_incident_url == incident_link:
|
if current_incident_url != incident_link:
|
||||||
if deets != details:
|
print("Current incident url did not match wahts in the file")
|
||||||
embed = discord.Embed(
|
embed = star_citizen.build_alert_embed(
|
||||||
description="-------",
|
thumbnail="https://media.robertsspaceindustries.com/t0q21kbb3zrpt/source.png",
|
||||||
color=discord.Color.yellow(),
|
author="🚨 OH NO THERES AN INCIDENT 🚨",
|
||||||
type="rich",
|
image="https://media.giphy.com/media/WWIZJyXHXscn8JC1e0/giphy.gif",
|
||||||
)
|
details=details,
|
||||||
|
link=current_incident_url,
|
||||||
|
)
|
||||||
|
star_citizen.write_incident_file(
|
||||||
|
file_path=rsi_incident_file,
|
||||||
|
url=current_incident_url,
|
||||||
|
details=details,
|
||||||
|
)
|
||||||
|
|
||||||
embed.set_thumbnail(
|
# # Testing channel
|
||||||
url="https://media.robertsspaceindustries.com/t0q21kbb3zrpt/source.png"
|
# await star_citizen.send_alert(
|
||||||
)
|
# self, channel=932476007439552522, embed=embed
|
||||||
embed.set_author(
|
# )
|
||||||
name="⚠️ THERE HAS BEEN AN UPDATE TO THE ONGOING INCIDENT ⚠️"
|
|
||||||
)
|
|
||||||
# embed.set_image(
|
|
||||||
# url="https://media.giphy.com/media/WWIZJyXHXscn8JC1e0/giphy.gif"
|
|
||||||
# )
|
|
||||||
embed.add_field(name="Details", value=deets, inline=True)
|
|
||||||
|
|
||||||
embed.add_field(
|
# Actual channel
|
||||||
name="LINK",
|
await star_citizen.send_alert(
|
||||||
value=incident_link,
|
self, channel=1097567909640929340, embed=embed
|
||||||
inline=False,
|
)
|
||||||
)
|
elif deets != details:
|
||||||
|
star_citizen.write_incident_file(
|
||||||
await self.bot.get_channel(1097567909640929340).send(
|
file_path=rsi_incident_file,
|
||||||
embed=embed
|
url=current_incident_url,
|
||||||
)
|
details=details,
|
||||||
|
)
|
||||||
# Testing channel
|
embed = star_citizen.build_alert_embed(
|
||||||
# await self.bot.get_channel(932476007439552522).send(
|
thumbnail="https://media.robertsspaceindustries.com/t0q21kbb3zrpt/source.png",
|
||||||
# embed=embed
|
author="⚠️ THERE HAS BEEN AN UPDATE TO THE ONGOING INCIDENT ⚠️",
|
||||||
# )
|
image="https://media.giphy.com/media/WWIZJyXHXscn8JC1e0/giphy.gif",
|
||||||
|
details=deets,
|
||||||
star_citizen.write_incident_file(
|
link=incident_link,
|
||||||
file_path=rsi_incident_file,
|
)
|
||||||
url=current_incident_url,
|
# # Testing channel
|
||||||
details=details,
|
# await star_citizen.send_alert(
|
||||||
)
|
# self, channel=932476007439552522, embed=embed
|
||||||
|
# )
|
||||||
|
# Actual channel
|
||||||
|
await star_citizen.send_alert(
|
||||||
|
self, channel=1097567909640929340, embed=embed
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
# Write the incident's body to a json file to read later
|
# Write the incident's body to a json file to read later
|
||||||
star_citizen.write_incident_file(
|
star_citizen.write_incident_file(
|
||||||
@ -287,32 +298,24 @@ class StarCitizen(commands.Cog):
|
|||||||
details=details,
|
details=details,
|
||||||
)
|
)
|
||||||
|
|
||||||
embed = discord.Embed(
|
embed = star_citizen.build_alert_embed(
|
||||||
description="-------", color=discord.Color.red(), type="rich"
|
thumbnail="https://media.robertsspaceindustries.com/t0q21kbb3zrpt/source.png",
|
||||||
|
author="🚨 OH NO THERES AN INCIDENT 🚨",
|
||||||
|
image="https://media.giphy.com/media/WWIZJyXHXscn8JC1e0/giphy.gif",
|
||||||
|
details=details,
|
||||||
|
link=current_incident_url,
|
||||||
)
|
)
|
||||||
|
|
||||||
embed.set_thumbnail(
|
# # Testing channel
|
||||||
url="https://media.robertsspaceindustries.com/t0q21kbb3zrpt/source.png"
|
# await star_citizen.send_alert(
|
||||||
)
|
# self, channel=932476007439552522, embed=embed
|
||||||
embed.set_author(name="🚨 OH NO THERES AN INCIDENT 🚨")
|
|
||||||
embed.set_image(
|
|
||||||
url="https://media.giphy.com/media/WWIZJyXHXscn8JC1e0/giphy.gif"
|
|
||||||
)
|
|
||||||
embed.add_field(name="Details", value=details, inline=True)
|
|
||||||
|
|
||||||
embed.add_field(
|
|
||||||
name="LINK",
|
|
||||||
value=current_incident_url,
|
|
||||||
inline=False,
|
|
||||||
)
|
|
||||||
|
|
||||||
await self.bot.get_channel(1097567909640929340).send(embed=embed)
|
|
||||||
|
|
||||||
# Testing channel
|
|
||||||
# await self.bot.get_channel(932476007439552522).send(
|
|
||||||
# embed=embed
|
|
||||||
# )
|
# )
|
||||||
|
|
||||||
|
# Actual channel
|
||||||
|
await star_citizen.send_alert(
|
||||||
|
self, channel=1097567909640929340, embed=embed
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def setup(bot):
|
def setup(bot):
|
||||||
bot.add_cog(StarCitizen(bot))
|
bot.add_cog(StarCitizen(bot))
|
||||||
|
0
app/cogs/user_functions.py
Executable file → Normal file
0
app/cogs/user_functions.py
Executable file → Normal file
@ -12,6 +12,32 @@ pp = pprint.PrettyPrinter(indent=4)
|
|||||||
wiki_url = "https://starcitizen.tools/"
|
wiki_url = "https://starcitizen.tools/"
|
||||||
|
|
||||||
|
|
||||||
|
async def send_alert(self, channel, embed):
|
||||||
|
await self.bot.get_channel(channel).send(embed=embed)
|
||||||
|
|
||||||
|
|
||||||
|
def build_alert_embed(thumbnail=None, author=None, image=None, details=None, link=None):
|
||||||
|
embed = discord.Embed(description="-------", color=discord.Color.red(), type="rich")
|
||||||
|
|
||||||
|
if thumbnail:
|
||||||
|
embed.set_thumbnail(url=thumbnail)
|
||||||
|
|
||||||
|
embed.set_author(name=author)
|
||||||
|
|
||||||
|
if image:
|
||||||
|
embed.set_image(url=image)
|
||||||
|
|
||||||
|
embed.add_field(name="Details", value=details, inline=True)
|
||||||
|
|
||||||
|
embed.add_field(
|
||||||
|
name="LINK",
|
||||||
|
value=link,
|
||||||
|
inline=False,
|
||||||
|
)
|
||||||
|
|
||||||
|
return embed
|
||||||
|
|
||||||
|
|
||||||
def write_incident_file(file_path, url, details):
|
def write_incident_file(file_path, url, details):
|
||||||
info_dict = {
|
info_dict = {
|
||||||
"incident_link": url,
|
"incident_link": url,
|
||||||
|
0
dalebot-overview.py
Executable file → Normal file
0
dalebot-overview.py
Executable file → Normal file
0
helm/.helmignore
Executable file → Normal file
0
helm/.helmignore
Executable file → Normal file
0
helm/Chart.yaml
Executable file → Normal file
0
helm/Chart.yaml
Executable file → Normal file
0
helm/templates/_helpers.tpl
Executable file → Normal file
0
helm/templates/_helpers.tpl
Executable file → Normal file
0
helm/templates/hpa.yaml
Executable file → Normal file
0
helm/templates/hpa.yaml
Executable file → Normal file
0
helm/templates/ingress.yaml
Executable file → Normal file
0
helm/templates/ingress.yaml
Executable file → Normal file
Loading…
x
Reference in New Issue
Block a user