1 var util
= require('util'),
2 EventBinder
= require('./eventbinder.js');
4 var IrcUser = function (irc_connection
, nick
) {
5 this.irc_connection
= irc_connection
;
12 whoisuser
: onWhoisUser
,
13 whoisaway
: onWhoisAway
,
14 whoisoperator
: onWhoisOperator
,
15 whoischannels
: onWhoisChannels
,
16 whoismodes
: onWhoisModes
,
17 whoisidle
: onWhoisIdle
,
18 whoisregnick
: onWhoisRegNick
,
19 whoisserver
: onWhoisServer
,
20 endofwhois
: onWhoisEnd
,
22 endofwhowas
: onWhoWasEnd
,
23 wasnosuchnick
: onWasNoSuchNick
,
25 ctcp_response
: onCtcpResponse
,
27 ctcp_request
: onCtcpRequest
,
30 EventBinder
.bindIrcEvents('user ' + this.nick
, this.irc_events
, this, irc_connection
);
34 module
.exports
= IrcUser
;
37 IrcUser
.prototype.dispose = function () {
38 EventBinder
.unbindIrcEvents('user ' + this.nick
, this.irc_events
, this.irc_connection
);
39 this.irc_connection
= undefined;
43 function onNick(event
) {
44 this.irc_connection
.clientEvent('nick', {
47 hostname
: event
.hostname
,
48 newnick
: event
.newnick
51 // TODO: uncomment when using an IrcUser per nick
52 //EventBinder.unbindIrcEvents('user ' + this.nick, this.irc_events, irc_connection);
53 //this.nick = event.newnick;
54 //EventBinder.bindIrcEvents('user ' + this.nick, this.irc_events, this, irc_connection);
57 function onAway(event
) {
58 this.irc_connection
.clientEvent('away', {
64 function onQuit(event
) {
65 this.irc_connection
.clientEvent('quit', {
68 hostname
: event
.hostname
,
69 message
: event
.trailing
73 function onWhoisUser(event
) {
74 this.irc_connection
.clientEvent('whois', {
83 function onWhoisAway(event
) {
84 this.irc_connection
.clientEvent('whois', {
86 away_reason
: event
.reason
,
91 function onWhoisServer(event
) {
92 this.irc_connection
.clientEvent('whois', {
94 irc_server
: event
.irc_server
,
95 server_info
: event
.server_info
,
100 function onWhoisOperator(event
) {
101 this.irc_connection
.clientEvent('whois', {
108 function onWhoisChannels(event
) {
109 this.irc_connection
.clientEvent('whois', {
116 function onWhoisModes(event
) {
117 this.irc_connection
.clientEvent('whois', {
124 function onWhoisIdle(event
) {
125 this.irc_connection
.clientEvent('whois', {
128 logon
: event
.logon
|| undefined,
133 function onWhoisRegNick(event
) {
134 this.irc_connection
.clientEvent('whois', {
141 function onWhoisEnd(event
) {
142 this.irc_connection
.clientEvent('whois', {
149 function onWhoWas(event
) {
150 this.irc_connection
.clientEvent('whowas', {
154 real_name
: event
.real_name
,
159 function onWasNoSuchNick(event
) {
160 this.irc_connection
.clientEvent('whowas', {
166 function onWhoWasEnd(event
) {
167 this.irc_connection
.clientEvent('whowas', {
173 function onNotice(event
) {
174 this.irc_connection
.clientEvent('notice', {
175 from_server
: event
.from_server
,
178 hostname
: event
.hostname
,
179 target
: event
.target
,
184 function onCtcpResponse(event
) {
185 this.irc_connection
.clientEvent('ctcp_response', {
188 hostname
: event
.hostname
,
189 channel
: event
.channel
,
194 function onPrivmsg(event
) {
195 this.irc_connection
.clientEvent('msg', {
198 hostname
: event
.hostname
,
199 channel
: event
.channel
,
204 function onCtcpRequest(event
) {
205 this.irc_connection
.clientEvent('ctcp_request', {
208 hostname
: event
.hostname
,
209 target
: event
.target
,
215 function onMode(event
) {
216 this.irc_connection
.clientEvent('mode', {
217 target
: event
.target
,