es2015 bitches
This commit is contained in:
		@@ -3,22 +3,20 @@ var tls = require("tls");
 | 
			
		||||
var EventEmitter = require("events").EventEmitter;
 | 
			
		||||
var util = require("util");
 | 
			
		||||
 | 
			
		||||
function irc(options) {
 | 
			
		||||
class irc {
 | 
			
		||||
  constructor(options) {
 | 
			
		||||
    EventEmitter.call(this);
 | 
			
		||||
    this.options = options || {};
 | 
			
		||||
    this.options.channels = this.options.channels || [];
 | 
			
		||||
 | 
			
		||||
    this.options.host = this.options.host || "127.0.0.1";
 | 
			
		||||
    this.options.port = this.options.port || 6667;
 | 
			
		||||
    this.options.ssl = this.options.ssl || false;
 | 
			
		||||
    this.options.selfSigned = this.options.selfSigned || false;
 | 
			
		||||
 | 
			
		||||
    this.network = this.options.network || "test";
 | 
			
		||||
    this.nickname = this.options.nickname || "test";
 | 
			
		||||
    this.username = this.options.username || "test";
 | 
			
		||||
    this.realname = this.options.realname || "test";
 | 
			
		||||
    this.channels = this.options.channels || [];
 | 
			
		||||
 | 
			
		||||
    this.socket = (this.options.ssl ? tls : net).connect({
 | 
			
		||||
      host: this.options.host,
 | 
			
		||||
      port: this.options.port,
 | 
			
		||||
@@ -28,7 +26,6 @@ function irc(options) {
 | 
			
		||||
      this.send("USER ", this.username, ' 0 * :', this.realname);
 | 
			
		||||
    });
 | 
			
		||||
    this.socket.setEncoding('utf-8');
 | 
			
		||||
 | 
			
		||||
    this.socket.on('data', msg => {
 | 
			
		||||
      msg = this.parse(msg);
 | 
			
		||||
      switch (msg.command) {
 | 
			
		||||
@@ -45,14 +42,12 @@ function irc(options) {
 | 
			
		||||
      }
 | 
			
		||||
    });
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
irc.prototype.send = function send() {
 | 
			
		||||
  send() {
 | 
			
		||||
    for (let i = 0; i < arguments.length; i++)
 | 
			
		||||
      this.socket.write(arguments[i]);
 | 
			
		||||
    this.socket.write('\n');
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
irc.prototype.parse = function parse(data) {
 | 
			
		||||
  parse(data) {
 | 
			
		||||
    var raw = data;
 | 
			
		||||
    if (data.charAt(0) === ':') {
 | 
			
		||||
      var i = data.indexOf(' ');
 | 
			
		||||
@@ -60,17 +55,20 @@ irc.prototype.parse = function parse(data) {
 | 
			
		||||
      data = data.slice(i + 1);
 | 
			
		||||
    }
 | 
			
		||||
    var i = data.indexOf(' ');
 | 
			
		||||
  if(i === -1) i = data.length;
 | 
			
		||||
    if (i === -1)
 | 
			
		||||
      i = data.length;
 | 
			
		||||
    var command = data.slice(0, i);
 | 
			
		||||
    data = data.slice(i + 1);
 | 
			
		||||
    var params = [];
 | 
			
		||||
    while (data && data.charAt(0) !== ':') {
 | 
			
		||||
      var i = data.indexOf(' ');
 | 
			
		||||
    if (i === -1) i = data.length;
 | 
			
		||||
      if (i === -1)
 | 
			
		||||
        i = data.length;
 | 
			
		||||
      params.push(data.slice(0, i));
 | 
			
		||||
      data = data.slice(i + 1);
 | 
			
		||||
    }
 | 
			
		||||
  if (data) params.push(data.slice(1));
 | 
			
		||||
    if (data)
 | 
			
		||||
      params.push(data.slice(1));
 | 
			
		||||
    return {
 | 
			
		||||
      raw: raw,
 | 
			
		||||
      prefix: prefix,
 | 
			
		||||
@@ -78,8 +76,7 @@ irc.prototype.parse = function parse(data) {
 | 
			
		||||
      params: params
 | 
			
		||||
    };
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
irc.prototype.reply = function(tmp) { //   prefix: 'Flummi!~bark@bark',
 | 
			
		||||
  reply(tmp) {
 | 
			
		||||
    let usertmp = tmp.prefix.split("!");
 | 
			
		||||
    let hosttmp = usertmp[1].split("@");
 | 
			
		||||
    let user = {
 | 
			
		||||
@@ -105,7 +102,8 @@ irc.prototype.reply = function(tmp) { //   prefix: 'Flummi!~bark@bark',
 | 
			
		||||
        //rpc.emit('call', this.network, 'notice', [this.channel, msg]);
 | 
			
		||||
      }
 | 
			
		||||
    };
 | 
			
		||||
};
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
module.exports = irc;
 | 
			
		||||
util.inherits(irc, EventEmitter);
 | 
			
		||||
		Reference in New Issue
	
	Block a user