global args

This commit is contained in:
Flummi 2017-11-27 01:29:09 +01:00
parent 3dae5a2437
commit 868bbea424
2 changed files with 13 additions and 3 deletions

View File

@ -40,6 +40,7 @@ read().then(() => {
break; break;
} }
e = Object.assign(e, parseArgs(e.message));
trigger.f(e); trigger.f(e);
} }
logger.info(`${e.network} -> ${e.channel} -> ${e.user.nick}: ${e.message}`); logger.info(`${e.network} -> ${e.channel} -> ${e.user.nick}: ${e.message}`);
@ -57,3 +58,12 @@ function trigger(args) {
this.clients = args.clients || ["irc", "tg"]; this.clients = args.clients || ["irc", "tg"];
this.f = args.f; this.f = args.f;
} }
const parseArgs = (msg) => {
let args = msg.trim().split(" ");
let cmd = args.shift();
return {
cmd: cmd.replace(/^(\.|\/|\!)/, ""),
args: args
};
};

View File

@ -68,7 +68,7 @@ export class tg {
}; };
} }
format(msg) { format(msg) {
return ""+msg return msg.toString()
.replace("<", "&lt;") .replace("<", "&lt;")
.replace(">", "&gt;") .replace(">", "&gt;")
.replace(/\[b\](.*?)\[\/b\]/g, "<b>$1</b>") // bold .replace(/\[b\](.*?)\[\/b\]/g, "<b>$1</b>") // bold