summaryrefslogtreecommitdiff
path: root/modules/$common.js
diff options
context:
space:
mode:
authorTom Smeding <tom@tomsmeding.com>2025-07-17 15:17:37 +0200
committerTom Smeding <tom@tomsmeding.com>2025-07-17 15:17:37 +0200
commitc2292c50210df227417cf16c8e7eaeef33dd40dc (patch)
tree3d5a8cbf22efdf6ec3c988a98baf5efc9119261e /modules/$common.js
parent52ec17571d6b8792019f0e98d545eed9fb6881f9 (diff)
Allow sending message by statusbot using common
Diffstat (limited to 'modules/$common.js')
-rw-r--r--modules/$common.js17
1 files changed, 17 insertions, 0 deletions
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,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;');
},
+
"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,
};