Skip to content

Commit 3fb72a6

Browse files
AmbratolmAmbratolm
authored andcommitted
AI: Added embed content to channel chat history prompt data.
1 parent 78f4fd9 commit 3fb72a6

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

bot/cogs/chat_cogs/ai_cog.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,10 +568,34 @@ async def get_channel_history(
568568
async def get_channel_history_csv(self, channel: Messageable) -> tuple[str, str]:
569569
"""Fetch (messages, members) CSV of latest messages in given channel and unique members who sent those messages."""
570570
messages, members = await self.get_channel_history(channel)
571+
572+
def format_embed_to_str(embed: Embed) -> str:
573+
parts = []
574+
if embed.title:
575+
parts.append(f"Title: {embed.title}")
576+
if embed.description:
577+
parts.append(f"Description: {embed.description}")
578+
if embed.author and embed.author.name:
579+
parts.append(f"Author: {embed.author.name}")
580+
for field in embed.fields:
581+
parts.append(f"Field '{field.name}': {field.value}")
582+
if embed.footer and embed.footer.text:
583+
parts.append(f"Footer: {embed.footer.text}")
584+
if embed.image and embed.image.url:
585+
parts.append(f"Image URL: {embed.image.url}")
586+
if embed.thumbnail and embed.thumbnail.url:
587+
parts.append(f"Thumbnail URL: {embed.thumbnail.url}")
588+
if embed.url:
589+
parts.append(f"URL: {embed.url}")
590+
return f"{{ {'; '.join(parts)} }}"
591+
571592
messages_data = [
572593
{
573594
"author_id": str(msg.author.id),
574595
"message_content": msg.content.replace("\n", " "),
596+
"message_embed": (
597+
format_embed_to_str(msg.embeds[0]) if msg.embeds else ""
598+
),
575599
}
576600
for msg in messages
577601
]

0 commit comments

Comments
 (0)