Channel object start
authorDarren <darren@darrenwhitlen.com>
Wed, 23 Jan 2013 17:45:51 +0000 (17:45 +0000)
committerDarren <darren@darrenwhitlen.com>
Thu, 31 Jan 2013 14:58:42 +0000 (14:58 +0000)
server/client.js
server/irc/channel.js [new file with mode: 0644]

index 36edf0c0254088b4a797f7c90b48cd172a24bb31..428878c8467d5a6f9bb35cc9b590bdfa33fe860d 100755 (executable)
@@ -135,6 +135,7 @@ function kiwiCommand(command, callback) {
 
                 var con_num = this.next_connection++;
                 this.irc_connections[con_num] = con;
+                con.con_num = con_num;
 
                 var irc_commands = new IrcCommands(con, con_num, this);
                 irc_commands.bindEvents();
diff --git a/server/irc/channel.js b/server/irc/channel.js
new file mode 100644 (file)
index 0000000..5fa18b6
--- /dev/null
@@ -0,0 +1,76 @@
+
+function IrcChannel(irc_connection, name) {
+       this.irc_connection = irc_connection;
+       this.name = name;
+
+       // Helper for binding listeners
+       function bindEvent(event, fn) {
+               irc_connection.on('channel:' + name + ':' + event, fn);
+       }
+
+       bindEvent('join', this.onJoin);
+       bindEvent('part', this.onPart);
+       bindEvent('kick', this.onKick);
+       bindEvent('quit', this.onQuit);
+
+       bindEvent('privmsg', this.onMsg);
+       bindEvent('notice', this.onNotice);
+       bindEvent('ctcp', this.onCtcp);
+}
+
+
+// TODO: Move this into irc_connection
+ircChannel.prototype.clientEvent = function (event_name, event) {
+       event.server = this.irc_connection.con_num;
+       this.client.sendIrcCommand(event_name, event);
+};
+
+
+IrcChannel.prototype.onJoin = function (event) {
+       this.clientEvent('join', {
+               channel: this.name,
+               nick: command.nick,
+               ident: command.ident,
+               hostname: command.hostname,
+       });
+
+       // If we've just joined this channel then requesr=t get a nick list
+    if (event.nick === this.irc_connection.nick) {
+        this.irc_connection.write('NAMES ' + channel);
+    }
+};
+
+
+IrcChannel.prototype.removeUser = function (event) {
+       type = type || 'part';
+
+       this.emit('')
+}
+
+
+/*
+server:event
+server:*
+channel:#channel:event
+channel:*:event
+user:event
+user:*
+
+
+Server disconnected:
+       server:disconnect
+       server:*
+
+Joining channel #kiwiirc:
+       channel:#kiwiirc:join
+       channel:*:join
+
+Channel message:
+       channel:#kiwiirc:privmsg
+       channel:*:privmsg
+
+Private message:
+       user:privmsg
+       user:*
+
+*/
\ No newline at end of file