Add searxng engines to matrix event

This commit is contained in:
q
2025-10-15 15:00:21 -04:00
parent 0c164c708c
commit e28bd5a09b

View File

@@ -51,7 +51,7 @@ function sendImage(results, resultIndex, roomId, name, searchCommand, retryCount
try { try {
const imageResponse = await axios.get(imageURL, { responseType: 'arraybuffer' }); const imageResponse = await axios.get(imageURL, { responseType: 'arraybuffer' });
var imageType = imageResponse.headers['content-type']; var imageType = imageResponse.headers['content-type'];
console.debug("[Search text: "+searchCommand+"], "+"[imageURL: "+imageURL+"], "+"[retryCount: "+retryCount+"]"+", [Engine: "+resultObj.engines[0]+"]"+", [content-type: "+imageType+"]"); console.debug("[Search text: "+searchCommand+"], "+"[imageURL: "+imageURL+"], "+"[retryCount: "+retryCount+"]"+", [Engines: "+resultObj.engines.join(",")+"]"+", [content-type: "+imageType+"]");
const uploadResponse = await uploadMatrixClient.uploadContent(imageResponse.data, { rawResponse: false, type: imageType }); const uploadResponse = await uploadMatrixClient.uploadContent(imageResponse.data, { rawResponse: false, type: imageType });
const matrixUrl = uploadResponse.content_uri; const matrixUrl = uploadResponse.content_uri;
var filename; var filename;
@@ -98,7 +98,6 @@ function sendImage(results, resultIndex, roomId, name, searchCommand, retryCount
break; break;
} }
//matrixClient.sendImageMessage(roomId, matrixUrl, {"mimetype": imageType}, name, null);
const content = { const content = {
msgtype: "m.image", msgtype: "m.image",
@@ -107,6 +106,7 @@ function sendImage(results, resultIndex, roomId, name, searchCommand, retryCount
url: matrixUrl, url: matrixUrl,
requested_by: requester, requested_by: requester,
image_source: imageURL, image_source: imageURL,
searxng_engines: resultObj.engines.join(","),
info: { info: {
mimetype: imageType mimetype: imageType
}, },
@@ -126,7 +126,7 @@ function sendImage(results, resultIndex, roomId, name, searchCommand, retryCount
if (retryCount > 4 || resultIndex > (results.length - 1)) { if (retryCount > 4 || resultIndex > (results.length - 1)) {
matrixClient.sendNotice(roomId, "Error occurred during \"" + searchCommand + "\""); matrixClient.sendNotice(roomId, "Error occurred during \"" + searchCommand + "\"");
console.error("ERROR! [Search text: "+searchCommand+"], "+"[imageURL: "+imageURL+"], "+"[retryCount: "+retryCount+"]"+", [Engine: "+resultObj.engines[0]+"]"); console.error("ERROR! [Search text: "+searchCommand+"], "+"[imageURL: "+imageURL+"], "+"[retryCount: "+retryCount+"]"+", [Engines: "+resultObj.engines.join(",")+"]");
console.error(error); console.error(error);
} }
else { else {