2 function IrcChannel(irc_connection
, name
) {
3 this.irc_connection
= irc_connection
;
7 this.ban_list_buffer
= [];
11 IrcChannel
.prototype.dispose = function (){
13 this.irc_connection
= undefined;
17 IrcChannel
.prototype.bindEvents = function() {
20 // If we havent generated an event listing yet, do so now
21 if (!this.irc_events
) {
29 ctcp_request
: onCtcpRequest
,
30 ctcp_response
: onCtcpResponse
,
33 nicklistEnd
: onNicklistEnd
,
35 banlist_end
: onBanListEnd
,
36 topicsetby
: onTopicSetby
40 this.irc_events
.forEach(function(fn
, event_name
, irc_events
){
41 // Bind the event to `that` context, storing it with the event listing
42 if (!irc_events
[event_name
].bound_fn
) {
43 irc_events
[event_name
].bound_fn
= fn
.bind(that
);
46 this.irc_connection
.on(event_name
, irc_events
[event_name
].bound_fn
);
51 IrcChannel
.prototype.unbindEvents = function() {
52 this.irc_events
.forEach(function(fn
, event_name
, irc_events
){
53 if (irc_events
[event_name
].bound_fn
) {
54 this.irc_connection
.removeListener(event_name
, irc_events
[event_name
].bound_fn
);
63 function onJoin(event
) {
64 this.irc_connection
.sendIrcCommand('join', {
68 hostname
: event
.hostname
,
71 // If we've just joined this channel then request get a nick list
72 if (event
.nick
=== this.irc_connection
.nick
) {
73 this.irc_connection
.write('NAMES ' + channel
);
78 function onPart(event
) {
79 this.irc_connection
.sendIrcCommand('part', {
82 hostname
: event
.hostname
,
84 message
: event
.message
91 function onKick(event
) {
92 this.irc_connection
.sendIrcCommand('kick', {
93 kicked
: event
.kicked
, // Nick of the kicked
94 nick
: event
.nick
, // Nick of the kicker
96 hostname
: event
.hostname
,
98 message
: event
.message
105 function onQuit(event
) {
106 this.irc_connection
.sendIrcCommand('quit', {
109 hostname
: event
.hostname
,
110 message
: event
.message
117 function onMsg(event
) {
118 this.irc_connection
.sendIrcCommand('msg', {
121 hostname
: event
.hostname
,
128 function onNotice(event
) {
129 this.irc_connection
.sendIrcCommand('msg', {
132 hostname
: event
.hostname
,
139 function onCtcpRequest(event
) {
140 this.irc_connection
.sendIrcCommand('ctcp_request', {
143 hostname
: event
.hostname
,
144 target
: event
.target
,
151 function onCtcpResponse(event
) {
152 this.irc_connection
.sendIrcCommand('ctcp_response', {
155 hostname
: event
.hostname
,
156 target
: event
.target
,
163 // TODO: Split event.users into batches of 50
164 function onNicklist(event
) {
165 this.irc_connection
.sendIrcCommand('userlist', {
172 function onNicklistEnd(event
) {
173 this.irc_connection
.sendIrcCommand('userlist_end', {
180 function onTopic(event
) {
181 this.irc_connection
.sendIrcCommand('topic', {
189 function onBanList(event
) {
190 this.ban_list_buffer
.push(event
);
193 function onBanListEnd(event
) {
195 this.ban_list_buffer
.forEach(function (ban
) {
196 that
.irc_connection
.clientEvent('banlist', ban
);
198 this.ban_list_buffer
= [];
201 function onTopic(event
) {
202 this.irc_connection
.clientEvent('topic', {
203 channel
: event
.channel
,
208 function onTopicSetBy(event
) {
209 this.irc_connection
.clientEvent('topicsetby', {
211 channel
: event
.channel
,
220 channel:#channel:event
229 Joining channel #kiwiirc:
230 channel:#kiwiirc:join
234 channel:#kiwiirc:privmsg