1 var util
= require('util'),
2 Binder
= require('./binder.js');
4 function IrcChannel(irc_connection
, name
) {
5 this.irc_connection
= irc_connection
;
8 this.scope
= 'channel:' + name
;
12 this.ban_list_buffer
= [];
15 util
.inherits(IrcChannel
, Binder
);
17 module
.exports
= IrcChannel
;
20 IrcChannel
.prototype.dispose = function (){
22 this.irc_connection
= undefined;
26 IrcChannel
.prototype.irc_events
= {
33 ctcp_request
: onCtcpRequest
,
34 ctcp_response
: onCtcpResponse
,
37 nicklistEnd
: onNicklistEnd
,
39 banlist_end
: onBanListEnd
,
40 topicsetby
: onTopicSetby
,
45 function onJoin(event
) {
46 this.irc_connection
.sendIrcCommand('join', {
50 hostname
: event
.hostname
,
53 // If we've just joined this channel then request get a nick list
54 if (event
.nick
=== this.irc_connection
.nick
) {
55 this.irc_connection
.write('NAMES ' + channel
);
60 function onPart(event
) {
61 this.irc_connection
.sendIrcCommand('part', {
64 hostname
: event
.hostname
,
66 message
: event
.message
73 function onKick(event
) {
74 this.irc_connection
.sendIrcCommand('kick', {
75 kicked
: event
.kicked
, // Nick of the kicked
76 nick
: event
.nick
, // Nick of the kicker
78 hostname
: event
.hostname
,
80 message
: event
.message
87 function onQuit(event
) {
88 this.irc_connection
.sendIrcCommand('quit', {
91 hostname
: event
.hostname
,
92 message
: event
.message
99 function onMsg(event
) {
100 this.irc_connection
.sendIrcCommand('msg', {
103 hostname
: event
.hostname
,
110 function onNotice(event
) {
111 this.irc_connection
.sendIrcCommand('msg', {
114 hostname
: event
.hostname
,
121 function onCtcpRequest(event
) {
122 this.irc_connection
.sendIrcCommand('ctcp_request', {
125 hostname
: event
.hostname
,
126 target
: event
.target
,
133 function onCtcpResponse(event
) {
134 this.irc_connection
.sendIrcCommand('ctcp_response', {
137 hostname
: event
.hostname
,
138 target
: event
.target
,
145 // TODO: Split event.users into batches of 50
146 function onNicklist(event
) {
147 this.irc_connection
.sendIrcCommand('userlist', {
154 function onNicklistEnd(event
) {
155 this.irc_connection
.sendIrcCommand('userlist_end', {
162 function onTopic(event
) {
163 this.irc_connection
.sendIrcCommand('topic', {
171 function onBanList(event
) {
172 this.ban_list_buffer
.push(event
);
175 function onBanListEnd(event
) {
177 this.ban_list_buffer
.forEach(function (ban
) {
178 that
.irc_connection
.clientEvent('banlist', ban
);
180 this.ban_list_buffer
= [];
183 function onTopic(event
) {
184 this.irc_connection
.clientEvent('topic', {
185 channel
: event
.channel
,
190 function onTopicSetBy(event
) {
191 this.irc_connection
.clientEvent('topicsetby', {
193 channel
: event
.channel
,
198 function onMode(event
) {
199 this.irc_connection
.clientEvent('mode', {
200 target
: event
.target
,
210 channel:#channel:event
219 Joining channel #kiwiirc:
220 channel:#kiwiirc:join
224 channel:#kiwiirc:privmsg