Rmeoving unused code and adding a makefile
This commit is contained in:
parent
d58ce8a2c2
commit
ecf009f051
11
Makefile
Normal file
11
Makefile
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
format:
|
||||||
|
docker run --rm -ti -v ${PWD}:/tmp/python/app python:alpine sh -c "cd /tmp/python; pip install -q black; black ."
|
||||||
|
|
||||||
|
clean:
|
||||||
|
docker rm -f dragon-bot-test
|
||||||
|
rm -vr app/__pycache__ app/cogs/__pycache__
|
||||||
|
|
||||||
|
discord_token := "MzQ1MjkwMTI5OTQ4Mjc4Nzg0.G16mG8.vxgQLwnbusG9fSlXvAFV0wTUmRsJJlPnQ3bpco"
|
||||||
|
DRAGON_ENV := "test"
|
||||||
|
test: clean format
|
||||||
|
docker run -ti -v ${PWD}/app:/app --rm --name dragon-bot-test -e DRAGON_ENV=${DRAGON_ENV} -e discord_token=${discord_token} dragon-bot-test bash
|
@ -62,60 +62,6 @@ class StarCitizen(commands.Cog):
|
|||||||
embed = await star_citizen.calculate_trade_profies(commodity=commodity, scu=scu)
|
embed = await star_citizen.calculate_trade_profies(commodity=commodity, scu=scu)
|
||||||
await ctx.send_followup(embed=embed)
|
await ctx.send_followup(embed=embed)
|
||||||
|
|
||||||
@tasks.loop(seconds=5)
|
|
||||||
async def poll_for_patch_notes(self):
|
|
||||||
# Wait until the bot is ready before we actually start executing code
|
|
||||||
await self.bot.wait_until_ready()
|
|
||||||
|
|
||||||
blog_url = "https://www.spaceloop.it/en/blog-en"
|
|
||||||
|
|
||||||
headers = {
|
|
||||||
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20100101 Firefox/112.0"
|
|
||||||
}
|
|
||||||
|
|
||||||
response = requests.get(
|
|
||||||
blog_url,
|
|
||||||
headers=headers,
|
|
||||||
).text
|
|
||||||
|
|
||||||
soup = BeautifulSoup(response, "html.parser")
|
|
||||||
|
|
||||||
latest_post = soup.find("div", {"class": "posts-wrapper"}).findNext(
|
|
||||||
"h2", {"class": "blog-entry-title"}
|
|
||||||
)
|
|
||||||
print(latest_post)
|
|
||||||
|
|
||||||
if "Patch Notes" in latest_post.text:
|
|
||||||
patch_notes_page = requests.get(
|
|
||||||
latest_post.findNext("a")["href"],
|
|
||||||
headers=headers,
|
|
||||||
).text
|
|
||||||
|
|
||||||
soup = BeautifulSoup(patch_notes_page, "html.parser")
|
|
||||||
|
|
||||||
patch_number = soup.find("h2", {"class": "wp-block-heading"}).text
|
|
||||||
print(patch_number)
|
|
||||||
|
|
||||||
embed = discord.Embed(
|
|
||||||
description="-------", color=discord.Color.blue(), type="rich"
|
|
||||||
)
|
|
||||||
|
|
||||||
embed.set_thumbnail(
|
|
||||||
url="https://media.robertsspaceindustries.com/t0q21kbb3zrpt/source.png"
|
|
||||||
)
|
|
||||||
embed.set_author(name=patch_number)
|
|
||||||
|
|
||||||
for bullet in soup.find_all("h3"):
|
|
||||||
if bullet.text == "Patch News":
|
|
||||||
break
|
|
||||||
embed.add_field(
|
|
||||||
name=bullet.text,
|
|
||||||
value="\n".join([x for x in bullet.findNext("ul").find_all("li")]),
|
|
||||||
inline=False,
|
|
||||||
)
|
|
||||||
|
|
||||||
await self.bot.get_channel(932476007439552522).send(embed=embed)
|
|
||||||
|
|
||||||
@tasks.loop(seconds=5)
|
@tasks.loop(seconds=5)
|
||||||
async def poll_status_page(self):
|
async def poll_status_page(self):
|
||||||
# Wait until the bot is ready before we actually start executing code
|
# Wait until the bot is ready before we actually start executing code
|
||||||
@ -135,9 +81,9 @@ class StarCitizen(commands.Cog):
|
|||||||
latest_incident = current_status.findNext("h2")
|
latest_incident = current_status.findNext("h2")
|
||||||
|
|
||||||
# Check if we've already notified
|
# Check if we've already notified
|
||||||
if os.path.exists(rsi_incident_file):
|
|
||||||
if (
|
if (
|
||||||
open(rsi_incident_file, "r").read()
|
os.path.exists(rsi_incident_file)
|
||||||
|
and open(rsi_incident_file, "r").read()
|
||||||
== latest_incident.findNext("a")["href"]
|
== latest_incident.findNext("a")["href"]
|
||||||
):
|
):
|
||||||
return
|
return
|
||||||
@ -168,15 +114,6 @@ class StarCitizen(commands.Cog):
|
|||||||
)
|
)
|
||||||
|
|
||||||
await self.bot.get_channel(1097567909640929340).send(embed=embed)
|
await self.bot.get_channel(1097567909640929340).send(embed=embed)
|
||||||
# sent_embed = await self.bot.get_channel(932476007439552522).send(
|
|
||||||
# embed=embed
|
|
||||||
# )
|
|
||||||
|
|
||||||
# # If the devs update the content of the incident, update the embed with the new text
|
|
||||||
# if details.text != sent_embed.embeds[0].fields[0].value:
|
|
||||||
# sent_embed.embeds[0].set_field_at(
|
|
||||||
# index=0, name="Details", value=details.text, inline=True
|
|
||||||
# )
|
|
||||||
|
|
||||||
|
|
||||||
def setup(bot):
|
def setup(bot):
|
||||||
|
@ -1 +0,0 @@
|
|||||||
docker run --rm -ti -v $(pwd):/tmp/python/app python:alpine sh -c "cd /tmp/python ; pip install -q black; black ."
|
|
@ -1,14 +0,0 @@
|
|||||||
printf "\n[-] Formatting code\n"
|
|
||||||
./format_code.sh
|
|
||||||
printf "[+] Done\n"
|
|
||||||
|
|
||||||
# Remove the running container so we can re-use the container name 'dragon-bot'
|
|
||||||
printf "\n[-] Deleting old dragon-bot container from system\n"
|
|
||||||
docker rm -f dragon-bot-test
|
|
||||||
printf "[+] Done\n"
|
|
||||||
|
|
||||||
printf "\n[-] Running dragon bot in test mode\n"
|
|
||||||
chmod +x ./app/bot.py
|
|
||||||
docker build -f ./Dockerfile-test-env -t dragon-bot-test . || exit
|
|
||||||
|
|
||||||
docker run -ti -v $(pwd)/app:/app --rm --name dragon-bot-test -e DRAGON_ENV=test -e token="MzQ1MjkwMTI5OTQ4Mjc4Nzg0.G16mG8.vxgQLwnbusG9fSlXvAFV0wTUmRsJJlPnQ3bpco" dragon-bot-test bash
|
|
Loading…
x
Reference in New Issue
Block a user