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
44 function onJoin(event
) {
45 this.irc_connection
.sendIrcCommand('join', {
49 hostname
: event
.hostname
,
52 // If we've just joined this channel then request get a nick list
53 if (event
.nick
=== this.irc_connection
.nick
) {
54 this.irc_connection
.write('NAMES ' + channel
);
59 function onPart(event
) {
60 this.irc_connection
.sendIrcCommand('part', {
63 hostname
: event
.hostname
,
65 message
: event
.message
72 function onKick(event
) {
73 this.irc_connection
.sendIrcCommand('kick', {
74 kicked
: event
.kicked
, // Nick of the kicked
75 nick
: event
.nick
, // Nick of the kicker
77 hostname
: event
.hostname
,
79 message
: event
.message
86 function onQuit(event
) {
87 this.irc_connection
.sendIrcCommand('quit', {
90 hostname
: event
.hostname
,
91 message
: event
.message
98 function onMsg(event
) {
99 this.irc_connection
.sendIrcCommand('msg', {
102 hostname
: event
.hostname
,
109 function onNotice(event
) {
110 this.irc_connection
.sendIrcCommand('msg', {
113 hostname
: event
.hostname
,
120 function onCtcpRequest(event
) {
121 this.irc_connection
.sendIrcCommand('ctcp_request', {
124 hostname
: event
.hostname
,
125 target
: event
.target
,
132 function onCtcpResponse(event
) {
133 this.irc_connection
.sendIrcCommand('ctcp_response', {
136 hostname
: event
.hostname
,
137 target
: event
.target
,
144 // TODO: Split event.users into batches of 50
145 function onNicklist(event
) {
146 this.irc_connection
.sendIrcCommand('userlist', {
153 function onNicklistEnd(event
) {
154 this.irc_connection
.sendIrcCommand('userlist_end', {
161 function onTopic(event
) {
162 this.irc_connection
.sendIrcCommand('topic', {
170 function onBanList(event
) {
171 this.ban_list_buffer
.push(event
);
174 function onBanListEnd(event
) {
176 this.ban_list_buffer
.forEach(function (ban
) {
177 that
.irc_connection
.clientEvent('banlist', ban
);
179 this.ban_list_buffer
= [];
182 function onTopic(event
) {
183 this.irc_connection
.clientEvent('topic', {
184 channel
: event
.channel
,
189 function onTopicSetBy(event
) {
190 this.irc_connection
.clientEvent('topicsetby', {
192 channel
: event
.channel
,
201 channel:#channel:event
210 Joining channel #kiwiirc:
211 channel:#kiwiirc:join
215 channel:#kiwiirc:privmsg