Update example.js
This commit is contained in:
+13
-13
@@ -22,9 +22,9 @@ const matrixClient = sdk.createClient({
|
|||||||
accessToken: myAccessToken,
|
accessToken: myAccessToken,
|
||||||
userId: myUserId
|
userId: myUserId
|
||||||
});
|
});
|
||||||
const Searx = require('./index.js');
|
const Searxng = require('./index.js');
|
||||||
const searx = new Searx(matrixClient)
|
const searxng = new Searxng(matrixClient)
|
||||||
searx.setSearxInstance(searxng_server);
|
searxng.setSearxngInstance(searxng_server);
|
||||||
|
|
||||||
|
|
||||||
// --------- The following settings are all optional: ----------------------
|
// --------- The following settings are all optional: ----------------------
|
||||||
@@ -36,25 +36,25 @@ const uploadMatrixClient = sdk.createClient({
|
|||||||
accessToken: "syt_AnotherRealAccessTokenDoNotCommit",
|
accessToken: "syt_AnotherRealAccessTokenDoNotCommit",
|
||||||
userId: "@upload_leech:midov.pl"
|
userId: "@upload_leech:midov.pl"
|
||||||
});
|
});
|
||||||
searx.setUploadMatrixClient(uploadMatrixClient);
|
searxng.setUploadMatrixClient(uploadMatrixClient);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Set which rooms are not allowed to search for images.
|
// Set which rooms are not allowed to search for images.
|
||||||
//searx.setBlacklistedImgRooms(["!wehateimagesearching:matrix.org", "!wehateittoo:nerdsin.space"]);
|
//searxng.setBlacklistedImgRooms(["!wehateimagesearching:matrix.org", "!wehateittoo:nerdsin.space"]);
|
||||||
|
|
||||||
// Set which rooms are not allowed to search for images with safesearch disabled.
|
// Set which rooms are not allowed to search for images with safesearch disabled.
|
||||||
//searx.setBlacklistedUimgRooms(["!sfw:matrix.org", "!church:nerdsin.space"]);
|
//searxng.setBlacklistedUimgRooms(["!sfw:matrix.org", "!church:nerdsin.space"]);
|
||||||
|
|
||||||
// Set the amount of time in milliseconds users in a room are required to wait between searches (and allow some users to be immune to the cooldown and send as many as they want)
|
// Set the amount of time in milliseconds users in a room are required to wait between searches (and allow some users to be immune to the cooldown and send as many as they want)
|
||||||
/*
|
/*
|
||||||
searx.setCooldownImmuneUsers(["@q:glowers.club", "@romanticusgondolaticus:glowers.club"]);
|
searxng.setCooldownImmuneUsers(["@q:glowers.club", "@romanticusgondolaticus:glowers.club"]);
|
||||||
searx.setRoomCooldowns(new Map([
|
searxng.setRoomCooldowns(new Map([
|
||||||
["!sCbWouzHiLEyfOAaSJ:midov.pl",30000]
|
["!sCbWouzHiLEyfOAaSJ:midov.pl",30000]
|
||||||
]));
|
]));
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Lets you set which URL parameters are used in SearXNG queries. Useful for changing which search engines are included and excluded. See SearXNG's documentation for all of the parameters available.
|
// Lets you set which URL parameters are used in SearXNG queries. Useful for changing which search engines are included and excluded. See SearXNG's documentation for all of the parameters available.
|
||||||
//searx.setSearxParameters("disabled_engines=flickr__images");
|
//searxng.setSearxngParameters("disabled_engines=flickr__images");
|
||||||
|
|
||||||
// Lets you add a whitelist for a room. When added, only the users in that whitelist will be able to search. Other users will receive an error.
|
// Lets you add a whitelist for a room. When added, only the users in that whitelist will be able to search. Other users will receive an error.
|
||||||
/*
|
/*
|
||||||
@@ -74,8 +74,8 @@ matrixClient.on("Room.timeline", function(event, room, toStartOfTimeline) {
|
|||||||
if (event.getTs() >= startupTime && event.getType() == "m.room.message" && event.getContent().body != null) {
|
if (event.getTs() >= startupTime && event.getType() == "m.room.message" && event.getContent().body != null) {
|
||||||
|
|
||||||
if (event.getContent().body.indexOf("!help") == 0) {
|
if (event.getContent().body.indexOf("!help") == 0) {
|
||||||
const helpMessage = "Commands:\n"+searx.getHelp();
|
const helpMessage = "Commands:\n"+searxng.getHelp();
|
||||||
const formattedHelpMessage = "Commands:<br />"+searx.getFormattedHelp();
|
const formattedHelpMessage = "Commands:<br />"+searxng.getFormattedHelp();
|
||||||
|
|
||||||
const content = {
|
const content = {
|
||||||
"format": "org.matrix.custom.html",
|
"format": "org.matrix.custom.html",
|
||||||
@@ -91,9 +91,9 @@ matrixClient.on("Room.timeline", function(event, room, toStartOfTimeline) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
searx.handleMessage(event, room);
|
searxng.handleMessage(event, room);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
searx.startUploadMatrixClient();
|
searxng.startUploadMatrixClient();
|
||||||
matrixClient.startClient();
|
matrixClient.startClient();
|
||||||
|
|||||||
Reference in New Issue
Block a user