fix: Update sticker ID handling to prevent duplicates and improve logging
This commit is contained in:
parent
682cceaa43
commit
f45cdbc0c6
12
gurt/api.py
12
gurt/api.py
@ -1549,11 +1549,11 @@ async def get_ai_response(cog: 'GurtCog', message: discord.Message, model_name:
|
||||
# Remove the sticker text from the content (only the first instance)
|
||||
if full_item_name_with_colons in modified_content:
|
||||
modified_content = modified_content.replace(full_item_name_with_colons, "", 1).strip()
|
||||
if sticker_id not in sticker_ids_to_send: # Avoid duplicate sticker IDs
|
||||
sticker_ids_to_send.append(sticker_id)
|
||||
print(f"Found custom sticker '{full_item_name_with_colons}', removed from content, added ID '{sticker_id}' to send list.")
|
||||
elif not sticker_id:
|
||||
print(f"Found custom sticker '{full_item_name_with_colons}' (dict) but no ID stored.")
|
||||
if sticker_id_to_add not in sticker_ids_to_send: # Avoid duplicate sticker IDs
|
||||
sticker_ids_to_send.append(sticker_id_to_add)
|
||||
print(f"Found custom sticker '{full_item_name_with_colons}', removed from content, added ID '{sticker_id_to_add}' to send list.")
|
||||
elif not sticker_id_to_add: # Check sticker_id_to_add here
|
||||
print(f"[GET_AI_RESPONSE] Found custom sticker '{full_item_name_with_colons}' (dict) but no ID stored (sticker_id_to_add is falsy).")
|
||||
elif sticker_data is not None:
|
||||
print(f"Warning: sticker_data for '{full_item_name_with_colons}' is not a dict: {type(sticker_data)}")
|
||||
|
||||
@ -1832,6 +1832,8 @@ async def get_proactive_ai_response(cog: 'GurtCog', message: discord.Message, tr
|
||||
if sticker_id_to_add not in sticker_ids_to_send_proactive:
|
||||
sticker_ids_to_send_proactive.append(sticker_id_to_add)
|
||||
print(f"Proactive: Found custom sticker '{full_item_name_with_colons}', removed from content, added ID '{sticker_id_to_add}'")
|
||||
elif not sticker_id_to_add: # Check sticker_id_to_add here
|
||||
print(f"[PROACTIVE] Found custom sticker '{full_item_name_with_colons}' (dict) but no ID stored (sticker_id_to_add is falsy).")
|
||||
|
||||
# Clean up any double spaces or leading/trailing whitespace after replacements
|
||||
modified_content = re.sub(r'\s{2,}', ' ', modified_content).strip()
|
||||
|
Loading…
x
Reference in New Issue
Block a user