Make whois work

This commit is contained in:
Pavel Djundik 2016-03-09 10:27:01 +02:00 committed by Maxime Poulin
parent 28ae544b2a
commit b6993f6e37
2 changed files with 36 additions and 20 deletions

View File

@ -1,26 +1,35 @@
<div> <div>
<a href="#" class="user" data-name="{{whois.nickname}}">{{whois.nickname}}</a> <a href="#" class="user" data-name="{{whois.nick}}">{{whois.nick}}</a>
<i class="hostmask">({{whois.username}}@{{whois.hostname}})</i>: <i class="hostmask">({{whois.user}}@{{whois.host}})</i>:
<b>{{whois.realname}}</b> <b>{{whois.realname}}</b>
</div> </div>
{{#if whois.account}}
<div>
<a href="#" class="user" data-name="{{whois.nickname}}">{{whois.nick}}</a>
is logged in as <b>{{whois.account}}</b>
</div>
{{/if}}
{{#if whois.channels}} {{#if whois.channels}}
<div> <div>
<a href="#" class="user" data-name="{{whois.nickname}}">{{whois.nickname}}</a> <a href="#" class="user" data-name="{{whois.nickname}}">{{whois.nick}}</a>
is on the following channels: is on the following channels: {{{parse whois.channels}}}
{{#each whois.channels}}
{{{parse this}}}
{{/each}}
</div> </div>
{{/if}} {{/if}}
{{#if whois.server}} {{#if whois.server}}
<div> <div>
<a href="#" class="user" data-name="{{whois.nickname}}">{{whois.nickname}}</a> <a href="#" class="user" data-name="{{whois.nickname}}">{{whois.nick}}</a>
is connected to {{whois.server}} is connected to {{whois.server}} <i>({{whois.server_info}})</i>
</div>
{{/if}}
{{#if whois.secure}}
<div>
<a href="#" class="user" data-name="{{whois.nickname}}">{{whois.nick}}</a>
is using a secure connection
</div> </div>
{{/if}} {{/if}}
{{#if whois.away}} {{#if whois.away}}
<div> <div>
<a href="#" class="user" data-name="{{whois.nickname}}">{{whois.nickname}}</a> <a href="#" class="user" data-name="{{whois.nickname}}">{{whois.nick}}</a>
is away <i>({{whois.away}})</i> is away <i>({{whois.away}})</i>
</div> </div>
{{/if}} {{/if}}

View File

@ -4,15 +4,12 @@ var Msg = require("../../models/msg");
module.exports = function(irc, network) { module.exports = function(irc, network) {
var client = this; var client = this;
irc.on("whois", function(err, data) { irc.on("whois", function(data) {
if (data === null) { var chan = _.find(network.channels, {name: data.nick});
return;
}
var chan = _.find(network.channels, {name: data.nickname});
if (typeof chan === "undefined") { if (typeof chan === "undefined") {
chan = new Chan({ chan = new Chan({
type: Chan.Type.QUERY, type: Chan.Type.QUERY,
name: data.nickname name: data.nick
}); });
network.channels.push(chan); network.channels.push(chan);
client.emit("join", { client.emit("join", {
@ -20,10 +17,20 @@ module.exports = function(irc, network) {
chan: chan chan: chan
}); });
} }
var msg = new Msg({
type: Msg.Type.WHOIS, var msg;
whois: data if (data.error) {
}); msg = new Msg({
type: Msg.Type.ERROR,
text: "No such nick: " + data.nick
});
} else {
msg = new Msg({
type: Msg.Type.WHOIS,
whois: data
});
}
chan.messages.push(msg); chan.messages.push(msg);
client.emit("msg", { client.emit("msg", {
chan: chan.id, chan: chan.id,