2 function IrcChannel(irc_connection
, name
) {
5 this.irc_connection
= irc_connection
;
8 // Helper for binding listeners
9 function bindEvent(event
, fn
) {
10 irc_connection
.on('channel:' + name
+ ':' + event
, function () {
11 fn
.apply(that
, arguments
);
15 bindEvent('join', this.onJoin
);
16 bindEvent('part', this.onPart
);
17 bindEvent('kick', this.onKick
);
18 bindEvent('quit', this.onQuit
);
20 bindEvent('privmsg', this.onMsg
);
21 bindEvent('notice', this.onNotice
);
22 bindEvent('ctcp_request', this.onCtcpRequest
);
23 bindEvent('ctcp_response', this.onCtcpResponse
);
25 bindEvent('topic', this.onTopic
)
27 bindEvent('nicklist', this.onNicklist
);
28 bindEvent('nicklistEnd', this.onNicklistEnd
);
32 IrcChannel
.prototype.clientEvent = function (event_name
, event
) {
33 event
.server
= this.irc_connection
.con_num
;
34 this.irc_connection
.state
.sendIrcCommand(event_name
, event
);
38 IrcChannel
.prototype.onJoin = function (event
) {
39 this.clientEvent('join', {
43 hostname
: event
.hostname
,
46 // If we've just joined this channel then requesr=t get a nick list
47 if (event
.nick
=== this.irc_connection
.nick
) {
48 this.irc_connection
.write('NAMES ' + channel
);
53 IrcChannel
.prototype.onPart = function (event
) {
54 this.clientEvent('part', {
57 hostname
: event
.hostname
,
59 message
: event
.message
64 IrcChannel
.prototype.onKick = function (event
) {
65 this.client
.sendIrcCommand('kick', {
66 kicked
: event
.kicked
, // Nick of the kicked
67 nick
: event
.nick
, // Nick of the kicker
69 hostname
: event
.hostname
,
71 message
: event
.message
76 IrcChannel
.prototype.onQuit = function (event
) {
77 this.clientEvent('quit', {
80 hostname
: event
.hostname
,
81 message
: event
.message
86 IrcChannel
.prototype.onMsg = function (event
) {
87 this.clientEvent('msg', {
90 hostname
: event
.hostname
,
97 IrcChannel
.prototype.onNotice = function (event
) {
98 this.clientEvent('msg', {
101 hostname
: event
.hostname
,
108 IrcChannel
.prototype.onCtcpRequest = function (event
) {
109 this.clientEvent('ctcp_request', {
112 hostname
: event
.hostname
,
113 target
: event
.target
,
120 IrcChannel
.prototype.onCtcpResponse = function (event
) {
121 this.clientEvent('ctcp_response', {
124 hostname
: event
.hostname
,
125 target
: event
.target
,
132 // TODO: Split event.users into batches of 50
133 IrcChannel
.prototype.onNicklist = function (event
) {
134 this.clientEvent('userlist', {
141 IrcChannel
.prototype.onNicklistEnd = function (event
) {
142 this.clientEvent('userlist_end', {
149 IrcChannel
.prototype.onTopic = function (event
) {
150 this.clientEvent('topic', {
160 channel:#channel:event
169 Joining channel #kiwiirc:
170 channel:#kiwiirc:join
174 channel:#kiwiirc:privmsg