Update things
This commit is contained in:
parent
1a8a6c1ef8
commit
4c5a28ca84
5 changed files with 86 additions and 21 deletions
3
.gitmodules
vendored
3
.gitmodules
vendored
|
@ -1,3 +1,6 @@
|
|||
[submodule "brainlet-lib"]
|
||||
path = brainlet-lib
|
||||
url = https://git.hippoz.xyz/hiimgoodpack/brainlet-lib.git
|
||||
[submodule "ircd.js"]
|
||||
path = ircd.js
|
||||
url = https://github.com/TestingPlant/ircd.js.git
|
||||
|
|
|
@ -1,3 +1,10 @@
|
|||
# brainlet-irc
|
||||
|
||||
Brainlet to IRC translation layer
|
||||
|
||||
# Technical notes
|
||||
|
||||
This uses irc@0.5.0. See [this](https://github.com/martynsmith/node-irc/issues/495) for more information
|
||||
|
||||
This also uses a fork of ircdjs to add the NOTICE command. [This pull request](https://github.com/alexyoung/ircd.js/pull/99)
|
||||
is trying to get it merged with the main repository, but I'm not sure how fast it'll get merged seeing the date of the last commit.
|
||||
|
|
28
config.js
28
config.js
|
@ -4,10 +4,30 @@ module.exports = {
|
|||
name: "BrainletToIrcSpectator",
|
||||
password: "Put a secure password here. See the README for more info"
|
||||
},
|
||||
motd: `A Brainlet to IRC translation layer.
|
||||
|
||||
SECURITY WARNING: The traffic to the Brainlet server is not encrypted
|
||||
motd: "A Brainlet to IRC translation layer.\n" +
|
||||
"SECURITY WARNING: The traffic to the Brainlet server is not encrypted.\n" +
|
||||
"Use \"/msg NickServ help\" to see how to use an account",
|
||||
|
||||
To sign up, use /nick YourName and then /msg NickServ REGISTER YourPassword YourEmail
|
||||
To log in, use /msg NickServ IDENTIFY YourName YourPassword`
|
||||
responses: {
|
||||
NickServ: {
|
||||
help: `NickServ allows you to use and create a Brainlet account from IRC.
|
||||
You can use a command with "/msg NickServ <command> <arguments>"
|
||||
|
||||
Commands:
|
||||
HELP - Shows this message
|
||||
REGISTER <password> <email> - Creates an account, using your current nick as the username.
|
||||
Note: The email is not directly used by IRC, but may be used by the Brainlet host.
|
||||
IDENTIFY <name> <password> - Logs into an account.`,
|
||||
|
||||
// Sent on invalid command
|
||||
invalid: "Invalid command. Use \"/msg NickServ help\" for help",
|
||||
|
||||
// Sent on an invalid entry.
|
||||
// %s is replaced with how it's invalid.
|
||||
invalidName: "Invalid username specified. %s",
|
||||
invalidEmail: "Invalid email specified. %s",
|
||||
invalidPassword: "Invalid password specified. %s"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
66
index.js
66
index.js
|
@ -16,12 +16,12 @@
|
|||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
const fs = require("fs");
|
||||
const ircServer = require("ircdjs");
|
||||
const ircServer = require("./ircd.js/lib/server.js");
|
||||
const ircClient = require("irc");
|
||||
const crypto = require("crypto");
|
||||
|
||||
// Set up IRC server
|
||||
const translationConfig = require(`${__dirname}/config.js`)
|
||||
const config = require(`${__dirname}/config.js`)
|
||||
|
||||
const genPass = () => {
|
||||
// This should give us a reasonably secure password
|
||||
|
@ -37,10 +37,10 @@ const ircConfig = {
|
|||
network: "BrainletToIRC",
|
||||
hostname: "localhost",
|
||||
serverDescription: "A brainlet to IRC translation layer",
|
||||
serverName: translationConfig.server,
|
||||
serverName: config.server,
|
||||
port: 6667,
|
||||
linkPort: 7777,
|
||||
motd: translationConfig.motd,
|
||||
motd: config.motd,
|
||||
whoWasLimit: 10000,
|
||||
token: 1,
|
||||
opers: systemUsers,
|
||||
|
@ -56,22 +56,56 @@ const ircConfig = {
|
|||
pingTimeout: 120,
|
||||
maxNickLength: 30
|
||||
};
|
||||
fs.writeFileSync(`${__dirname}/node_modules/ircdjs/config/config.json`, JSON.stringify(ircConfig));
|
||||
fs.writeFileSync(`${__dirname}/ircd.js/config/config.json`, JSON.stringify(ircConfig));
|
||||
|
||||
ircServer.Server.boot();
|
||||
|
||||
// Set up system users
|
||||
// TODO: Figure out why user is not joining
|
||||
const ircServerAddress = ircConfig.links.server.host;
|
||||
const ircServerPort = ircConfig.links.server.port;
|
||||
let NickServ = new ircClient.Client("127.0.0.1", "NickServ", {
|
||||
userName: "NickServ",
|
||||
realName: "NickServ",
|
||||
port: ircServerPort,
|
||||
channels: ["#foo"],
|
||||
password: systemUsers.NickServ.password
|
||||
});
|
||||
|
||||
let NickServ = new ircClient.Client("localhost", "NickServ");
|
||||
console.log(NickServ)
|
||||
NickServ.addListener("error", console.error);
|
||||
NickServ.addListener("join", () => {
|
||||
console.log("Joined server");
|
||||
})
|
||||
NickServ.addListener("message", (from, to, text, message) => {
|
||||
// Make sure it's a private message to NickServ
|
||||
if (to !== NickServ.opt.nick)
|
||||
return;
|
||||
|
||||
const args = text.split(" ");
|
||||
if (args.length == 0) {
|
||||
NickServ.notice(from, config.responses.NickServ.invalid);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (args[0].toLowerCase()) {
|
||||
case "help": {
|
||||
NickServ.notice(from, config.responses.NickServ.help);
|
||||
break;
|
||||
}
|
||||
case "register": {
|
||||
const password = args[1];
|
||||
const email = args[2];
|
||||
if (!password || !email) {
|
||||
NickServ.notice(from, config.responses.NickServ.invalid);
|
||||
return;
|
||||
}
|
||||
NickServ.notice(from, "Account registration is currently not implemented");
|
||||
break;
|
||||
}
|
||||
case "identify": {
|
||||
const name = args[1];
|
||||
const password = args[2];
|
||||
if (!name || !password) {
|
||||
NickServ.notice(from, config.responses.NickServ.invalid);
|
||||
return;
|
||||
}
|
||||
NickServ.notice(from, "Account login is currently not implemented");
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
NickServ.notice(from, config.responses.NickServ.invalid);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
1
ircd.js
Submodule
1
ircd.js
Submodule
|
@ -0,0 +1 @@
|
|||
Subproject commit 53e18a0032600abd092aced978e232f637221d1d
|
Loading…
Reference in a new issue