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

@ -39,7 +39,8 @@ read().then(() => {
e.reply(`no permission, min level ${trigger.level} required`);
break;
}
e = Object.assign(e, parseArgs(e.message));
trigger.f(e);
}
logger.info(`${e.network} -> ${e.channel} -> ${e.user.nick}: ${e.message}`);
@ -56,4 +57,13 @@ function trigger(args) {
this.active = args.hasOwnProperty("active") ? args.active : true;
this.clients = args.clients || ["irc", "tg"];
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) {
return ""+msg
return msg.toString()
.replace("<", "&lt;")
.replace(">", "&gt;")
.replace(/\[b\](.*?)\[\/b\]/g, "<b>$1</b>") // bold