hasi geti deli :⁾
This commit is contained in:
		@@ -6,7 +6,8 @@
 | 
				
			|||||||
  "scripts": {
 | 
					  "scripts": {
 | 
				
			||||||
    "build": "./node_modules/.bin/babel src --presets=env --plugins=add-module-exports --out-dir dist",
 | 
					    "build": "./node_modules/.bin/babel src --presets=env --plugins=add-module-exports --out-dir dist",
 | 
				
			||||||
    "debug": "node --inspect=9229 dist/bot.js",
 | 
					    "debug": "node --inspect=9229 dist/bot.js",
 | 
				
			||||||
    "start": "npm run build && node dist/bot.js"
 | 
					    "start": "npm run build && node dist/bot.js",
 | 
				
			||||||
 | 
					    "inspect": "npm run build && node --inspect=9229 dist/bot.js"
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
  "author": "Flummi & jkhsjdhjs",
 | 
					  "author": "Flummi & jkhsjdhjs",
 | 
				
			||||||
  "license": "WTFPL",
 | 
					  "license": "WTFPL",
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,7 +1,7 @@
 | 
				
			|||||||
var net = require("net");
 | 
					const net = require("net")
 | 
				
			||||||
var tls = require("tls");
 | 
					  , tls = require("tls")
 | 
				
			||||||
var EventEmitter = require("events").EventEmitter;
 | 
					  , EventEmitter = require("events").EventEmitter
 | 
				
			||||||
var util = require("util");
 | 
					  ,util = require("util");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class irc {
 | 
					class irc {
 | 
				
			||||||
  constructor(options) {
 | 
					  constructor(options) {
 | 
				
			||||||
@@ -39,37 +39,38 @@ class irc {
 | 
				
			|||||||
      let tmpuser = {};
 | 
					      let tmpuser = {};
 | 
				
			||||||
      let tmpchan = {};
 | 
					      let tmpchan = {};
 | 
				
			||||||
      let chans = [];
 | 
					      let chans = [];
 | 
				
			||||||
 | 
					      let prefix = "";
 | 
				
			||||||
      switch (msg.command) { // auslagern!
 | 
					      switch (msg.command) { // auslagern!
 | 
				
			||||||
      // WHOIS BEGIN
 | 
					      // WHOIS BEGIN
 | 
				
			||||||
      case "307": // Rizon Account
 | 
					      case "307": // Rizon Account
 | 
				
			||||||
        tmpuser = {};
 | 
					        tmpuser = {};
 | 
				
			||||||
        if(this.server.user.has( msg.params[1].toLowerCase() ))
 | 
					        if(this.server.user.hasi( msg.params[1] ))
 | 
				
			||||||
          tmpuser = this.server.user.get( msg.params[1].toLowerCase() );
 | 
					          tmpuser = this.server.user.geti( msg.params[1] );
 | 
				
			||||||
        tmpuser.account = msg.params[1].toLowerCase();
 | 
					        tmpuser.account = msg.params[1];
 | 
				
			||||||
        tmpuser.registered = true;
 | 
					        tmpuser.registered = true;
 | 
				
			||||||
        this.server.user.set( msg.params[1].toLowerCase(), tmpuser );
 | 
					        this.server.user.set( msg.params[1], tmpuser );
 | 
				
			||||||
        break;
 | 
					        break;
 | 
				
			||||||
      case "311": // first
 | 
					      case "311": // first
 | 
				
			||||||
        tmpuser = {};
 | 
					        tmpuser = {};
 | 
				
			||||||
        if (this.server.user.has( msg.params[1].toLowerCase() ))
 | 
					        if (this.server.user.hasi( msg.params[1] ))
 | 
				
			||||||
          tmpuser = this.server.user.get( msg.params[1].toLowerCase() );
 | 
					          tmpuser = this.server.user.geti( msg.params[1] );
 | 
				
			||||||
        tmpuser.nickname = msg.params[1].toLowerCase();
 | 
					        tmpuser.nickname = msg.params[1];
 | 
				
			||||||
        tmpuser.username = msg.params[2];
 | 
					        tmpuser.username = msg.params[2];
 | 
				
			||||||
        tmpuser.hostname = msg.params[3];
 | 
					        tmpuser.hostname = msg.params[3];
 | 
				
			||||||
        tmpuser.realname = msg.params[5];
 | 
					        tmpuser.realname = msg.params[5];
 | 
				
			||||||
        this.server.user.set( msg.params[1].toLowerCase(), tmpuser );
 | 
					        this.server.user.set( msg.params[1], tmpuser );
 | 
				
			||||||
        break;
 | 
					        break;
 | 
				
			||||||
      case "313": // Oper
 | 
					      case "313": // Oper
 | 
				
			||||||
        tmpuser = {};
 | 
					        tmpuser = {};
 | 
				
			||||||
        if (this.server.user.has( msg.params[1].toLowerCase() ))
 | 
					        if (this.server.user.hasi( msg.params[1] ))
 | 
				
			||||||
          tmpuser = this.server.user.get( msg.params[1].toLowerCase() );
 | 
					          tmpuser = this.server.user.geti( msg.params[1] );
 | 
				
			||||||
        tmpuser.oper = true;
 | 
					        tmpuser.oper = true;
 | 
				
			||||||
        this.server.user.set( msg.params[1].toLowerCase(), tmpuser );
 | 
					        this.server.user.set( msg.params[1], tmpuser );
 | 
				
			||||||
        break;
 | 
					        break;
 | 
				
			||||||
      case "318": // last (check Data)
 | 
					      case "318": // last (check Data)
 | 
				
			||||||
        tmpuser = {};
 | 
					        tmpuser = {};
 | 
				
			||||||
        if (this.server.user.has( msg.params[1].toLowerCase() ))
 | 
					        if (this.server.user.hasi( msg.params[1] ))
 | 
				
			||||||
          tmpuser = this.server.user.get( msg.params[1].toLowerCase() );
 | 
					          tmpuser = this.server.user.geti( msg.params[1] );
 | 
				
			||||||
        tmpuser = {
 | 
					        tmpuser = {
 | 
				
			||||||
          nickname: tmpuser.nickname || false,
 | 
					          nickname: tmpuser.nickname || false,
 | 
				
			||||||
          username: tmpuser.username || false,
 | 
					          username: tmpuser.username || false,
 | 
				
			||||||
@@ -81,13 +82,13 @@ class irc {
 | 
				
			|||||||
          channels: tmpuser.channels || [],
 | 
					          channels: tmpuser.channels || [],
 | 
				
			||||||
          cached: ~~(Date.now() / 1000)
 | 
					          cached: ~~(Date.now() / 1000)
 | 
				
			||||||
        };
 | 
					        };
 | 
				
			||||||
        this.server.user.set( msg.params[1].toLowerCase(), tmpuser );
 | 
					        this.server.user.set( msg.params[1], tmpuser );
 | 
				
			||||||
        break;
 | 
					        break;
 | 
				
			||||||
      case "319": // Chanlist Todo
 | 
					      case "319": // Chanlist Todo
 | 
				
			||||||
        tmpchan = new Map();
 | 
					        tmpchan = new Map();
 | 
				
			||||||
        tmpuser = {};
 | 
					        tmpuser = {};
 | 
				
			||||||
        if (this.server.user.has( msg.params[1].toLowerCase() )) {
 | 
					        if (this.server.user.hasi( msg.params[1] )) {
 | 
				
			||||||
          tmpuser = this.server.user.get( msg.params[1].toLowerCase() );
 | 
					          tmpuser = this.server.user.geti( msg.params[1] );
 | 
				
			||||||
          if(tmpuser.channels)
 | 
					          if(tmpuser.channels)
 | 
				
			||||||
            tmpchan = tmpuser.channels;
 | 
					            tmpchan = tmpuser.channels;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@@ -99,15 +100,15 @@ class irc {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
        tmpuser.channels = tmpchan;
 | 
					        tmpuser.channels = tmpchan;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        this.server.user.set( msg.params[1].toLowerCase(), tmpuser );
 | 
					        this.server.user.set( msg.params[1], tmpuser );
 | 
				
			||||||
        break;
 | 
					        break;
 | 
				
			||||||
      case "330": // Quarknet
 | 
					      case "330": // Quarknet
 | 
				
			||||||
        tmpuser = {};
 | 
					        tmpuser = {};
 | 
				
			||||||
        if (this.server.user.has( msg.params[1].toLowerCase() ))
 | 
					        if (this.server.user.hasi( msg.params[1] ))
 | 
				
			||||||
          tmpuser = this.server.user.get( msg.params[1].toLowerCase() );
 | 
					          tmpuser = this.server.user.geti( msg.params[1] );
 | 
				
			||||||
        tmpuser.account = msg.params[2];
 | 
					        tmpuser.account = msg.params[2];
 | 
				
			||||||
        tmpuser.registered = true;
 | 
					        tmpuser.registered = true;
 | 
				
			||||||
        this.server.user.set( msg.params[1].toLowerCase(), tmpuser );
 | 
					        this.server.user.set( msg.params[1], tmpuser );
 | 
				
			||||||
        break;
 | 
					        break;
 | 
				
			||||||
        // WHOIS END
 | 
					        // WHOIS END
 | 
				
			||||||
      case "001": // welcome
 | 
					      case "001": // welcome
 | 
				
			||||||
@@ -163,6 +164,12 @@ class irc {
 | 
				
			|||||||
      case "NOTICE":
 | 
					      case "NOTICE":
 | 
				
			||||||
        this.emit("data", ["notice", msg.params[1]]);
 | 
					        this.emit("data", ["notice", msg.params[1]]);
 | 
				
			||||||
        break;
 | 
					        break;
 | 
				
			||||||
 | 
					      case "NICK": // nickchange
 | 
				
			||||||
 | 
					        prefix = parsePrefix(msg.prefix);
 | 
				
			||||||
 | 
					        if(this.server.user.hasi(prefix.nick))
 | 
				
			||||||
 | 
					          this.server.user.deli(prefix.nick);
 | 
				
			||||||
 | 
					        this.whois(msg.params[0], true); // force
 | 
				
			||||||
 | 
					        break;
 | 
				
			||||||
      default:
 | 
					      default:
 | 
				
			||||||
        console.log(msg);
 | 
					        console.log(msg);
 | 
				
			||||||
        break;
 | 
					        break;
 | 
				
			||||||
@@ -243,9 +250,9 @@ class irc {
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
  whois(user, force = false) {
 | 
					  whois(user, force = false) {
 | 
				
			||||||
    user = user.toLowerCase();
 | 
					    user = user.toLowerCase();
 | 
				
			||||||
    if(this.server.user.has(user) && !force) {
 | 
					    if(this.server.user.hasi(user) && !force) {
 | 
				
			||||||
      if(this.server.user.get(user).cached >= ~~(Date.now() / 1000) - this._recachetime) {
 | 
					      if(this.server.user.geti(user).cached >= ~~(Date.now() / 1000) - this._recachetime) {
 | 
				
			||||||
        console.log(this.server.user.get(user).cached, ~~(Date.now() / 1000) - this._recachetime);
 | 
					        console.log(this.server.user.geti(user).cached, ~~(Date.now() / 1000) - this._recachetime);
 | 
				
			||||||
        console.log(user, "already cached");
 | 
					        console.log(user, "already cached");
 | 
				
			||||||
        return;
 | 
					        return;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
@@ -266,4 +273,24 @@ function parsePrefix(prefix) {
 | 
				
			|||||||
    username: hosttmp[0],
 | 
					    username: hosttmp[0],
 | 
				
			||||||
    hostname: hosttmp[1]
 | 
					    hostname: hosttmp[1]
 | 
				
			||||||
  };
 | 
					  };
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Map.prototype.hasi = function(val) {
 | 
				
			||||||
 | 
					  for (let [key] of this)
 | 
				
			||||||
 | 
					    if(key.toLowerCase() === val.toLowerCase())
 | 
				
			||||||
 | 
					      return true;
 | 
				
			||||||
 | 
					  return false;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Map.prototype.geti = function(val) {
 | 
				
			||||||
 | 
					  for (let [key, value] of this)
 | 
				
			||||||
 | 
					    if(key.toLowerCase() === val.toLowerCase())
 | 
				
			||||||
 | 
					      return value;
 | 
				
			||||||
 | 
					  return false;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Map.prototype.deli = function(val) {
 | 
				
			||||||
 | 
					  for (let [key] of this)
 | 
				
			||||||
 | 
					    if(key.toLowerCase() === val.toLowerCase())
 | 
				
			||||||
 | 
					      this.delete(key);
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
		Reference in New Issue
	
	Block a user