Permalink
Browse files

Real Name and Away message configuration. Automatically setting of yo…

…ur away when you are disconnected.
  • Loading branch information...
1 parent 10a3cc5 commit 7cb737576c1f9e74d9cc08914932602a3d6b6c02 @ericbarch ericbarch committed Jul 3, 2012
Showing with 36 additions and 5 deletions.
  1. +1 −1 assets/js/views/chat.js
  2. +5 −1 assets/js/views/overview.js
  3. +6 −1 lib/irclink.js
  4. +2 −0 lib/models.js
  5. +3 −1 lib/restore.js
  6. +11 −1 lib/socket.js
  7. +8 −0 views/templates.jade
View
@@ -120,7 +120,7 @@ var ChatView = Backbone.View.extend({
match = true;
//We decide whether or not to add colon
if (sentence.length === 1) {
- $('#chat-input').val(sentence.join(' ') + ":");
+ $('#chat-input').val(sentence.join(' ') + ": ");
} else {
$('#chat-input').val(sentence.join(' '));
}
@@ -50,6 +50,8 @@ var OverviewView = Backbone.View.extend({
var server = $('#connect-server').val();
var nick = $('#connect-nick').val();
var port = $('#connect-port').val();
+ var away = $('#connect-away').val();
+ var realName = $('#connect-realName').val();
var secure = $('#connect-secure').is(':checked');
var selfSigned = $('#connect-selfSigned').is(':checked');
var rejoin = $('#connect-rejoin').is(':checked');
@@ -72,10 +74,12 @@ var OverviewView = Backbone.View.extend({
var connectInfo = {
nick: nick,
server: server,
- port: port,
+ port: port,
secure: secure,
selfSigned: selfSigned,
rejoin: rejoin,
+ away: away,
+ realName: realName,
password: password
};
View
@@ -8,10 +8,15 @@ var Channel = mongoose.model('Channel');
var Message = mongoose.model('Message');
// Constructor
-var IRCLink = function(hostname, port, ssl, selfSigned, nick, realName, password, rejoin, channels) {
+var IRCLink = function(hostname, port, ssl, selfSigned, nick, realName, password, rejoin, away, channels) {
this.sockets = new Array();
this.server = hostname;
+ if (away === undefined || away == '')
+ this.away = 'AFK';
+ else
+ this.away = away;
+
if (channels === undefined || !rejoin)
var channels = new Array();
View
@@ -15,6 +15,8 @@ module.exports = function() {
port: Number,
ssl: Boolean,
rejoin: Boolean,
+ away: String,
+ realName: String,
selfSigned: Boolean,
channels: [String],
nick: String,
View
@@ -11,9 +11,11 @@ module.exports = function (connections) {
// restore connections
Connection.find({},function(err, docs){
docs.forEach(function(doc){
- var connection = new IRCLink(doc.hostname, doc.port, doc.ssl, doc.selfSigned, doc.nick, doc.nick, doc.password, doc.rejoin, doc.channels);
+ var connection = new IRCLink(doc.hostname, doc.port, doc.ssl, doc.selfSigned, doc.nick, doc.realName, doc.password, doc.rejoin, doc.away, doc.channels);
connection.associateUser(doc.user);
connections[doc.user] = connection;
+ // set ourselves as away
+ connection.client.send('AWAY', doc.away);
});
});
}
View
@@ -57,7 +57,7 @@ module.exports = function(socket, connections) {
connection = connections[current_user.username];
}
if(connection === undefined) {
- connection = new IRCLink(data.server, data.port, data.secure, data.selfSigned, data.nick, data.nick, data.password, data.rejoin);
+ connection = new IRCLink(data.server, data.port, data.secure, data.selfSigned, data.nick, data.realName, data.password, data.rejoin, data.away);
// save this connection
if(current_user){
@@ -69,6 +69,8 @@ module.exports = function(socket, connections) {
port: data.port || (data.secure ? 6697 : 6667),
ssl: data.secure,
rejoin: data.rejoin,
+ away: data.away,
+ realName: data.realName,
selfSigned: data.selfSigned,
channels: data.channels,
nick: data.nick,
@@ -81,6 +83,10 @@ module.exports = function(socket, connections) {
socket.emit('restore_connection', {nick: connection.client.nick,
server: connection.client.opt.server, channels: connection.client.chans});
connection.clearUnreads();
+
+ // set ourselves as not being away
+ if (connection.sockets.length == 0)
+ connection.client.send('AWAY');
}
// register this socket with our user's IRC connection
@@ -150,6 +156,10 @@ module.exports = function(socket, connections) {
// keep the session alive, remove this socket, and clear unreads
connection.removeSocket(socket);
connection.clearUnreads();
+
+ // set ourselves as away
+ if (connection.sockets.length == 0)
+ connection.client.send('AWAY', connection.away);
}
});
View
@@ -59,6 +59,14 @@ script(id="overview_connection", type="text/html")
.controls
input#connect-nick(type="text")
.control-group
+ label(for="connect-realName") Real Name
+ .controls
+ input#connect-realName(type="text")
+ .control-group
+ label(for="connect-away") Away Message
+ .controls
+ input#connect-away(type="text", placeholder="AFK")
+ .control-group
label(for="connect-password") Password
.controls
input#connect-password(type="password")

0 comments on commit 7cb7375

Please sign in to comment.