|
@@ -4,7 +4,6 @@ var IRCserver = require('./server');
|
|
|
var IRCuser = require('./user');
|
|
|
var IRCchannel = require('./channel');
|
|
|
|
|
|
-var uplink = null;
|
|
|
var connection = null;
|
|
|
var recvData = '';
|
|
|
var users = [];
|
|
@@ -18,11 +17,11 @@ function addInternalEvents(){
|
|
|
for(var i=0; i<users.length; i++){
|
|
|
var user = users[i];
|
|
|
if(user.uplink == me){
|
|
|
- uplink.introduceUser(user);
|
|
|
+ irc.uplink.introduceUser(user);
|
|
|
}
|
|
|
}
|
|
|
for(var i=0; i<channels.length; i++){
|
|
|
- uplink.syncChannel(channels[i]);
|
|
|
+ irc.uplink.syncChannel(channels[i]);
|
|
|
}
|
|
|
});
|
|
|
}
|
|
@@ -176,7 +175,7 @@ function makeTagsString(tags){
|
|
|
|
|
|
function ircMessage(data){
|
|
|
var msg = irc.parseLine(data);
|
|
|
- uplink.processMessage(msg);
|
|
|
+ irc.uplink.processMessage(msg);
|
|
|
}
|
|
|
|
|
|
function ircConnectionClosed(e){
|
|
@@ -228,13 +227,14 @@ var irc = {
|
|
|
'channels': channels,
|
|
|
'servers': servers,
|
|
|
'getChannel': getChannel,
|
|
|
+ 'uplink': null,
|
|
|
'setConnection': function(host, port, protocol){
|
|
|
- uplink = require('./protocol/' + protocol);
|
|
|
+ irc.uplink = require('./protocol/' + protocol);
|
|
|
me = new IRCserver;
|
|
|
me.setEvents(events);
|
|
|
me.introduce('serwisy.pirc.pl', '11K', 'Serwisy', 0, null);
|
|
|
servers.push(me);
|
|
|
- uplink.setHandlers({
|
|
|
+ irc.uplink.setHandlers({
|
|
|
send: ircSendData,
|
|
|
findServer: findServer,
|
|
|
findUser: findUser,
|
|
@@ -246,7 +246,7 @@ var irc = {
|
|
|
removeServer: removeServer,
|
|
|
findChannel: findChannel
|
|
|
});
|
|
|
- uplink.setSettings({
|
|
|
+ irc.uplink.setSettings({
|
|
|
ID: me.sid,
|
|
|
password: 'myservicespassword',
|
|
|
name: me.name,
|
|
@@ -256,9 +256,9 @@ var irc = {
|
|
|
maxUsers: 0
|
|
|
});
|
|
|
addInternalEvents();
|
|
|
- uplink.setEvents(events);
|
|
|
+ irc.uplink.setEvents(events);
|
|
|
connection = new net.Socket();
|
|
|
- connection.connect(port, host, uplink.connected.bind(this));
|
|
|
+ connection.connect(port, host, irc.uplink.connected.bind(this));
|
|
|
connection.on('data', ircDataReceived);
|
|
|
connection.on('close', ircConnectionClosed);
|
|
|
},
|
|
@@ -268,8 +268,9 @@ var irc = {
|
|
|
'makeUser': function(nick, ident, host, realname){
|
|
|
var user = new IRCuser;
|
|
|
user.setEvents(events);
|
|
|
- var uid = uplink.makeUid();
|
|
|
- user.introduce(nick, 0, Math.floor(new Date() / 1000).toString(10), ident, host, uid, null, '+SoB'/*TODO*/, null, null, null, realname, me);
|
|
|
+ var uid = irc.uplink.makeUid();
|
|
|
+ var umodes = { 'SERVICEUSER': true, 'BOT': true, 'OPER': true }; // TODO make it configurable
|
|
|
+ user.introduce(nick, 0, Math.floor(new Date() / 1000).toString(10), ident, host, uid, null, umodes, null, null, null, realname, me);
|
|
|
users.push(user);
|
|
|
return user;
|
|
|
},
|
|
@@ -438,7 +439,7 @@ var irc = {
|
|
|
ircmsg.args.push(currArg);
|
|
|
}
|
|
|
|
|
|
- ircmsg.sender = uplink.processSender(ircmsg.sender);
|
|
|
+ ircmsg.sender = irc.uplink.processSender(ircmsg.sender);
|
|
|
if(!ircmsg.sender){
|
|
|
return false;
|
|
|
}
|