Fixed optional arguments bug, added self hmmscore calling, made debugging easier
This commit is contained in:
parent
c0df2150ae
commit
5a0cc587b3
37
bot.js
37
bot.js
|
@ -10,11 +10,13 @@ const BotList = require("./spells/botlist");
|
|||
// const Pardon = require("./spells/pardon");
|
||||
const Hmm = require("./spells/hmm");
|
||||
|
||||
const botName = "BabiliBot"
|
||||
const debug = false;
|
||||
|
||||
const botName = `BabiliBot${debug ? "Demo" : ""}`;
|
||||
const client = new irc.Client("localhost", botName, {
|
||||
channels: [
|
||||
"#bots",
|
||||
"#meta"
|
||||
// "#meta"
|
||||
],
|
||||
localAddress: "127.0.0.1",
|
||||
port: 6667,
|
||||
|
@ -27,6 +29,10 @@ const client = new irc.Client("localhost", botName, {
|
|||
debug: true
|
||||
});
|
||||
|
||||
if (!debug) {
|
||||
client.opt.channels.push("#meta");
|
||||
}
|
||||
|
||||
client.config = JSON.parse(fs.readFileSync("config.json", "utf8"));
|
||||
client.config.botName = botName;
|
||||
client.config.dirname = __dirname;
|
||||
|
@ -48,6 +54,14 @@ client.triggers = {
|
|||
vars: " <user> <reason:optional>",
|
||||
description: "Used to send a summoning email to <user>@tilde.team."
|
||||
},
|
||||
"!hmmscore": {
|
||||
vars: " <user:optional>",
|
||||
description: "Reports your's or another user's hmmscore."
|
||||
},
|
||||
"!hmmscoreboard": {
|
||||
vars: "",
|
||||
description: "Displays the leaderboard for hmmscores."
|
||||
},
|
||||
"!help BabiliBot": {
|
||||
vars: "",
|
||||
description: "PMs user this message."
|
||||
|
@ -146,16 +160,11 @@ const castSpell = (client, from, to, incantation) => {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (vars > 0) {
|
||||
// Note: Handle variables in spells
|
||||
const spellName = spell.spell;
|
||||
const splitIncantation = incantation.split(spellName);
|
||||
|
||||
// Skip if could not split
|
||||
if (!splitIncantation[1]) {
|
||||
return false;
|
||||
}
|
||||
// Note: Handle variables in spells
|
||||
const spellName = spell.spell;
|
||||
const splitIncantation = incantation.split(spellName);
|
||||
|
||||
if (splitIncantation[1]) {
|
||||
const variable = splitIncantation[1].trim().split(" ");
|
||||
spell.incantation = incantation.split(splitIncantation[1])[0];
|
||||
response = spell.test.apply(spell, variable.splice(0, vars));
|
||||
|
@ -326,7 +335,7 @@ const runLogic = (client, from, to, message) => {
|
|||
}
|
||||
} else if (
|
||||
message.startsWith("!summon ") ||
|
||||
message.startsWith("!hmmscore ") ||
|
||||
message.startsWith("!hmmscore") ||
|
||||
message.startsWith("!botlist")
|
||||
) {
|
||||
const cheatCode = message.slice(1).trim();
|
||||
|
@ -370,4 +379,6 @@ client.addListener("registered", () => {
|
|||
client.connect();
|
||||
|
||||
client.join("#bots");
|
||||
client.join("#meta");
|
||||
if (!debug) {
|
||||
client.join("#meta");
|
||||
}
|
|
@ -28,6 +28,10 @@ module.exports = class Hmm {
|
|||
debug: {},
|
||||
content: ""
|
||||
};
|
||||
|
||||
if (!user) {
|
||||
user = this.summoner;
|
||||
}
|
||||
|
||||
const memories = this.client.brain.memories;
|
||||
memories.hmmscores = memories.hmmscores || {};
|
||||
|
|
Loading…
Reference in New Issue