add sender to report message

This commit is contained in:
Nils Büchner 2024-09-27 15:16:39 +02:00
parent 45a085075c
commit 49a0b9dd89

View file

@ -116,7 +116,7 @@ class NSFWModelPlugin(Plugin):
return
results = await self.process_images([evt.content.url])
matrix_to_url = self.create_matrix_to_url(evt.room_id, evt.event_id)
response = self.format_response(results, matrix_to_url)
response = self.format_response(results, matrix_to_url, evt.sender)
await self.send_responses(evt, response, results)
except Exception as e:
self.log.error(f"Error handling image message: {e}")
@ -156,7 +156,7 @@ class NSFWModelPlugin(Plugin):
for _, temp_filename in temp_files:
os.remove(temp_filename)
def format_response(self, results: dict, matrix_to_url: str) -> str:
def format_response(self, results: dict, matrix_to_url: str, sender: str) -> str:
"""
Format the response message based on the results.
@ -172,6 +172,7 @@ class NSFWModelPlugin(Plugin):
f"{mxc_url} contains {detection['class']} "
f"with a score of {detection['score']:.2f} "
f"in {matrix_to_url} "
f"by {sender}"
)
response_parts.append(detection_info)
break