Example #1
0
 socket.on('data', function(data) {
  console.log(new Date + " [DEBUG] [" + name + "@RCON]> " + data.toString());
  if (socket.auth) {
   bot.execCmd({
    "numeric": "PRIVMSG",
    "prefix": name + "!~" + name + "@" + name,
    "args": name + " " + data,
    "nick": name,
    "ident": "~" + name,
    "host": name,
    "channel": name,
    "msg": "?!" + data.toString(),
    "unparsed": [":" + name + "!~" + name + "@" + name, "PRIVMSG", name].push(data.toString().split(" "))
   });
  } else if (data.toString().split(" ")[0] == "PASS") {
   if (data.toString().split(" ")[1] == passwd) {
    socket.write("LOGIN_SUCESSFULL You logged in.\r\n");
    console.log("[INFO] Client from " + socket.remoteAddress + " logged in");
    socket.auth = true;
   } else {
    socket.write("ERR_WRONG_PASSWD Invalid password.\r\n");
   }
  } else {
   socket.write("ERR_NOT_LOGED_IN You need to auth using PASS <password>\r\n");
  }
 });
Example #2
0
bot.on("PRIVMSG", function(data, parsed) {
 if (parsed.unparsed[2].toLowerCase() == "ioserv") {
  var nick = parsed.unparsed[0].substr(1);
  var msg = parsed.unparsed.slice(3).join(" ").substr(1).replace("\r", "").replace("\n", "");
  console.log("Got PM from " + nick + ", data: " + msg);
  bot.execCmd({
   "numeric": "PRIVMSG",
   "prefix": nick + "!~" + nick + "@" + nick,
   "args": nick + " " + data,
   "nick": nick,
   "ident": "~" + nick,
   "host": nick,
   "channel": nick,
   "msg": "?!" + msg.toString(),
   "unparsed": [":" + nick + "!~" + nick + "@" + nick, "PRIVMSG", nick].push(msg.toString().split(" "))
  });
  console.log("User's host is " + (bot.nicks[nick] || new Array(7))[7]);
 }
});