Skip to content

Commit

Permalink
Fixed some bugs in events and trending coins
Browse files Browse the repository at this point in the history
  • Loading branch information
StephanAkkerman committed Dec 20, 2023
1 parent 5308b21 commit 11ff79c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/cogs/loops/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,13 @@ async def post_events(self):
"""

# Send this message every friday at 23:00 UTC
if datetime.datetime.today().weekday() != 4:
if datetime.datetime.utcnow().hour != 23:
if datetime.datetime.today().weekday() == 4:
if datetime.datetime.utcnow().hour == 23:
df = await self.get_events()

# If time == "All Day" convert it to 00:00
df["time"] = df["time"].str.replace("All Day", "00:00")

# Create datetime
df["datetime"] = pd.to_datetime(
df["date"] + " " + df["time"],
Expand Down
6 changes: 4 additions & 2 deletions src/cogs/loops/listings.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from util.disc_util import get_channel


class Exchange_Listings:
class Exchange_Listings(commands.Cog):
"""
This class contains the cog for posting the new Binance listings
It can be enabled / disabled in the config under ["LOOPS"]["NEW_LISTINGS"].
Expand All @@ -30,7 +30,6 @@ def __init__(self, bot: commands.Bot) -> None:
)

asyncio.create_task(self.set_old_symbols())
self.new_listings.start()

async def get_symbols(self, exchange: str) -> list:
"""
Expand Down Expand Up @@ -122,6 +121,9 @@ async def set_old_symbols(self) -> None:
for exchange in self.exchanges:
self.old_symbols[exchange] = await self.get_symbols(exchange)

# Start after setting all the symbols
self.new_listings.start()

@loop(hours=6)
async def new_listings(self) -> None:
"""
Expand Down
3 changes: 3 additions & 0 deletions src/util/cg_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,9 @@ async def get_trending_coins() -> pd.DataFrame:
# Add website to Symbol using format: [Symbol](Website)
df["Symbol"] = "[" + df["Symbol"] + "](" + df["Website"] + ")"

# Replace NaN values in '24h Volume' with values from 'Mkt Cap'
df["24h Volume"] = df["24h Volume"].fillna(df["Mkt Cap"])

# Fix volume if it contains a %
df.loc[df["24h Volume"].str.contains("%"), "24h Volume"] = df["Mkt Cap"]

Expand Down

0 comments on commit 11ff79c

Please sign in to comment.