|
@@ -49,7 +49,6 @@ var handlers = {
|
|
|
killUser: null,
|
|
|
newServer: null,
|
|
|
newUser: null,
|
|
|
- parseUmodes: null,
|
|
|
getChannel: null,
|
|
|
findChannel: null,
|
|
|
quitUser: null,
|
|
@@ -114,6 +113,30 @@ var chmodeMap = {
|
|
|
'c': { 'name': 'NOCOLOR', 'user': true, 'services': true }
|
|
|
};
|
|
|
|
|
|
+var umodeMap = {
|
|
|
+ 'i': { 'name': 'INVISIBLE', 'user': true, 'services': true },
|
|
|
+ 'o': { 'name': 'OPER', 'user': false, 'services': false },
|
|
|
+ 'w': { 'name': 'WALLOP', 'user': true, 'services': true },
|
|
|
+ 'r': { 'name': 'REGISTEREDNICK', 'user': false, 'services': true },
|
|
|
+ 's': { 'name': 'SNOTICE', 'user': true, 'services': true },
|
|
|
+ 'x': { 'name': 'CLOAK', 'user': true, 'services': true },
|
|
|
+ 'z': { 'name': 'SECUREUSER', 'user': false, 'services': false },
|
|
|
+ 'd': { 'name': 'DEAF', 'user': true, 'services': true },
|
|
|
+ 'H': { 'name': 'HIDEIRCOP', 'user': false, 'services': false },
|
|
|
+ 't': { 'name': 'VHOST', 'user': false, 'services': true },
|
|
|
+ 'I': { 'name': 'HIDEIDLE', 'user': false, 'services': false },
|
|
|
+ 'D': { 'name': 'PRIVDEAF', 'user': true, 'services': true },
|
|
|
+ 'Z': { 'name': 'SECUREMESSAGES', 'user': true, 'services': true },
|
|
|
+ 'R': { 'name': 'REGISTEREDMESSAGES', 'user': true, 'services': true },
|
|
|
+ 'q': { 'name': 'UNKICKABLE', 'user': false, 'services': false },
|
|
|
+ 'p': { 'name': 'HIDECHANNELS', 'user': true, 'services': true },
|
|
|
+ 'W': { 'name': 'WHOISNOTICE', 'user': false, 'services': false },
|
|
|
+ 'G': { 'name': 'CENSORMESSAGES', 'user': true, 'services': true },
|
|
|
+ 'T': { 'name': 'NOCTCPMESSAGES', 'user': true, 'services': true },
|
|
|
+ 'S': { 'name': 'SERVICEUSER', 'user': false, 'services': true },
|
|
|
+ 'B': { 'name': 'BOT', 'user': true, 'services': true }
|
|
|
+};
|
|
|
+
|
|
|
function parseChannelModes(modes, args){
|
|
|
var plus = true;
|
|
|
var argIndex = 0;
|
|
@@ -149,7 +172,6 @@ function parseChannelModes(modes, args){
|
|
|
} else if(connection.statusmodes.indexOf(c) >= 0){
|
|
|
var user = handlers.findUser(args[argIndex++]);
|
|
|
if(user){
|
|
|
- console.log('Setting status mode for '+user.name);
|
|
|
output['status'].push({ 'name': name, 'user': user, 'status': plus });
|
|
|
} else {
|
|
|
throw 'User not found';
|
|
@@ -161,10 +183,27 @@ function parseChannelModes(modes, args){
|
|
|
output[name] = plus;
|
|
|
}
|
|
|
}
|
|
|
- console.log(output);
|
|
|
return output;
|
|
|
}
|
|
|
|
|
|
+function parseUmodes(modeString){
|
|
|
+ var plus = true;
|
|
|
+ var modes = {};
|
|
|
+ for(var i=0; i<modeString.length; i++){
|
|
|
+ var c = modeString.charAt(i);
|
|
|
+ switch(c){
|
|
|
+ case '+': plus = true; break;
|
|
|
+ case '-': plus = false; break;
|
|
|
+ default:
|
|
|
+ var modeName = umodeMap[c].name;
|
|
|
+ if(!modeName) modeName = c;
|
|
|
+ modes[modeName] = plus;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return modes;
|
|
|
+}
|
|
|
+
|
|
|
function parseModePrefix(text){
|
|
|
var modes = {'status': [], 'list': [] };
|
|
|
var isUser = false;
|
|
@@ -319,7 +358,7 @@ var cmdBinds = {
|
|
|
if(account == '0'){
|
|
|
account = null;
|
|
|
}
|
|
|
- handlers.newUser(nick, distance, TS, ident, host, uid, account, handlers.parseUmodes(umodes), vhost, cloakedHost, ip, realname, msg.sender.server);
|
|
|
+ handlers.newUser(nick, distance, TS, ident, host, uid, account, parseUmodes(umodes), vhost, cloakedHost, ip, realname, msg.sender.server);
|
|
|
},
|
|
|
|
|
|
'SJOIN': function(msg){
|
|
@@ -348,6 +387,9 @@ var cmdBinds = {
|
|
|
'SENDUMODE': function(msg){ // ignore
|
|
|
},
|
|
|
|
|
|
+ 'SENDSNO': function(msg){ // ignore
|
|
|
+ },
|
|
|
+
|
|
|
'PASS': function(msg){ // ignore
|
|
|
},
|
|
|
|
|
@@ -355,33 +397,7 @@ var cmdBinds = {
|
|
|
console.log(msg);
|
|
|
//TODO
|
|
|
},
|
|
|
-/*messagedata {
|
|
|
- text: '1584206946',
|
|
|
- args: [ '#qwer', '+nt', '1584206946' ],
|
|
|
- tags: [
|
|
|
- time: '2020-03-14T17:29:07.017Z',
|
|
|
- msgid: '0AnsVOjKaaFGxoaANiChIo-Uqo0dqr9WjGPgUEgGzdr3w'
|
|
|
- ],
|
|
|
- command: 'MODE',
|
|
|
- sender: {
|
|
|
- nick: 'test3.pirc.pl',
|
|
|
- ident: '',
|
|
|
- host: '',
|
|
|
- server: server {
|
|
|
- name: 'test3.pirc.pl',
|
|
|
- sid: '143',
|
|
|
- description: 'serwer testowy!',
|
|
|
- distance: '1',
|
|
|
- uplink: [server],
|
|
|
- introduce: [Function]
|
|
|
- },
|
|
|
- user: false
|
|
|
- },
|
|
|
- time: 2020-03-14T17:29:07.021Z,
|
|
|
- reply: [Function],
|
|
|
- originalString: '@time=2020-03-14T17:29:07.017Z;msgid=0AnsVOjKaaFGxoaANiChIo-Uqo0dqr9WjGPgUEgGzdr3w :143 MODE #qwer +nt 1584206946'
|
|
|
-}
|
|
|
-*/
|
|
|
+
|
|
|
'MODE': function(msg){
|
|
|
var channel = handlers.findChannel(msg.args[0]);
|
|
|
if(channel){
|
|
@@ -392,8 +408,6 @@ var cmdBinds = {
|
|
|
var chmodes = parseChannelModes(msg.args[1], modeArgs);
|
|
|
channel.changeModes(chmodes);
|
|
|
}
|
|
|
- console.log(msg);
|
|
|
- //TODO
|
|
|
},
|
|
|
|
|
|
'TKL': function(msg){
|
|
@@ -451,13 +465,11 @@ var cmdBinds = {
|
|
|
},
|
|
|
|
|
|
'SETHOST': function(msg){
|
|
|
- console.log(msg);
|
|
|
- //TODO
|
|
|
+ msg.sender.user.changeVHost(msg.args[0]);
|
|
|
},
|
|
|
|
|
|
'SETIDENT': function(msg){
|
|
|
- console.log(msg);
|
|
|
- //TODO
|
|
|
+ msg.sender.user.changeVIdent(msg.args[0]);
|
|
|
},
|
|
|
|
|
|
'NICK': function(msg){
|
|
@@ -501,10 +513,9 @@ messagedata {
|
|
|
'REPUTATION': function(msg){
|
|
|
//TODO
|
|
|
},
|
|
|
-
|
|
|
+
|
|
|
'UMODE2': function(msg){
|
|
|
- console.log(msg);
|
|
|
- //TODO
|
|
|
+ msg.sender.user.changeUmodes(parseUmodes(msg.args[0]));
|
|
|
},
|
|
|
|
|
|
'KILL': function(msg){
|