AMLT finally knows her name! You can now let your chatbot character to know their name by setting it in the pack.mltmeta file.
I also put together a way for users to use these information in AMLT’s reply strings. It’s called MLTCode. MLTCode is parsed entirely on the JavaScript side.
function parseStringToJson(input) {
let result = {};
let [opcode, params] = input.split(',');
result['opcode'] = opcode;
if (params) {
let paramPairs = params.split(',');
paramPairs.forEach(pair => {
let [key, value] = pair.split('=');
result[key] = value;
});
}
return result;
}
function replaceMLTCodes(input) {
// MLTCode, a CQCode-like control code [MLT:command,param0=val0,param1=val1,...,paramN=valN]
const regex = /\[MLT:([^\]]+)\]/g;
return input.replace(regex, (match, code) => processMLTCode(code));
}
function processAMCode(str) {
str = replaceMLTCodes(str);
return str;
}
Code language: JavaScript (javascript)
MLTCode looks like this:
[MLT:command,param0=val0,param1=val1,...,paramN=valN]
For example: if you want to insert your character’s nick name in a reply string, the reply could looks like this:
Welcome back my friend! If you need anything you can call [MLT:nick]!
If you want to also play a sound while a message shows, you can do this:
Heads up, your timer is up! [MLT:sound,src=assets/sound/alarm1.mp3]
What’s even cooler is that now you can run YeziiBot.js commands directly inside your reply!
If you need usage documentation please send %help. I am gonna run this command for you. [MLT:command,cmd=help]
Leave a Reply