From c2292c50210df227417cf16c8e7eaeef33dd40dc Mon Sep 17 00:00:00 2001 From: Tom Smeding Date: Thu, 17 Jul 2025 15:17:37 +0200 Subject: Allow sending message by statusbot using common --- modules/$common.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'modules/$common.js') diff --git a/modules/$common.js b/modules/$common.js index 59b9a66..f7ec42a 100644 --- a/modules/$common.js +++ b/modules/$common.js @@ -4,13 +4,28 @@ var path=require("path"), var cwd=process.cwd(); var globalAccounts=require(cwd+"/globalAccounts.json"); +var statusbotObject={ + // calls cb with http status code + "send":function statusbotSend(sender,text,cb){ + if(statusbotObject._handler==null){ + console.log("[common.statusbot] No statusbot yet"); + cb(500); + return; + } + statusbotObject._handler(sender,text,cb); + }, + "_handler":null, // to be set from the statusbot module +}; + module.exports={ "serverdir":cwd, "webfilesdir":cwd+"/web_files", "persistdir":cwd+"/persist", + "simpleHTMLescape":function simpleHTMLescape(str){ return str.replace(/&/g,'&').replace(//g,'>'); }, + "authgen":function authgen(accounts){ //omit `accounts` to use the globalAccounts list if(!accounts)accounts=globalAccounts; return function (req,res,next){ @@ -32,4 +47,6 @@ module.exports={ return unauth(res); }; }, + + "statusbot":statusbotObject, }; -- cgit v1.2.3-70-g09d2