123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771 |
- var protocol = {
- supportsTags: false,
- connected: function(){
- ircSend(handlers.newTags(), settings.ID, 'PASS', [settings.password]);
- ircSend(handlers.newTags(), settings.ID, 'PROTOCTL', ['NICKv2', 'VHP', 'UMODE2', 'NICKIP', 'SJOIN', 'SJOIN2', 'SJ3', 'NOQUIT', 'TKLEXT', 'MLOCK', 'SID', 'MTAGS']);
- ircSend(handlers.newTags(), settings.ID, 'PROTOCTL', ['EAUTH=' + settings.name + ',,,' + settings.version]);
- ircSend(handlers.newTags(), settings.ID, 'PROTOCTL', ['SID=' + settings.ID]);
- ircSend(handlers.newTags(), settings.ID, 'SERVER', [settings.name, '1', settings.description]);
- },
- processMessage: function(msg){
- if(!msg) return;
- if(msg.command in cmdBinds){
- cmdBinds[msg.command](msg);
- } else {
- console.log('Unhandled cmd: '+msg.command);
- console.log(msg);
- }
- },
- processSender: function(sender){
- if(sender.nick){
- if(server = handlers.findServer(sender.nick)){
- sender.nick = server.name;
- sender.server = server;
- } else if(user = handlers.findUser(sender.nick)){
- sender.nick = user.name
- sender.ident = user.ident;
- sender.host = user.host;
- sender.user = user;
- } else {
- handlers.killUser(sender.nick);
- return false;
- }
- }
- return sender;
- },
- setHandlers: function(newHandlers){
- handlers = newHandlers;
- },
- setSettings: function(newSettings){
- settings = newSettings;
- },
- setEvents: function(newEvents){
- events = newEvents;
- },
- // IRC actions
- introduceUser: function(user){
- var nick = user.name;
- var distance = user.distance.toString();
- var TS = user.TS.toString();
- var ident = user.ident;
- var host = user.host;
- var uid = user.uid;
- var account = '0';
- if(user.account){
- account = user.account;
- }
- var umodes = makeUmodeString(user.umodes, true);
- var vhost = '*';
- if(user.vhost){
- vhost = user.vhost;
- }
- var cloakedHost = '*';
- if(user.cloakedHost){
- cloakedHost = user.cloakedHost;
- }
- var ip = '*';
- if(user.ip){
- ip = user.ip;
- }
- var realname = user.realname;
- var args = [nick, distance, TS, ident, host, uid, account, umodes, vhost, cloakedHost, ip, realname];
- ircSend(handlers.newTags(), settings.ID, 'UID', args);
- },
- syncChannel: function(channel){
- var modes = null;
- var modeArgs = null;
- // prepare list modes
- var listModes = [];
- for(m in channel.listModes){
- var mode = channel.listModes[m];
- for(var i=0; i<mode.length; i++){
- switch(m){
- case 'BAN': listModes.push('&' + mode[i]); break;
- case 'EXCEPT': listModes.push('"' + mode[i]); break;
- case 'INVEX': listModes.push('\'' + mode[i]); break;
- }
- }
- }
- // prepare users
- var users = [];
- for(var i=0; i<channel.users.length; i++){
- var user = channel.users[i];
- if(user.uplink != settings.me) continue;
- var status = '';
- if(user.uid in channel.statusModes){
- var statusModes = channel.statusModes[user.uid];
- for(var j=0; j<statusModes.length; j++){
- var statusMode = statusModes[j];
- for(c in chmodeMap){
- if(chmodeMap[c].name == statusMode){
- for(sm in connection.statusmodes){
- if(connection.statusmodes[sm] == c){
- status += sm; // assign status character to user
- break;
- }
- }
- break;
- }
- }
- }
- }
- users.push(status + user.uid);
- }
- var done = false;
- var listCount = 0;
- var userCount = 0;
- do {
- var text = '';
- var count = 0;
- for(; listCount < listModes.length; listCount++){
- if(++count > 10) break;
- if(text.length > 0) text += ' ';
- text += listModes[listCount];
- }
-
- for(; userCount < users.length; userCount++){
- if(++count > 10) break;
- if(text.length > 0) text += ' ';
- text += users[userCount];
- }
-
- if(text.length == 0){
- break;
- }
- var args = [Math.floor(new Date() / 1000).toString(10), channel.name];
- if(modes) args.push(modes); else args.push('+');
- if(modeArgs) args.push(modeArgs);
- args.push(text);
- ircSend(handlers.newTags(), settings.ID, 'SJOIN', args);
- } while(true);
- },
- 'makeUid': function(){
- return settings.me.sid + randomID();
- },
- 'changeUmodes': function(user, umodes){
- if(user.uplink == settings.me){ // services bot
- ircSend(handlers.newTags(), user.uid, 'UMODE2', [makeUmodeString(umodes, true)]);
- } else { // normal user
- ircSend(handlers.newTags(), settings.ID, 'SVS2MODE', [user.uid, makeUmodeString(umodes, false)]);
- }
- user.changeUmodes(umodes);
- },
- 'joinChannel': function(user, channel){
- ircSend(handlers.newTags(), settings.ID, 'SJOIN', [Math.floor(new Date() / 1000).toString(10), channel.name, user.uid]);
- channel.joinUser(user);
- }
- }
- //>>> @time=2020-03-17T08:14:32.290Z;msgid=uwGzT2VzSTEEGab0demOxX :093 SJOIN 1584303585 #test :0931Y7O8W
- //>>> @time=2020-03-15T12:17:07.355Z;msgid=FhjgUp20YBKQ32TGPM28tS :143 SJOIN 1580651090 #help +nt :0931Y7O8W 093375CFR 123VTY20R
- function randomID(){
- var length = 6;
- var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
- return handlers.randomID(characters, length);
- }
- module.exports = protocol;
- var handlers = {
- sendHandler: null,
- findServer: null,
- findUser: null,
- killUser: null,
- newServer: null,
- newUser: null,
- getChannel: null,
- findChannel: null,
- quitUser: null,
- removeServer: null,
- randomID: null
- };
- var settings = {
- ID: null,
- password: null,
- name: null,
- description: null,
- version: null,
- me: null,
- maxUsers: null
- };
- var events = {};
- var connection = {
- 'protoctl': {},
- 'prefixes': {},
- 'statusmodes': [],
- 'chmodes': [], // 0 - list modes, 1 - argument modes, 2 - argument modes (add only), 3 - standard modes
- 'umodes': {}
- };
- var chmodeMap = {
- 'b': { 'name': 'BAN', 'user': true, 'services': true },
- 'e': { 'name': 'EXCEPT', 'user': true, 'services': true },
- 'I': { 'name': 'INVEX', 'user': true, 'services': true },
- 'v': { 'name': 'VOICE', 'user': true, 'services': true },
- 'h': { 'name': 'HALFOP', 'user': true, 'services': true },
- 'o': { 'name': 'OP', 'user': true, 'services': true },
- 'a': { 'name': 'PROTECT', 'user': true, 'services': true },
- 'q': { 'name': 'OWNER', 'user': true, 'services': true },
- 'k': { 'name': 'KEY', 'user': true, 'services': true },
- 'L': { 'name': 'CHANNELLINK', 'user': true, 'services': true },
- 'f': { 'name': 'FLOODPROT', 'user': true, 'services': true },
- 'l': { 'name': 'LIMIT', 'user': true, 'services': true },
- 'H': { 'name': 'HISTORY', 'user': true, 'services': true },
- 'p': { 'name': 'PRIVATE', 'user': true, 'services': true },
- 's': { 'name': 'SECRET', 'user': true, 'services': true },
- 'm': { 'name': 'MODERATED', 'user': true, 'services': true },
- 'n': { 'name': 'NOEXTERNAL', 'user': true, 'services': true },
- 't': { 'name': 'TOPIC', 'user': true, 'services': true },
- 'i': { 'name': 'INVITE', 'user': true, 'services': true },
- 'r': { 'name': 'REGISTERED', 'user': false, 'services': true },
- 'z': { 'name': 'SECUREONLY', 'user': true, 'services': true },
- 'M': { 'name': 'NONREGMODERATED', 'user': true, 'services': true },
- 'Q': { 'name': 'NOKICK', 'user': true, 'services': true },
- 'N': { 'name': 'NONICK', 'user': true, 'services': true },
- 'R': { 'name': 'NONREGINVITE', 'user': true, 'services': true },
- 'T': { 'name': 'NOCTCPS', 'user': true, 'services': true },
- 'O': { 'name': 'OPERS', 'user': false, 'services': true },
- 'V': { 'name': 'NOINVITE', 'user': true, 'services': true },
- 'K': { 'name': 'NOKNOCK', 'user': true, 'services': true },
- 'D': { 'name': 'OLDDELAYJOIN', 'user': false, 'services': false },
- 'd': { 'name': 'DELAYJOIN', 'user': true, 'services': true },
- 'G': { 'name': 'CENSOR', 'user': true, 'services': true },
- 'P': { 'name': 'PERMANENT', 'user': false, 'services': true },
- 'Z': { 'name': 'SECURE', 'user': false, 'services': false },
- 'S': { 'name': 'COLORFILTER', 'user': true, 'services': true },
- 'C': { 'name': 'NOCTCP', 'user': true, 'services': true },
- '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': false },
- 'B': { 'name': 'BOT', 'user': true, 'services': true }
- };
- function parseChannelModes(modes, args){
- var plus = true;
- var argIndex = 0;
- var output = {};
- output['status'] = [];
- output['list'] = [];
- for(var i=0; i<modes.length; i++){
- var c = modes.charAt(i);
- if(c in chmodeMap){
- var name = chmodeMap[c].name;
- } else {
- var name = c;
- }
- if(c == '+'){
- plus = true;
- } else if(c == '-'){
- plus = false;
- } else if(connection.chmodes[0].indexOf(c) >= 0){
- output['list'].push({ 'name': name, 'value': args[argIndex++], 'status': plus });
- } else if(connection.chmodes[1].indexOf(c) >= 0){
- if(plus){
- output[name] = args[argIndex++];
- } else {
- output[name] = false;
- argIndex++;
- }
- } else if(connection.chmodes[2].indexOf(c) >= 0){
- if(plus){
- output[name] = args[argIndex++];
- } else {
- output[name] = false;
- }
- } else if(connection.statusmodes.indexOf(c) >= 0){
- var user = handlers.findUser(args[argIndex++]);
- if(user){
- output['status'].push({ 'name': name, 'user': user, 'status': plus });
- } else {
- throw 'User not found';
- }
- } else { // treat unknown chars as type 3
- if(connection.chmodes[3].indexOf(c) < 0){
- console.log('Unknown mode '+name);
- }
- output[name] = plus;
- }
- }
- 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 makeUmodeString(umodes, own){
- var out = '';
- var plus = false;
- var addPM = true;
- for(char in umodeMap){
- var name = umodeMap[char].name;
- if(name in umodes){
- if(own || umodeMap[char].services){
- if(umodes[name] && (addPM || !plus)){
- addPM = false;
- plus = true;
- out += '+';
- } else if(!umodes[name] && (addPM || plus)){
- addPM = false;
- plus = false;
- out += '-';
- }
- out += char;
- } else {
- console.log('Attempted to set umode ' + char + ' which is not settable by services');
- }
- }
- }
- return out;
- }
- function parseModePrefix(text){
- var modes = {'status': [], 'list': [] };
- var isUser = false;
- var c = text.charAt(0);
- if(c == '&'){ // +b
- modes.list.push({ 'name': 'BAN', 'value': text.substring(1), 'status': true });
- } else if(c == '"'){ // +e
- modes.list.push({ 'name': 'EXCEPT', 'value': text.substring(1), 'status': true });
- } else if(c == '\''){ // +I
- modes.list.push({ 'name': 'INVEX', 'value': text.substring(1), 'status': true });
- } else {
- isUser = true;
- for(var i=0; i<text.length; i++){
- c = text.charAt(i);
- if(c in connection.prefixes){
- modes.status.push({ 'name': chmodeMap[connection.prefixes[c]].name, 'user': false /* setting it later */, 'status': true });
- // can be more than 1
- } else {
- break;
- }
- }
- }
- var user = null;
- if(isUser){
- var uid = text.substring(i);
- user = handlers.findUser(uid);
- if(!user){
- handlers.killUser(uid);
- modes.status = [];
- }
- for(var i=0; i<modes.status.length; i++){
- modes.status[i].user = user;
- }
- }
- return { 'modes': modes, 'user': user };
- }
- function ircSend(tags, from, cmd, args){
- handlers.send(tags, from, cmd, args);
- }
- var cmdBinds = {
- 'PROTOCTL': function(msg){
- for(var i=0; i<msg.args.length; i++){
- var arg = msg.args[i];
- if(arg.indexOf('=') >= 0){
- var arg = arg.split('=');
- connection.protoctl[arg[0]] = arg[1];
- switch(arg[0]){
- case 'PREFIX':
- var data = arg[1].substring(1).split(')');
- var modes = data[0].split('');
- var chars = data[1].split('');
- for(var i=0; i<modes.length; i++){
- connection.prefixes[chars[i]] = modes[i];
- connection.statusmodes.push(modes[i]);
- }
- break;
- case 'CHANMODES':
- connection.chmodes = arg[1].split(',');
- break;
- case 'USERMODES':
- connection.umodes = arg[1];
- break;
- }
- } else {
- switch(arg){
- case 'MTAGS': protocol.supportsTags = true; break;
- }
- connection.protoctl[arg] = true;
- }
- }
- console.log(protocol);
- },
-
- 'SERVER': function(msg){
- var expr = /^([^-]+)-([^-]+)-([^ ]+) (.*)$/;
- var match = expr.exec(msg.args[2]);
- if(match){
- settings.me.uplink = handlers.newServer(msg.args[0], match[3], match[4], msg.args[1], settings.me);
- } else {
- throw 'Unknown SERVER message';
- }
- events.doEvent('netSynced');
- ircSend(handlers.newTags(), settings.ID, 'EOS');
- },
-
- 'MD': function(msg){
- switch(msg.args[0]){
- case 'client':
- var user = handlers.findUser(msg.args[1]);
- if(!user) return;
- switch(msg.args[2]){
- case 'certfp':
- if(!msg.args[3] || msg.args[3].length == 0) break;
- user.setSecure(true);
- user.setFingerprint(msg.args[3]);
- break;
- default: break;
- }
- break;
- default: break;
- }
- },
-
- 'SMOD': function(msg){ // ignore
- },
-
- 'EOS': function(msg){ // ?
- console.log(connection);
- },
-
- 'SINFO': function(msg){
- console.log(msg);
- },
- 'SID': function(msg){
- handlers.newServer(msg.args[0], msg.args[2], msg.args[3], msg.args[1], msg.sender.server);
- },
-
- 'UID': function(msg){
- var nick = msg.args[0];
- var distance = msg.args[1];
- var TS = msg.args[2];
- var ident = msg.args[3];
- var host = msg.args[4];
- var uid = msg.args[5];
- var account = msg.args[6];
- var umodes = msg.args[7];
- var vhost = msg.args[8];
- var cloakedHost = msg.args[9];
- var ip = msg.args[10];
- var realname = msg.args[11];
- if(ip != '*'){
- var ipBinary = Buffer.from(ip, 'base64');
- if(ipBinary.byteLength == 4){ // IPv4
- ip = ipBinary[0].toString(10) + '.' + ipBinary[1].toString(10) + '.' + ipBinary[2].toString(10) + '.' + ipBinary[3].toString(10);
- } else if(ipBinary.byteLength == 16){ // IPv6
- ip = '';
- for(var i=0; i<8; i++){
- if(i > 0) ip += ':';
- ip += ipBinary[i*2].toString(16).padStart(2, '0') + ipBinary[i*2+1].toString(16).padStart(2, '0');
- }
- } else {
- throw 'unknown IP format';
- }
- } else {
- ip = null;
- }
- if(vhost == '*'){
- vhost = null;
- }
- if(cloakedHost == '*'){
- cloakedHost = null;
- }
- if(account == '0'){
- account = null;
- }
- handlers.newUser(nick, distance, TS, ident, host, uid, account, parseUmodes(umodes), vhost, cloakedHost, ip, realname, msg.sender.server);
- },
- 'SJOIN': function(msg){
- var channel = handlers.getChannel(msg.args[1]);
- channel.setTS(msg.args[0]);
- if(msg.args.length > 3){
- var modeArgs = [];
- for(var i=3; i<msg.args.length - 1; i++){
- modeArgs.push(msg.args[i]);
- }
- channel.changeModes(parseChannelModes(msg.args[2], modeArgs));
- }
- var members = msg.text.split(' ');
- for(var i=0; i<members.length; i++){
- var member = members[i];
- var c = member.charAt(0);
- var udata = parseModePrefix(member);
- if(udata.user){
- console.log(udata.user.name + ' joined ' + msg.args[1]);
- channel.joinUser(udata.user);
- }
- channel.changeModes(udata.modes);
- }
- },
-
- 'SENDUMODE': function(msg){ // ignore
- },
-
- 'SENDSNO': function(msg){ // ignore
- },
-
- 'PASS': function(msg){ // ignore
- },
-
- 'SWHOIS': function(msg){
- console.log(msg);
- //TODO
- },
- 'MODE': function(msg){
- var channel = handlers.findChannel(msg.args[0]);
- if(channel){
- var modeArgs = [];
- for(var i=2; i<msg.args.length; i++){
- modeArgs.push(msg.args[i]);
- }
- var chmodes = parseChannelModes(msg.args[1], modeArgs);
- channel.changeModes(chmodes);
- }
- },
-
- 'TKL': function(msg){
- // console.log(msg);
- //TODO
- },
-
- 'METADATA': function(msg){
- var what = msg.args[0];
- var name = msg.args[1];
- var visibility = msg.args[2];
- if(msg.args.length > 3){
- var value = msg.args[3];
- } else {
- var value = null;
- }
- var channel = handlers.findChannel(what);
- if(channel){
- channel.setMetadata(name, visibility, value);
- return;
- }
- var user = handlers.findUser(what);
- if(user){
- user.setMetadata(name, visibility, value);
- }
- },
-
- 'NETINFO': function(msg){
- ircSend(handlers.newTags(), null, 'NETINFO', [settings.maxUsers.toString(10), Math.floor(new Date() / 1000).toString(10), msg.args[2], msg.args[3], "0", "0", "0", msg.args[7]]);
- },
-
- 'SASL': function(msg){
- console.log(msg);
- //TODO
- },
-
- 'PING': function(msg){
- msg.reply(null, 'PONG', msg.args);
- },
- 'QUIT': function(msg){
- handlers.quitUser(msg.sender.user);
- },
- 'PART': function(msg){
- var channel = handlers.getChannel(msg.args[0]);
- channel.removeUser(msg.sender.user);
- },
-
- 'CHGHOST': function(msg){
- var user = handlers.findUser(msg.args[0]);
- if(!user) return;
- user.changeVHost(msg.args[1]);
- },
-
- 'CHGIDENT': function(msg){
- var user = handlers.findUser(msg.args[0]);
- if(!user) return;
- user.changeVIdent(msg.args[1]);
- },
-
- 'CHGNAME': function(msg){
- var user = handlers.findUser(msg.args[0]);
- if(!user) return;
- user.setRealname(msg.args[1]);
- },
-
- 'SETNAME': function(msg){
- msg.sender.user.setRealname(msg.args[0]);
- },
-
- 'SETHOST': function(msg){
- msg.sender.user.changeVHost(msg.args[0]);
- },
-
- 'SETIDENT': function(msg){
- msg.sender.user.changeVIdent(msg.args[0]);
- },
-
- 'NICK': function(msg){
- msg.sender.user.changeNick(msg.args[0]);
- },
-
- 'SDESC': function(msg){
- msg.sender.uplink.setDescription(msg.args[0]);
- },
-
- 'TOPIC': function(msg){
- var channel = handlers.findChannel(msg.args[0]);
- if(!channel) return;
- var setter = msg.args[1];
- var TS = msg.args[2];
- var text = msg.args[3];
- channel.setTopic({'setter': setter, 'TS': TS, 'text': text });
- },
- /*
- messagedata {
- text: '0',
- args: [ '183.89.186.94', '0' ],
- tags: [],
- command: 'REPUTATION',
- sender: {
- nick: 'test1.pirc.pl',
- ident: '',
- host: '',
- server: server {
- name: 'test1.pirc.pl',
- sid: '093',
- description: 'serwer testowy!',
- distance: '3',
- uplink: [Object],
- introduce: [Function]
- },
- user: false
- },
- time: 2020-03-14T10:48:06.207Z,
- reply: [Function],
- originalString: ':093 REPUTATION 183.89.186.94 0'
- }
- */
- 'REPUTATION': function(msg){
- //TODO
- },
- 'UMODE2': function(msg){
- msg.sender.user.changeUmodes(parseUmodes(msg.args[0]));
- },
-
- 'KILL': function(msg){
- var user = handlers.findUser(msg.args[0]);
- if(!user) return;
- handlers.quitUser(user);
- },
- 'SQUIT': function(msg){
- var server = handlers.findServer(msg.args[0]);
- if(!server) return;
- handlers.removeServer(server);
- },
- /*messagedata {
- text: 'TestServ',
- args: [ '11K3R1VLH', 'TestServ' ],
- tags: [],
- command: 'WHOIS',
- sender: {
- nick: 'k4be',
- ident: 'testowy',
- host: 'localhost',
- server: false,
- user: user {
- name: 'k4be',
- TS: '1583056052',
- ident: 'testowy',
- host: 'localhost',
- account: null,
- umodes: [Object],
- vhost: 'staff:netadmin',
- cloakedHost: 'ukryty-18D8A42D',
- ip: '0000:0000:0000:0000:0000:0000:0000:0001',
- realname: 'realname',
- uid: '143ZQ0B02',
- distance: '0',
- uplink: [server],
- secure: false,
- certfp: null,
- vident: null,
- metadata: {},
- introduce: [Function],
- setSecure: [Function],
- setFingerprint: [Function],
- changeVHost: [Function],
- changeVIdent: [Function],
- setRealname: [Function],
- changeNick: [Function],
- changeUmodes: [Function],
- setMetadata: [Function]
- }
- },
- time: 2020-03-16T14:02:45.252Z,
- reply: [Function],
- originalString: ':143ZQ0B02 WHOIS 11K3R1VLH :TestServ'
- }*/
- 'WHOIS': function(msg){
- },
- 'PRIVMSG': function(msg){
- if(msg.args[0].charAt(0) == '#'){
- events.doEvent('channelMessage', msg);
- } else {
- events.doEvent('botMessage', msg);
- }
- },
-
- 'NOTICE': function(msg){
- if(msg.args[0].charAt(0) == '#'){
- events.doEvent('channelNotice', msg);
- } else {
- events.doEvent('botNotice', msg);
- }
- }
- };
|