1 var EventBinder
= require('./eventbinder.js');
3 var IrcUser = function (irc_connection
, nick
) {
4 this.irc_connection
= irc_connection
;
11 whoisuser
: onWhoisUser
,
12 whoisaway
: onWhoisAway
,
13 whoisoperator
: onWhoisOperator
,
14 whoischannels
: onWhoisChannels
,
15 whoismodes
: onWhoisModes
,
16 whoisidle
: onWhoisIdle
,
17 whoisregnick
: onWhoisRegNick
,
18 whoisserver
: onWhoisServer
,
19 whoishost
: onWhoisHost
,
20 whoissecure
: onWhoisSecure
,
21 whoisaccount
: onWhoisAccount
,
22 whoishelpop
: onWhoisHelpOp
,
24 whoisswhois
: onWhoisSwhois
,
25 endofwhois
: onWhoisEnd
,
27 endofwhowas
: onWhoWasEnd
,
28 wasnosuchnick
: onWasNoSuchNick
,
30 ctcp_response
: onCtcpResponse
,
33 ctcp_request
: onCtcpRequest
,
37 EventBinder
.bindIrcEvents('user ' + this.nick
, this.irc_events
, this, irc_connection
);
41 module
.exports
= IrcUser
;
44 IrcUser
.prototype.dispose = function () {
45 EventBinder
.unbindIrcEvents('user ' + this.nick
, this.irc_events
, this.irc_connection
);
46 this.irc_connection
= undefined;
50 function onNick(event
) {
51 this.irc_connection
.clientEvent('nick', {
54 hostname
: event
.hostname
,
55 newnick
: event
.newnick
,
59 // TODO: uncomment when using an IrcUser per nick
60 //EventBinder.unbindIrcEvents('user ' + this.nick, this.irc_events, irc_connection);
61 //this.nick = event.newnick;
62 //EventBinder.bindIrcEvents('user ' + this.nick, this.irc_events, this, irc_connection);
65 function onAway(event
) {
66 this.irc_connection
.clientEvent('away', {
73 function onQuit(event
) {
74 this.irc_connection
.clientEvent('quit', {
77 hostname
: event
.hostname
,
78 message
: event
.message
,
83 function onWhoisUser(event
) {
84 this.irc_connection
.clientEvent('whois', {
93 function onWhoisAway(event
) {
94 this.irc_connection
.clientEvent('whois', {
96 away_reason
: event
.reason
,
101 function onWhoisServer(event
) {
102 this.irc_connection
.clientEvent('whois', {
104 irc_server
: event
.irc_server
,
105 server_info
: event
.server_info
,
110 function onWhoisOperator(event
) {
111 this.irc_connection
.clientEvent('whois', {
118 function onWhoisChannels(event
) {
119 this.irc_connection
.clientEvent('whois', {
126 function onWhoisModes(event
) {
127 this.irc_connection
.clientEvent('whois', {
134 function onWhoisIdle(event
) {
135 this.irc_connection
.clientEvent('whois', {
138 logon
: event
.logon
|| undefined,
143 function onWhoisRegNick(event
) {
144 this.irc_connection
.clientEvent('whois', {
151 function onWhoisHost(event
) {
152 this.irc_connection
.clientEvent('whois', {
159 function onWhoisSecure(event
) {
160 this.irc_connection
.clientEvent('whois', {
162 msg
: 'Using a secure connection',
167 function onWhoisAccount(event
) {
168 this.irc_connection
.clientEvent('whois', {
170 msg
: 'Logged in as ' + event
.account
,
175 function onWhoisHelpOp(event
) {
176 this.irc_connection
.clientEvent('whois', {
183 function onWhoisBot(event
) {
184 this.irc_connection
.clientEvent('whois', {
191 function onWhoisSwhois(event
) {
192 this.irc_connection
.clientEvent('whois', {
199 function onWhoisEnd(event
) {
200 this.irc_connection
.clientEvent('whois', {
207 function onWhoWas(event
) {
208 this.irc_connection
.clientEvent('whowas', {
211 hostname
: event
.host
,
212 real_name
: event
.real_name
,
217 function onWasNoSuchNick(event
) {
218 this.irc_connection
.clientEvent('whowas', {
224 function onWhoWasEnd(event
) {
225 this.irc_connection
.clientEvent('whowas', {
231 function onNotice(event
) {
233 global
.modules
.emit('irc user notice', {
234 connection
: this.irc_connection
,
238 that
.irc_connection
.clientEvent('message', {
240 from_server
: event
.from_server
,
243 hostname
: event
.hostname
,
244 target
: event
.target
,
251 function onCtcpResponse(event
) {
252 this.irc_connection
.clientEvent('ctcp_response', {
255 hostname
: event
.hostname
,
256 target
: event
.target
,
262 function onPrivmsg(event
) {
265 global
.modules
.emit('irc message', {
266 connection
: this.irc_connection
,
270 that
.irc_connection
.clientEvent('message', {
274 hostname
: event
.hostname
,
275 target
: event
.target
,
282 function onAction(event
) {
285 global
.modules
.emit('irc action', {
286 connection
: this.irc_connection
,
290 that
.irc_connection
.clientEvent('message', {
294 hostname
: event
.hostname
,
295 target
: event
.target
,
302 function onCtcpRequest(event
) {
303 this.irc_connection
.clientEvent('ctcp_request', {
306 hostname
: event
.hostname
,
307 target
: event
.target
,
314 function onMode(event
) {
315 this.irc_connection
.clientEvent('mode', {
316 target
: event
.target
,
323 function onWallops(event
) {
324 this.irc_connection
.clientEvent('wallops', {
327 hostname
: event
.hostname
,