Enhance chat function to include server emoji usage instructions and improve message clarity

This commit is contained in:
Joakim Hellsén 2025-08-17 05:58:38 +02:00
commit 53fa0a02d1
2 changed files with 33 additions and 2 deletions

View file

@ -42,6 +42,7 @@
"thelovinator", "thelovinator",
"tobytes", "tobytes",
"twimg", "twimg",
"unsignedinteger" "unsignedinteger",
"Zenless"
] ]
} }

32
misc.py
View file

@ -6,7 +6,7 @@ from collections import deque
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
import psutil import psutil
from discord import Member, User, channel from discord import Emoji, Member, User, channel
if TYPE_CHECKING: if TYPE_CHECKING:
from collections.abc import Sequence from collections.abc import Sequence
@ -210,6 +210,33 @@ def chat( # noqa: PLR0913, PLR0917
context = extra_context(current_channel=current_channel, user=user) context = extra_context(current_channel=current_channel, user=user)
if current_channel.guild:
server_emojis: list[Emoji] = list(current_channel.guild.emojis)
if server_emojis:
context += "\nEmojis with `kao` are pictures of kao172, he is our friend so you can use them to express yourself!\n"
context += "\nYou can use the following server emojis:\n"
for emoji in server_emojis:
context += f" - {emoji!s}\n"
context += "\n You can create bigger emojis by combining them:\n"
context += "For example if you want to create a big rat emoji, you can combine the following emojis. The picture is three by three:\n"
context += " - <:rat1:1405292421742334116>: + <:rat2:1405292423373918258> + <:rat3:1405292425446031400>\n"
context += " - <:rat4:1405292427777933354>: + <:rat5:1405292430210891949>: + <:rat6:1405292433411145860>:\n"
context += " - <:rat7:1405292434883084409>: + <:rat8:1405292442181304320>: + <:rat9:1405292443619819631>:\n"
context += "This will create a picture of Jane Does ass."
context += " You can use it when we talk about coom, Zenless Zone Zero (ZZZ) or other related topics."
context += "\n"
context += "The following emojis needs to be on the same line to form a bigger emoji:\n"
context += "<a:phibiscarf2:1050306159023759420><a:phibiscarf_mid:1050306153084637194><a:phibiscarf1:1050306156997918802>\n"
context += "If you are using emoji combos, ONLY send the emoji itself and don't add unnecessary text.\n"
context += "Remember that combo emojis need to be on a separate line to form a bigger emoji.\n"
context += "But remember to not overuse them, remember that the user still can see the old message, so no need to write it again.\n"
context += "Also remember that you cant put code blocks around emojis.\n"
context += "Licka and Sniffa emojis are dogs that lick and sniff things. For example anime feet, butts and sweat.\n"
context += "If you want to use them, just send the emoji itself without any extra text.\n"
context += "The bot is in the following channels:\n" context += "The bot is in the following channels:\n"
if all_channels_in_guild: if all_channels_in_guild:
for c in all_channels_in_guild: for c in all_channels_in_guild:
@ -221,6 +248,7 @@ def chat( # noqa: PLR0913, PLR0917
prompt: str = ( prompt: str = (
"You are in a Discord group chat. People can ask you questions.\n" "You are in a Discord group chat. People can ask you questions.\n"
"Try to be brief, we don't want bloated messages. Be concise and to the point.\n"
"Use Discord Markdown to format messages if needed.\n" "Use Discord Markdown to format messages if needed.\n"
"Don't use emojis.\n" "Don't use emojis.\n"
"Extra context starts here:\n" "Extra context starts here:\n"
@ -231,6 +259,8 @@ def chat( # noqa: PLR0913, PLR0917
"Recent context ends here.\n" "Recent context ends here.\n"
) )
logger.info("Sending request to OpenAI API with prompt: %s", prompt)
resp: Response = openai_client.responses.create( resp: Response = openai_client.responses.create(
model="gpt-5-chat-latest", model="gpt-5-chat-latest",
instructions=prompt, instructions=prompt,