webp support, making commands case insensitive, skip to next result if invalid file type provided
This commit is contained in:
14
index.js
14
index.js
@@ -65,6 +65,12 @@ function sendImage(results, resultIndex, roomId, name, searchCommand, retryCount
|
||||
case "image/gif":
|
||||
name = name + ".gif";
|
||||
break;
|
||||
case "image/webp":
|
||||
name = name + ".webp";
|
||||
break;
|
||||
case "text/html":
|
||||
throw new Error("HTML file provided instead of image");
|
||||
break;
|
||||
case "application/octet-stream":
|
||||
const urlImageType = imageURL.substring(imageURL.lastIndexOf("."));
|
||||
|
||||
@@ -82,6 +88,10 @@ function sendImage(results, resultIndex, roomId, name, searchCommand, retryCount
|
||||
imageType = "image/gif";
|
||||
name = name + ".gif";
|
||||
break;
|
||||
case ".webp":
|
||||
imageType = "image/webp";
|
||||
name = name + ".webp";
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -92,7 +102,7 @@ function sendImage(results, resultIndex, roomId, name, searchCommand, retryCount
|
||||
retryCount = retryCount + 1;
|
||||
resultIndex = resultIndex + 1;
|
||||
|
||||
if (retryCount > 3 || resultIndex > (results.length - 1)) {
|
||||
if (retryCount > 4 || resultIndex > (results.length - 1)) {
|
||||
matrixClient.sendNotice(roomId, "Error occurred during \"" + searchCommand + "\"");
|
||||
console.error("ERROR! [Search text: "+searchCommand+"], "+"[imageURL: "+imageURL+"], "+"[retryCount: "+retryCount+"]"+", [Engine: "+resultObj.engines[0]+"]");
|
||||
console.error(error);
|
||||
@@ -110,7 +120,7 @@ Searxng.prototype.handleMessage = function(event, room) {
|
||||
|
||||
const messagePieces = event.getContent().body.split(" ");
|
||||
|
||||
if (searxngCommands.indexOf(messagePieces[0]) > -1) {
|
||||
if (messagePieces[0] != undefined && searxngCommands.indexOf(messagePieces[0].toLowerCase()) > -1) {
|
||||
|
||||
var cooldown = false;
|
||||
|
||||
|
Reference in New Issue
Block a user