Clarifying which settings are required and optional in example.js
This commit is contained in:
38
example.js
38
example.js
@@ -5,41 +5,65 @@ matrixcs.request(request);
|
|||||||
|
|
||||||
const startupTime = Date.now();
|
const startupTime = Date.now();
|
||||||
|
|
||||||
|
// --------- The following settings are all required: ----------------------
|
||||||
|
|
||||||
|
// Provide a matrix ID, access token, and homeserver that the bot will use.
|
||||||
const myUserId = "@glowy:glowers.club"
|
const myUserId = "@glowy:glowers.club"
|
||||||
const myAccessToken = "syt_TotallyMyRealAccessTokenAndNotAFake";
|
const myAccessToken = "syt_TotallyMyRealAccessTokenAndNotAFake";
|
||||||
|
const homeserver = "https://glowers.club";
|
||||||
|
|
||||||
|
// Provide the link to SearXNG. Include any directories used in a search query.
|
||||||
|
const searxng_server = "https://searxng.example.com/searxng"
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------
|
||||||
|
|
||||||
const matrixClient = sdk.createClient({
|
const matrixClient = sdk.createClient({
|
||||||
baseUrl: "https://glowers.club",
|
baseUrl: homeserver,
|
||||||
accessToken: myAccessToken,
|
accessToken: myAccessToken,
|
||||||
userId: myUserId
|
userId: myUserId
|
||||||
});
|
});
|
||||||
|
const Searx = require('./index.js');
|
||||||
|
const searx = new Searx(matrixClient)
|
||||||
|
searx.setSearxInstance(searxng_server);
|
||||||
|
|
||||||
|
|
||||||
|
// --------- The following settings are all optional: ----------------------
|
||||||
|
|
||||||
|
// This allows you to use a different Matrix user and homeserver for uploading the image results. If this is not provided then the bot's Matrix ID and homeserver will be used instead.
|
||||||
const uploadMatrixClient = sdk.createClient({
|
const uploadMatrixClient = sdk.createClient({
|
||||||
baseUrl: "https://midov.pl",
|
baseUrl: "https://midov.pl",
|
||||||
accessToken: "syt_AnotherRealAccessTokenDoNotCommit",
|
accessToken: "syt_AnotherRealAccessTokenDoNotCommit",
|
||||||
userId: "@upload_leech:midov.pl"
|
userId: "@upload_leech:midov.pl"
|
||||||
});
|
});
|
||||||
|
|
||||||
const Searx = require('./index.js');
|
|
||||||
const searx = new Searx(matrixClient)
|
|
||||||
searx.setUploadMatrixClient(uploadMatrixClient);
|
searx.setUploadMatrixClient(uploadMatrixClient);
|
||||||
|
|
||||||
|
// Set which rooms are not allowed to search for images.
|
||||||
searx.setBlacklistedImgRooms(["!wehateimagesearching:matrix.org", "!wehateittoo:nerdsin.space"]);
|
searx.setBlacklistedImgRooms(["!wehateimagesearching:matrix.org", "!wehateittoo:nerdsin.space"]);
|
||||||
|
|
||||||
|
// Set which rooms are not allowed to search for images with safesearch disabled.
|
||||||
searx.setBlacklistedUimgRooms(["!sfw:matrix.org", "!church:nerdsin.space"]);
|
searx.setBlacklistedUimgRooms(["!sfw:matrix.org", "!church:nerdsin.space"]);
|
||||||
searx.setCooldownImmuneUsers(["@q:glowers.club","@midov:midov.pl"]);
|
|
||||||
|
// 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"]);
|
||||||
searx.setRoomCooldowns(new Map([
|
searx.setRoomCooldowns(new Map([
|
||||||
["!sCbWouzHiLEyfOAaSJ:midov.pl",30000]
|
["!sCbWouzHiLEyfOAaSJ:midov.pl",30000]
|
||||||
]));
|
]));
|
||||||
searx.setSearxInstance("https://searx.example.com");
|
|
||||||
|
// 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");
|
searx.setSearxParameters("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.
|
||||||
searxng.setRoomUserWhitelists(new Map([
|
searxng.setRoomUserWhitelists(new Map([
|
||||||
["!blahblahblah:midov.pl",
|
["!blahblahblah:midov.pl",
|
||||||
[
|
[
|
||||||
"@q:glowers.club",
|
"@q:glowers.club",
|
||||||
"@midek:midov.pl"
|
"@romanticusgondolaticus:glowers.club"
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
]));
|
]));
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------
|
||||||
|
|
||||||
matrixClient.on("Room.timeline", function(event, room, toStartOfTimeline) {
|
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) {
|
||||||
|
|
||||||
|
|||||||
2
index.js
2
index.js
@@ -274,10 +274,12 @@ Searxng.prototype.handleMessage = function(event, room) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Searxng.prototype.startUploadMatrixClient = function() {
|
Searxng.prototype.startUploadMatrixClient = function() {
|
||||||
|
if (this.uploadMatrixClient != undefined && this.uploadMatrixClient != this.matrixClient) {
|
||||||
(async () => {
|
(async () => {
|
||||||
this.uploadMatrixClient.startClient({initialSyncLimit: 1});
|
this.uploadMatrixClient.startClient({initialSyncLimit: 1});
|
||||||
})();
|
})();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Searxng.prototype.getFormattedHelp = function() {
|
Searxng.prototype.getFormattedHelp = function() {
|
||||||
return "\
|
return "\
|
||||||
|
|||||||
Reference in New Issue
Block a user