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 whoisoperator
: onWhoisOperator
,
14 whoischannels
: onWhoisChannels
,
15 whoismodes
: onWhoisModes
,
16 whoisidle
: onWhoisIdle
,
17 whoisregnick
: onWhoisRegNick
,
18 endofwhois
: onWhoisEnd
,
20 ctcp_response
: onCtcpResponse
,
22 ctcp_request
: onCtcpRequest
,
25 EventBinder
.bindIrcEvents('user ' + this.nick
, this.irc_events
, this, irc_connection
);
29 module
.exports
= IrcUser
;
32 IrcUser
.prototype.dispose = function () {
33 EventBinder
.unbindIrcEvents('user ' + this.nick
, this.irc_events
, this.irc_connection
);
34 this.irc_connection
= undefined;
38 function onNick(event
) {
39 this.irc_connection
.clientEvent('nick', {
42 hostname
: event
.hostname
,
43 newnick
: event
.newnick
46 // TODO: uncomment when using an IrcUser per nick
47 //EventBinder.unbindIrcEvents('user ' + this.nick, this.irc_events, irc_connection);
48 //this.nick = event.newnick;
49 //EventBinder.bindIrcEvents('user ' + this.nick, this.irc_events, this, irc_connection);
52 function onAway(event
) {
53 this.irc_connection
.clientEvent('away', {
59 function onQuit(event
) {
60 this.irc_connection
.clientEvent('quit', {
63 hostname
: event
.hostname
,
64 message
: event
.trailing
68 function onWhoisUser(event
) {
69 this.irc_connection
.clientEvent('whois', {
78 function onWhoisServer(event
) {
79 this.irc_connection
.clientEvent('whois', {
81 irc_server
: event
.irc_server
,
86 function onWhoisOperator(event
) {
87 this.irc_connection
.clientEvent('whois', {
94 function onWhoisChannels(event
) {
95 this.irc_connection
.clientEvent('whois', {
102 function onWhoisModes(event
) {
103 this.irc_connection
.clientEvent('whois', {
110 function onWhoisIdle(event
) {
111 this.irc_connection
.clientEvent('whois', {
114 logon
: event
.logon
|| undefined,
119 function onWhoisRegNick(event
) {
120 this.irc_connection
.clientEvent('whois', {
127 function onWhoisEnd(event
) {
128 this.irc_connection
.clientEvent('whois', {
135 function onNotice(event
) {
136 this.irc_connection
.clientEvent('notice', {
139 hostname
: event
.hostname
,
140 target
: event
.target
,
145 function onCtcpResponse(event
) {
146 this.irc_connection
.clientEvent('ctcp_response', {
149 hostname
: event
.hostname
,
150 channel
: event
.channel
,
155 function onPrivmsg(event
) {
156 this.irc_connection
.clientEvent('msg', {
159 hostname
: event
.hostname
,
160 channel
: event
.channel
,
165 function onCtcpRequest(event
) {
166 this.irc_connection
.clientEvent('ctcp_request', {
169 hostname
: event
.hostname
,
170 target
: event
.target
,
176 function onMode(event
) {
177 this.irc_connection
.clientEvent('mode', {
178 target
: event
.target
,