123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- var user = function(){
- this.name = null;
- this.TS = null;
- this.ident = null;
- this.host = null;
- this.account = null;
- this.umodes = {};
- this.vhost = null;
- this.cloakedHost = null;
- this.ip = null;
- this.realname = null;
- this.uid = null;
- this.distance = null;
- this.uplink = null;
- this.secure = false;
- this.certfp = null;
- this.vident = null;
- this.metadata = {};
- this.channels = [];
-
- this.events = {};
- this.introduce = function(nick, distance, TS, ident, host, uid, account, umodes, vhost, cloakedHost, ip, realname, uplink){ // nick, distance, TS, ident, host, uid, account, umodes, vhost, cloakedHost, ip, realname, uplink
- this.name = nick;
- this.distance = distance;
- this.TS = TS;
- this.ident = ident;
- this.host = host;
- this.uid = uid;
- this.account = account;
- this.umodes = umodes;
- this.vhost = vhost;
- this.cloakedHost = cloakedHost;
- this.ip = ip;
- this.realname = realname;
- this.uplink = uplink;
- }
-
- this.setEvents = function(events){
- this.events = events;
- }
-
- this.setSecure = function(secure){
- this.secure = secure;
- }
-
- this.setFingerprint = function(certfp){
- this.certfp = certfp;
- }
-
- this.changeVHost = function(host){
- this.vhost = host;
- this.events.doEvent('userVHost', this);
- }
-
- this.changeVIdent = function(ident){
- this.vident = ident;
- this.events.doEvent('userVIdent', this);
- }
-
- this.setRealname = function(realname){
- this.realname = realname;
- this.events.doEvent('userRealname', this);
- }
-
- this.changeNick = function(nick){
- this.name = nick;
- this.events.doEvent('userNick', this);
- }
-
- this.changeUmodes = function(umodes){
- for(umode in umodes){
- this.umodes[umode] = umodes[umode];
- }
- this.events.doEvent('userUmode', this);
- }
-
- this.setMetadata = function(name, visibility, value){
- if(value){
- this.metadata[name] = { 'visibility': visibility, 'value': value };
- } else {
- if(name in this.metadata){
- delete this.metadata[name];
- }
- }
- this.events.doEvent('userMetadata', this, name);
- }
-
- this.joinChannel = function(channel){
- if(this.channels.indexOf(channel) < 0) this.channels.push(channel);
- }
-
- this.leaveChannel = function(channel){
- for(var i=0; i<this.channels.length; i++){
- if(this.channels[i] == channel){
- this.channels.splice(i, 1);
- break;
- }
- }
- }
- }
- module.exports = user;
|