Compare commits

...

7 commits

Author SHA1 Message Date
6c919081c7 rename collage method 2025-10-08 23:20:33 -03:00
8b496f7b12 create song collages 2025-10-08 23:19:32 -03:00
13852f59d3 fix chart generation 2025-10-08 23:06:12 -03:00
48e6a4442a fix typo 2025-10-08 23:02:14 -03:00
4ce5bdc805 create artist collages 2025-10-08 23:00:06 -03:00
d130a1a3c5 restructure collage generation 2025-10-08 22:53:38 -03:00
f9dc2e5b94 minor formatting 2025-10-08 22:42:49 -03:00
3 changed files with 105 additions and 64 deletions

8
commands/_top.py Normal file
View file

@ -0,0 +1,8 @@
import nerimity
import bot
def setup(bot: bot.Bot):
@bot.command(name="topartists", aliases=["ta","topartist"])
@bot.slash_command(name="topartists")
def topartists(ctx: nerimity.Context, timeframe)

View file

@ -8,14 +8,11 @@ import utils as u
# from catbox_async_uploader.catbox_async_uploader.enums import LitterboxDuration
# from pyzxz import ZeroXZero
def setup(bot: bot.Bot):
@bot.command(name="chart", aliases=["c", "chartalbum", "albumchart", "collage"])
@bot.slash_command(name="chartalbum", description="Generate an album collage.")
async def chartalbum(ctx: nerimity.Context, size: str = "3x3", timeframe: str = "7day", username: str = None):
async def send_collage(bot: bot.Bot, ctx: nerimity.Context, entity: str, size: str = "3x3", timeframe: str = "7day", username: str = None):
temp_msg = None
if 'x' not in size:
await ctx.send(u.error_msg("Please provide a valid size.\nie `/chartalbum 5x5`"))
await ctx.send(u.error_msg(f"Please provide a valid size.\nie `/chart{entity} 5x5`"))
return
if int(size.split('x')[0]) > 5 or int(size.split('x')[1]) > 5:
@ -59,10 +56,10 @@ def setup(bot: bot.Bot):
return
try:
temp_msg = await ctx.send(f"Generating album chart for **{username}**...")
temp_msg = await ctx.send(f"Generating {entity} chart for **{username}**...")
image = bot.collage_generator.generate(
entity = "album",
entity = entity,
username = username,
rows = int(size.split(sep="x")[0]),
cols = int(size.split(sep="x")[1]),
@ -84,9 +81,9 @@ def setup(bot: bot.Bot):
# bytes_arr = img_bytes,
# ).upload()
link = await bot.zxz.upload_from_bytes(img_bytes.getvalue(), "chart.png")
link = await bot.zxz.upload_from_bytes(img_bytes.getvalue(), f"{entity}_chart.png")
await ctx.send(u.good_msg(f"**{size}** {timeframe} chart for [{username}](https://last.fm/user/{username}) successfully generated:\n{link}"))
await ctx.send(u.good_msg(f"**{size}** {timeframe} {entity} chart for [{username}](https://last.fm/user/{username}) successfully generated:\n{link}"))
except Exception as e:
print(e)
@ -94,3 +91,40 @@ def setup(bot: bot.Bot):
finally:
if temp_msg: temp_msg.delete()
def setup(bot: bot.Bot):
@bot.command(name="chart", aliases=["c", "chartalbum", "albumchart", "collage"])
@bot.slash_command(name="chartalbum", description="Generate an album collage.")
async def chartalbum(ctx: nerimity.Context, size: str = "3x3", timeframe: str = "7day", username: str = None):
await send_collage(
bot = bot,
ctx = ctx,
entity = "album",
size = size,
timeframe = timeframe,
username = username
)
@bot.command(name="artistchart", aliases=["ac", "ca", "chartartist", "artistcollage"])
@bot.slash_command(name="chartartist", description="Generate an artist collage.")
async def chartartist(ctx: nerimity.Context, size: str = "3x3", timeframe: str = "7day", username: str = None):
await send_collage(
bot = bot,
ctx = ctx,
entity = "artist",
size = size,
timeframe = timeframe,
username = username
)
@bot.command(name="trackchart", aliases=["tc", "ct", "charttrack", "chartracks", "songchart", "chartsong", "trackcollage", "songcollage"])
@bot.slash_command(name="charttrack", description="Generate a track/song collage.")
async def charttrack(ctx: nerimity.Context, size: str = "3x3", timeframe: str = "7day", username: str = None):
await send_collage(
bot = bot,
ctx = ctx,
entity = "track",
size = size,
timeframe = timeframe,
username = username
)

View file

@ -86,8 +86,7 @@ def setup(bot: bot.Bot):
cover_art = albumobj.get_cover_image()
if not cover_art: await ctx.send(u.error_msg(f"**{albumobj.get_name()}** does not seem to have cover art."))
else: await ctx.send(f"Here's the cover art for **[{albumobj.get_name()}]({albumobj.get_url()})**:\
{cover_art}")
else: await ctx.send(f"Here's the cover art for **[{albumobj.get_name()}]({albumobj.get_url()})**:\n{cover_art}")
except Exception as e:
print(e)