
Remember stuff, in JavaScript
Readme
This package is meant to show how to use Abbot’s brain from JavaScript. Abbot already has a rem
function that works better than this one, but this could serve as the basis of another skill that requires persistence.
Usage
@abbot jsrem x is y
@abbot jsrem x
@abbot jsrem del x
Code
async function write(key, value) {
return await bot.brain.write(key, value);
}
async function read(key) {
return await bot.brain.read(key);
}
async function del(key) {
return await bot.brain.delete(key);
}
let response = null;
if (args.startsWith(‘del ‘)) {
await del(args.substring(4));
response = “Okay, deleted ” + args.substring(4);
} else if (args.includes(‘ is ‘)) {
const parts = args.split(‘ is ‘)
let k = parts[0];
let v = parts.slice(1,).join(‘ is ‘);
const out = await bot.brain.write(k, v);
response = `Okay, \`${k}\` is \`${v}\“;
} else {
try {
const out = await bot.brain.read(args);
response = out;
} catch (ex) {
response = “I don’t know anything about `” + args + “`”;
}
}
bot.reply(response);
})();
Version History
Version | Installs | Created | Author | Release Notes |
---|---|---|---|---|
1.0.1 | 0 | 2/8/2021 |
![]() paulnakata |
Formatting fixes. |
1.0.0 | 0 | 12/8/2020 |
![]() paulnakata |
First version! |
Info
You need an account to install this package with Abbot. Signing in with Slack or Discord will create an account if you don’t have one already.