Initial version working
This commit is contained in:
parent
09e47b9ca7
commit
2b41925813
|
@ -1,3 +1,8 @@
|
|||
# ---> For project
|
||||
config.json
|
||||
blacklist.json
|
||||
blacklist.log
|
||||
|
||||
# ---> Node
|
||||
# Logs
|
||||
logs
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
[]
|
|
@ -0,0 +1,187 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
const fs = require("fs");
|
||||
const irc = require("irc");
|
||||
const Summon = require("./spells/summon");
|
||||
|
||||
const botName = "BabiliBot"
|
||||
const client = new irc.Client("localhost", botName, {
|
||||
channels: [
|
||||
"#bots"
|
||||
],
|
||||
localAddress: "0.0.0.0",
|
||||
port: 6667,
|
||||
userName: "aewens",
|
||||
floodProtection: true,
|
||||
floodProtectionDelay: 1000,
|
||||
autoConnect: false,
|
||||
stripColors: true,
|
||||
encoding: "utf-8",
|
||||
debug: true
|
||||
});
|
||||
|
||||
client.config = JSON.parse(fs.readFileSync("config.json", "utf8"));
|
||||
|
||||
client.spells = [
|
||||
Summon
|
||||
];
|
||||
|
||||
// NOTE - Once the #chaos throne is returned to it's king, this will remain
|
||||
client.blacklist = JSON.parse(fs.readFileSync("blacklist.json", "utf8"));
|
||||
|
||||
// Format:
|
||||
// {
|
||||
// timestamp: Date.now(),
|
||||
// spell: spell.name
|
||||
// }
|
||||
client.memory = [];
|
||||
|
||||
const contains = (text, test) => {
|
||||
return text.indexOf(test) > -1;
|
||||
}
|
||||
|
||||
const logBlacklisters = (from, message) => {
|
||||
const blacklistLog = `${from} tried to issue ${message}`;
|
||||
fs.appendFile("blacklist.log", blacklistLog, (err) => {
|
||||
if (err) throw err;
|
||||
console.log("Blacklist", blacklistLog);
|
||||
});
|
||||
}
|
||||
|
||||
const addBlacklister = (from, message) => {
|
||||
// Log reason for adding to the blacklist
|
||||
const blacklistReason = `${from} was added for spamming ${message}`;
|
||||
fs.appendFile("blacklisters.log", blacklistReason, (err) => {
|
||||
if (err) throw err;
|
||||
console.log("Blacklist", blacklistReason);
|
||||
});
|
||||
|
||||
// Apply to current session
|
||||
client.blacklist.push(from);
|
||||
|
||||
// Apply to future sessions
|
||||
const blacklist = JSON.stringify(client.blacklist);
|
||||
fs.writeFile("blacklist.json", blacklist, (err) => {
|
||||
if (err) throw err;
|
||||
console.log("Added to blacklist:", from);
|
||||
});
|
||||
}
|
||||
|
||||
const castSpell = (client, from, to, incantation) => {
|
||||
let casted = false;
|
||||
client.spells.forEach((_spell) => {
|
||||
const spell = new _spell(client, from, incantation);
|
||||
const response = spell.test();
|
||||
|
||||
if (spell.casted) {
|
||||
casted = true;
|
||||
client.memory.push({
|
||||
timestamp: Date.now(),
|
||||
spell: spell.name
|
||||
});
|
||||
|
||||
if (response.say) {
|
||||
client.say(to, response.content);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (!casted) {
|
||||
client.say(to, `${from}, malsagxulo! That spell does not exist.`);
|
||||
}
|
||||
}
|
||||
|
||||
// For those who cannot handle Esperanto, plebeyoj!
|
||||
const useCheatCode = (client, from, to, cheatCode) => {
|
||||
let cheatCodes = {};
|
||||
|
||||
// Generate cheat code
|
||||
client.spells.forEach((_spell) => {
|
||||
const spell = new _spell(client, from, "");
|
||||
cheatCodes[spell.cheatCode] = spell.spell;
|
||||
});
|
||||
|
||||
if (contains(Object.keys(cheatCodes), cheatCode)) {
|
||||
castSpell(client, from, to, cheatCodes[cheatCode]);
|
||||
}
|
||||
}
|
||||
|
||||
const checkBlacklist = (client, from, to, message) => {
|
||||
const now = Date.now();
|
||||
const lastUsed = client.memory.slice(-1).pop();
|
||||
const lastTimestamp = lastUsed ? lastUsed.timestamp : 0;
|
||||
|
||||
if (contains(client.blacklist, from)) {
|
||||
// Log the blacklisters for later scrutiny
|
||||
logBlacklisters(from, message);
|
||||
|
||||
client.action(to, `is ignoring ${from}. Malsaĝa!`);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Add to blacklist if abusing bot
|
||||
if (now < lastTimestamp + client.config.timeout) {
|
||||
// Add exception for author of bot
|
||||
if (from !== client.config.author) {
|
||||
addBlacklister(from, message);
|
||||
|
||||
const banishment = `Malpermesante ${from}`;
|
||||
client.say(to, `${banishment}! I no longer head your words.`);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
client.addListener("message", (from, to, _message) => {
|
||||
console.log(`${from} => ${to}: ${_message}`);
|
||||
|
||||
const message = _message.toLowerCase();
|
||||
const triggerWord = client.config.triggerWord;
|
||||
const address = botName.toLowerCase();
|
||||
|
||||
if (message.startsWith(triggerWord)) {
|
||||
const incantation = message.split(triggerWord)[1].trim();
|
||||
const check = checkBlacklist(client, from, to, incantation);
|
||||
|
||||
if (check) {
|
||||
castSpell(client, from, to, incantation);
|
||||
}
|
||||
} else if (message.startsWith(address)) {
|
||||
let cheatCode = message.split(address)[1];
|
||||
|
||||
// Why punish formality?
|
||||
if (cheatCode.startsWith(": ")) {
|
||||
cheatCode = cheatCode.split(": ")[1];
|
||||
} else if (cheatCode.startsWith(", ")) {
|
||||
cheatCode = cheatCode.split(", ")[1];
|
||||
}
|
||||
|
||||
cheatCode = cheatCode.trim();
|
||||
const check = checkBlacklist(client, from, to, cheatCode);
|
||||
|
||||
if (check) {
|
||||
useCheatCode(client, from, to, cheatCode);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
client.addListener("pm", (from, message) => {
|
||||
console.log(`${from} => ME: ${message}`);
|
||||
});
|
||||
|
||||
client.addListener("error", (message) => {
|
||||
console.error(`error: ${message}`, message);
|
||||
});
|
||||
|
||||
client.addListener("registered", () => {
|
||||
// client.say("NickServ", `RECOVER ${botName} ${client.config.password}`);
|
||||
client.say("NickServ", `IDENTIFY ${client.config.password}`);
|
||||
});
|
||||
|
||||
client.connect();
|
||||
|
||||
client.join("#bots");
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"email": "",
|
||||
"device": "",
|
||||
"author": "",
|
||||
"skillDelay": 1000,
|
||||
"triggerWord": "",
|
||||
"password": "",
|
||||
"api": {
|
||||
"pushbullet": ""
|
||||
}
|
||||
}
|
|
@ -0,0 +1,466 @@
|
|||
{
|
||||
"name": "irc-bot",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
"ajv": {
|
||||
"version": "5.5.2",
|
||||
"resolved": "https://registry.npmjs.org/ajv/-/ajv-5.5.2.tgz",
|
||||
"integrity": "sha1-c7Xuyj+rZT49P5Qis0GtQiBdyWU=",
|
||||
"requires": {
|
||||
"co": "^4.6.0",
|
||||
"fast-deep-equal": "^1.0.0",
|
||||
"fast-json-stable-stringify": "^2.0.0",
|
||||
"json-schema-traverse": "^0.3.0"
|
||||
}
|
||||
},
|
||||
"asn1": {
|
||||
"version": "0.2.3",
|
||||
"resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.3.tgz",
|
||||
"integrity": "sha1-2sh4dxPJlmhJ/IGAd36+nB3fO4Y="
|
||||
},
|
||||
"assert-plus": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz",
|
||||
"integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU="
|
||||
},
|
||||
"asynckit": {
|
||||
"version": "0.4.0",
|
||||
"resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
|
||||
"integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k="
|
||||
},
|
||||
"aws-sign2": {
|
||||
"version": "0.7.0",
|
||||
"resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz",
|
||||
"integrity": "sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg="
|
||||
},
|
||||
"aws4": {
|
||||
"version": "1.7.0",
|
||||
"resolved": "https://registry.npmjs.org/aws4/-/aws4-1.7.0.tgz",
|
||||
"integrity": "sha512-32NDda82rhwD9/JBCCkB+MRYDp0oSvlo2IL6rQWA10PQi7tDUM3eqMSltXmY+Oyl/7N3P3qNtAlv7X0d9bI28w=="
|
||||
},
|
||||
"bcrypt-pbkdf": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz",
|
||||
"integrity": "sha1-pDAdOJtqQ/m2f/PKEaP2Y342Dp4=",
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"tweetnacl": "^0.14.3"
|
||||
}
|
||||
},
|
||||
"caseless": {
|
||||
"version": "0.12.0",
|
||||
"resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz",
|
||||
"integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw="
|
||||
},
|
||||
"clone": {
|
||||
"version": "2.1.1",
|
||||
"resolved": "https://registry.npmjs.org/clone/-/clone-2.1.1.tgz",
|
||||
"integrity": "sha1-0hfR6WERjjrJpLi7oyhVU79kfNs="
|
||||
},
|
||||
"co": {
|
||||
"version": "4.6.0",
|
||||
"resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz",
|
||||
"integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ="
|
||||
},
|
||||
"combined-stream": {
|
||||
"version": "1.0.6",
|
||||
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.6.tgz",
|
||||
"integrity": "sha1-cj599ugBrFYTETp+RFqbactjKBg=",
|
||||
"requires": {
|
||||
"delayed-stream": "~1.0.0"
|
||||
}
|
||||
},
|
||||
"core-util-is": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz",
|
||||
"integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac="
|
||||
},
|
||||
"dashdash": {
|
||||
"version": "1.14.1",
|
||||
"resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz",
|
||||
"integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=",
|
||||
"requires": {
|
||||
"assert-plus": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"debug": {
|
||||
"version": "2.6.9",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
|
||||
"integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
|
||||
"requires": {
|
||||
"ms": "2.0.0"
|
||||
}
|
||||
},
|
||||
"delayed-stream": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
|
||||
"integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk="
|
||||
},
|
||||
"ecc-jsbn": {
|
||||
"version": "0.1.1",
|
||||
"resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz",
|
||||
"integrity": "sha1-D8c6ntXw1Tw4GTOYUj735UN3dQU=",
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"jsbn": "~0.1.0"
|
||||
}
|
||||
},
|
||||
"extend": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/extend/-/extend-3.0.1.tgz",
|
||||
"integrity": "sha1-p1Xqe8Gt/MWjHOfnYtuq3F5jZEQ="
|
||||
},
|
||||
"extsprintf": {
|
||||
"version": "1.3.0",
|
||||
"resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz",
|
||||
"integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU="
|
||||
},
|
||||
"fast-deep-equal": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-1.1.0.tgz",
|
||||
"integrity": "sha1-wFNHeBfIa1HaqFPIHgWbcz0CNhQ="
|
||||
},
|
||||
"fast-json-stable-stringify": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz",
|
||||
"integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I="
|
||||
},
|
||||
"forever-agent": {
|
||||
"version": "0.6.1",
|
||||
"resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz",
|
||||
"integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE="
|
||||
},
|
||||
"form-data": {
|
||||
"version": "2.3.2",
|
||||
"resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.2.tgz",
|
||||
"integrity": "sha1-SXBJi+YEwgwAXU9cI67NIda0kJk=",
|
||||
"requires": {
|
||||
"asynckit": "^0.4.0",
|
||||
"combined-stream": "1.0.6",
|
||||
"mime-types": "^2.1.12"
|
||||
}
|
||||
},
|
||||
"getpass": {
|
||||
"version": "0.1.7",
|
||||
"resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz",
|
||||
"integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=",
|
||||
"requires": {
|
||||
"assert-plus": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"har-schema": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz",
|
||||
"integrity": "sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI="
|
||||
},
|
||||
"har-validator": {
|
||||
"version": "5.0.3",
|
||||
"resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.0.3.tgz",
|
||||
"integrity": "sha1-ukAsJmGU8VlW7xXg/PJCmT9qff0=",
|
||||
"requires": {
|
||||
"ajv": "^5.1.0",
|
||||
"har-schema": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"http-signature": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz",
|
||||
"integrity": "sha1-muzZJRFHcvPZW2WmCruPfBj7rOE=",
|
||||
"requires": {
|
||||
"assert-plus": "^1.0.0",
|
||||
"jsprim": "^1.2.2",
|
||||
"sshpk": "^1.7.0"
|
||||
}
|
||||
},
|
||||
"iconv": {
|
||||
"version": "2.2.3",
|
||||
"resolved": "https://registry.npmjs.org/iconv/-/iconv-2.2.3.tgz",
|
||||
"integrity": "sha1-4ITWDut9c9p/CpwJbkyKvgkL+u0=",
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"nan": "^2.3.5"
|
||||
}
|
||||
},
|
||||
"irc": {
|
||||
"version": "0.5.2",
|
||||
"resolved": "https://registry.npmjs.org/irc/-/irc-0.5.2.tgz",
|
||||
"integrity": "sha1-NxT0doNlqW0LL3dryRFmvrJGS7w=",
|
||||
"requires": {
|
||||
"iconv": "~2.2.1",
|
||||
"irc-colors": "^1.1.0",
|
||||
"node-icu-charset-detector": "~0.2.0"
|
||||
}
|
||||
},
|
||||
"irc-colors": {
|
||||
"version": "1.4.2",
|
||||
"resolved": "https://registry.npmjs.org/irc-colors/-/irc-colors-1.4.2.tgz",
|
||||
"integrity": "sha512-QZ1g4d9XTGKgBAp7lrltCetefqd3zfYs3SFQ4YyRSORORCmy/9EkU/r8LJrlSnaWc3Z+54EgHXBRlOHaCvpyHA=="
|
||||
},
|
||||
"is-typedarray": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz",
|
||||
"integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo="
|
||||
},
|
||||
"isstream": {
|
||||
"version": "0.1.2",
|
||||
"resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz",
|
||||
"integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo="
|
||||
},
|
||||
"jsbn": {
|
||||
"version": "0.1.1",
|
||||
"resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz",
|
||||
"integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=",
|
||||
"optional": true
|
||||
},
|
||||
"json-schema": {
|
||||
"version": "0.2.3",
|
||||
"resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz",
|
||||
"integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM="
|
||||
},
|
||||
"json-schema-traverse": {
|
||||
"version": "0.3.1",
|
||||
"resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.3.1.tgz",
|
||||
"integrity": "sha1-NJptRMU6Ud6JtAgFxdXlm0F9M0A="
|
||||
},
|
||||
"json-stringify-safe": {
|
||||
"version": "5.0.1",
|
||||
"resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz",
|
||||
"integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus="
|
||||
},
|
||||
"jsprim": {
|
||||
"version": "1.4.1",
|
||||
"resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz",
|
||||
"integrity": "sha1-MT5mvB5cwG5Di8G3SZwuXFastqI=",
|
||||
"requires": {
|
||||
"assert-plus": "1.0.0",
|
||||
"extsprintf": "1.3.0",
|
||||
"json-schema": "0.2.3",
|
||||
"verror": "1.10.0"
|
||||
}
|
||||
},
|
||||
"lodash": {
|
||||
"version": "4.17.10",
|
||||
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.10.tgz",
|
||||
"integrity": "sha512-UejweD1pDoXu+AD825lWwp4ZGtSwgnpZxb3JDViD7StjQz+Nb/6l093lx4OQ0foGWNRoc19mWy7BzL+UAK2iVg=="
|
||||
},
|
||||
"mime": {
|
||||
"version": "1.6.0",
|
||||
"resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz",
|
||||
"integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg=="
|
||||
},
|
||||
"mime-db": {
|
||||
"version": "1.33.0",
|
||||
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.33.0.tgz",
|
||||
"integrity": "sha512-BHJ/EKruNIqJf/QahvxwQZXKygOQ256myeN/Ew+THcAa5q+PjyTTMMeNQC4DZw5AwfvelsUrA6B67NKMqXDbzQ=="
|
||||
},
|
||||
"mime-types": {
|
||||
"version": "2.1.18",
|
||||
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.18.tgz",
|
||||
"integrity": "sha512-lc/aahn+t4/SWV/qcmumYjymLsWfN3ELhpmVuUFjgsORruuZPVSwAQryq+HHGvO/SI2KVX26bx+En+zhM8g8hQ==",
|
||||
"requires": {
|
||||
"mime-db": "~1.33.0"
|
||||
}
|
||||
},
|
||||
"ms": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
|
||||
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
|
||||
},
|
||||
"nan": {
|
||||
"version": "2.10.0",
|
||||
"resolved": "https://registry.npmjs.org/nan/-/nan-2.10.0.tgz",
|
||||
"integrity": "sha512-bAdJv7fBLhWC+/Bls0Oza+mvTaNQtP+1RyhhhvD95pgUJz6XM5IzgmxOkItJ9tkoCiplvAnXI1tNmmUD/eScyA=="
|
||||
},
|
||||
"node-forge": {
|
||||
"version": "0.7.5",
|
||||
"resolved": "https://registry.npmjs.org/node-forge/-/node-forge-0.7.5.tgz",
|
||||
"integrity": "sha512-MmbQJ2MTESTjt3Gi/3yG1wGpIMhUfcIypUCGtTizFR9IiccFwxSpfp0vtIZlkFclEqERemxfnSdZEMR9VqqEFQ=="
|
||||
},
|
||||
"node-icu-charset-detector": {
|
||||
"version": "0.2.0",
|
||||
"resolved": "https://registry.npmjs.org/node-icu-charset-detector/-/node-icu-charset-detector-0.2.0.tgz",
|
||||
"integrity": "sha1-wjINo3Tdy2cfxUy0oOBB4Vb/1jk=",
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"nan": "^2.3.3"
|
||||
}
|
||||
},
|
||||
"nodemailer": {
|
||||
"version": "4.6.7",
|
||||
"resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-4.6.7.tgz",
|
||||
"integrity": "sha512-GIAAYvs9XIP1fBa8wR89ukUh3yjL44pom5LKY5nTZcL+Zp9sRkqL8wgskyBQECQg9CPsDX/fjTZx8MNz20t0jA=="
|
||||
},
|
||||
"oauth-sign": {
|
||||
"version": "0.8.2",
|
||||
"resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.8.2.tgz",
|
||||
"integrity": "sha1-Rqarfwrq2N6unsBWV4C31O/rnUM="
|
||||
},
|
||||
"performance-now": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz",
|
||||
"integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns="
|
||||
},
|
||||
"punycode": {
|
||||
"version": "1.4.1",
|
||||
"resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz",
|
||||
"integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4="
|
||||
},
|
||||
"pushbullet": {
|
||||
"version": "2.2.0",
|
||||
"resolved": "https://registry.npmjs.org/pushbullet/-/pushbullet-2.2.0.tgz",
|
||||
"integrity": "sha512-ZzFHj9w8Wv5+472QM5F8wASBQBwsrG6vmxxW7f2mMMygYoAdPDhgq1755kfc9n0SPFNZ/2cHMfhja8t+jUOSGQ==",
|
||||
"requires": {
|
||||
"clone": "^2.1.0",
|
||||
"mime": "^1.3.4",
|
||||
"node-forge": "^0.7.1",
|
||||
"request": "^2.79.0",
|
||||
"request-promise-native": "^1.0.5",
|
||||
"websocket": "^1.0.24"
|
||||
}
|
||||
},
|
||||
"qs": {
|
||||
"version": "6.5.2",
|
||||
"resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz",
|
||||
"integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA=="
|
||||
},
|
||||
"request": {
|
||||
"version": "2.87.0",
|
||||
"resolved": "https://registry.npmjs.org/request/-/request-2.87.0.tgz",
|
||||
"integrity": "sha512-fcogkm7Az5bsS6Sl0sibkbhcKsnyon/jV1kF3ajGmF0c8HrttdKTPRT9hieOaQHA5HEq6r8OyWOo/o781C1tNw==",
|
||||
"requires": {
|
||||
"aws-sign2": "~0.7.0",
|
||||
"aws4": "^1.6.0",
|
||||
"caseless": "~0.12.0",
|
||||
"combined-stream": "~1.0.5",
|
||||
"extend": "~3.0.1",
|
||||
"forever-agent": "~0.6.1",
|
||||
"form-data": "~2.3.1",
|
||||
"har-validator": "~5.0.3",
|
||||
"http-signature": "~1.2.0",
|
||||
"is-typedarray": "~1.0.0",
|
||||
"isstream": "~0.1.2",
|
||||
"json-stringify-safe": "~5.0.1",
|
||||
"mime-types": "~2.1.17",
|
||||
"oauth-sign": "~0.8.2",
|
||||
"performance-now": "^2.1.0",
|
||||
"qs": "~6.5.1",
|
||||
"safe-buffer": "^5.1.1",
|
||||
"tough-cookie": "~2.3.3",
|
||||
"tunnel-agent": "^0.6.0",
|
||||
"uuid": "^3.1.0"
|
||||
}
|
||||
},
|
||||
"request-promise-core": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/request-promise-core/-/request-promise-core-1.1.1.tgz",
|
||||
"integrity": "sha1-Pu4AssWqgyOc+wTFcA2jb4HNCLY=",
|
||||
"requires": {
|
||||
"lodash": "^4.13.1"
|
||||
}
|
||||
},
|
||||
"request-promise-native": {
|
||||
"version": "1.0.5",
|
||||
"resolved": "https://registry.npmjs.org/request-promise-native/-/request-promise-native-1.0.5.tgz",
|
||||
"integrity": "sha1-UoF3D2jgyXGeUWP9P6tIIhX0/aU=",
|
||||
"requires": {
|
||||
"request-promise-core": "1.1.1",
|
||||
"stealthy-require": "^1.1.0",
|
||||
"tough-cookie": ">=2.3.3"
|
||||
}
|
||||
},
|
||||
"safe-buffer": {
|
||||
"version": "5.1.2",
|
||||
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
|
||||
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g=="
|
||||
},
|
||||
"safer-buffer": {
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
|
||||
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
|
||||
},
|
||||
"sshpk": {
|
||||
"version": "1.14.2",
|
||||
"resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.14.2.tgz",
|
||||
"integrity": "sha1-xvxhZIo9nE52T9P8306hBeSSupg=",
|
||||
"requires": {
|
||||
"asn1": "~0.2.3",
|
||||
"assert-plus": "^1.0.0",
|
||||
"bcrypt-pbkdf": "^1.0.0",
|
||||
"dashdash": "^1.12.0",
|
||||
"ecc-jsbn": "~0.1.1",
|
||||
"getpass": "^0.1.1",
|
||||
"jsbn": "~0.1.0",
|
||||
"safer-buffer": "^2.0.2",
|
||||
"tweetnacl": "~0.14.0"
|
||||
}
|
||||
},
|
||||
"stealthy-require": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/stealthy-require/-/stealthy-require-1.1.1.tgz",
|
||||
"integrity": "sha1-NbCYdbT/SfJqd35QmzCQoyJr8ks="
|
||||
},
|
||||
"tough-cookie": {
|
||||
"version": "2.3.4",
|
||||
"resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.4.tgz",
|
||||
"integrity": "sha512-TZ6TTfI5NtZnuyy/Kecv+CnoROnyXn2DN97LontgQpCwsX2XyLYCC0ENhYkehSOwAp8rTQKc/NUIF7BkQ5rKLA==",
|
||||
"requires": {
|
||||
"punycode": "^1.4.1"
|
||||
}
|
||||
},
|
||||
"tunnel-agent": {
|
||||
"version": "0.6.0",
|
||||
"resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz",
|
||||
"integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=",
|
||||
"requires": {
|
||||
"safe-buffer": "^5.0.1"
|
||||
}
|
||||
},
|
||||
"tweetnacl": {
|
||||
"version": "0.14.5",
|
||||
"resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz",
|
||||
"integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=",
|
||||
"optional": true
|
||||
},
|
||||
"typedarray-to-buffer": {
|
||||
"version": "3.1.5",
|
||||
"resolved": "https://registry.npmjs.org/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz",
|
||||
"integrity": "sha512-zdu8XMNEDepKKR+XYOXAVPtWui0ly0NtohUscw+UmaHiAWT8hrV1rr//H6V+0DvJ3OQ19S979M0laLfX8rm82Q==",
|
||||
"requires": {
|
||||
"is-typedarray": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"uuid": {
|
||||
"version": "3.3.2",
|
||||
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz",
|
||||
"integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA=="
|
||||
},
|
||||
"verror": {
|
||||
"version": "1.10.0",
|
||||
"resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz",
|
||||
"integrity": "sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA=",
|
||||
"requires": {
|
||||
"assert-plus": "^1.0.0",
|
||||
"core-util-is": "1.0.2",
|
||||
"extsprintf": "^1.2.0"
|
||||
}
|
||||
},
|
||||
"websocket": {
|
||||
"version": "1.0.26",
|
||||
"resolved": "https://registry.npmjs.org/websocket/-/websocket-1.0.26.tgz",
|
||||
"integrity": "sha512-fjcrYDPIQxpTnqFQ9JjxUQcdvR89MFAOjPBlF+vjOt49w/XW4fJknUoMz/mDIn2eK1AdslVojcaOxOqyZZV8rw==",
|
||||
"requires": {
|
||||
"debug": "^2.2.0",
|
||||
"nan": "^2.3.3",
|
||||
"typedarray-to-buffer": "^3.1.2",
|
||||
"yaeti": "^0.0.6"
|
||||
}
|
||||
},
|
||||
"yaeti": {
|
||||
"version": "0.0.6",
|
||||
"resolved": "https://registry.npmjs.org/yaeti/-/yaeti-0.0.6.tgz",
|
||||
"integrity": "sha1-8m9ITXJoTPQr7ft2lwqhYI+/lXc="
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
{
|
||||
"name": "irc-bot",
|
||||
"version": "1.0.0",
|
||||
"description": "aewens's IRC bot for irc.tilde.team",
|
||||
"main": "bot.js",
|
||||
"scripts": {
|
||||
"start": "node bot.js",
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git@tilde.team:aewens/irc-bot.git"
|
||||
},
|
||||
"keywords": [
|
||||
"irc",
|
||||
"bot",
|
||||
"aewens"
|
||||
],
|
||||
"author": "aewens",
|
||||
"license": "BSD-3-Clause",
|
||||
"dependencies": {
|
||||
"irc": "^0.5.2",
|
||||
"nodemailer": "^4.6.7",
|
||||
"pushbullet": "^2.2.0"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
let nodemailer = require("nodemailer");
|
||||
const PushBullet = require("pushbullet");
|
||||
|
||||
module.exports = class Summon {
|
||||
constructor(client, from, incantation) {
|
||||
this.name = "Summon";
|
||||
this.client = client;
|
||||
this.summoner = from;
|
||||
this.incantation = incantation;
|
||||
this.spell = "alvoku la kreinton";
|
||||
this.cheatCode = "summon";
|
||||
this.casted = false;
|
||||
this.transporter = nodemailer.createTransport({
|
||||
sendmail: true,
|
||||
newline: "unix",
|
||||
path: "/usr/sbin/sendmail"
|
||||
});
|
||||
this.pusher = new PushBullet(client.config.api.pushbullet);
|
||||
}
|
||||
|
||||
test() {
|
||||
if (this.incantation === this.spell) {
|
||||
this.casted = true;
|
||||
return this.cast();
|
||||
}
|
||||
|
||||
return { say: false };
|
||||
}
|
||||
|
||||
cast() {
|
||||
let response = {
|
||||
say: false,
|
||||
debug: {},
|
||||
content: ""
|
||||
};
|
||||
|
||||
const subject = "You have been summoned!";
|
||||
const text = `Summoning request performed by ${this.summoner}`;
|
||||
|
||||
this.transporter.sendMail({
|
||||
to: this.client.email,
|
||||
subject: subject,
|
||||
text: text
|
||||
}, (err, info) => {
|
||||
console.log("Summon::email", info);
|
||||
response.debug.email = info;
|
||||
});
|
||||
|
||||
this.pusher.note(this.client.device, subject, text, (err, info) => {
|
||||
console.log("Summon::pusher", info);
|
||||
response.debug.pusher = info;
|
||||
});
|
||||
|
||||
const success = `Superba ${this.summoner}! You have summoned`;
|
||||
|
||||
response.say = true;
|
||||
response.content = `${success} ${this.client.config.author}!`;
|
||||
|
||||
return response;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue