Added whois
This commit is contained in:
parent
c3aee3d025
commit
9119555f44
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +1,2 @@
|
|||||||
node_modules/
|
node_modules/
|
||||||
|
!node_modules/slate-irc
|
||||||
|
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
[submodule "node_modules/slate-irc"]
|
||||||
|
path = node_modules/slate-irc
|
||||||
|
url = http://github.com/erming/slate-irc
|
@ -194,6 +194,9 @@ h2 {
|
|||||||
line-height: 1.4em;
|
line-height: 1.4em;
|
||||||
padding: 0 6px;
|
padding: 0 6px;
|
||||||
}
|
}
|
||||||
|
#chat .message div {
|
||||||
|
display: inline;
|
||||||
|
}
|
||||||
#chat .message .time {
|
#chat .message .time {
|
||||||
color: #bbb;
|
color: #bbb;
|
||||||
}
|
}
|
||||||
|
@ -109,9 +109,9 @@
|
|||||||
<script type="text/html" id="message">
|
<script type="text/html" id="message">
|
||||||
{{#messages}}
|
{{#messages}}
|
||||||
<div class="message {{type}}">
|
<div class="message {{type}}">
|
||||||
<span class="time">{{time}}</span>
|
<div class="time">{{time}}</div>
|
||||||
<a href="{{from}}" class="user">{{mode}}{{from}}</a>
|
<div class="user">{{from}}</div>
|
||||||
<span class="text">{{type}} {{message}}</span>
|
<div class="text">{{type}} {{message}}</div>
|
||||||
</div>
|
</div>
|
||||||
{{/messages}}
|
{{/messages}}
|
||||||
</script>
|
</script>
|
||||||
|
@ -31,7 +31,7 @@ $(function() {
|
|||||||
var html = "";
|
var html = "";
|
||||||
var partials = {
|
var partials = {
|
||||||
users: render("#user"),
|
users: render("#user"),
|
||||||
messages: render("#message")
|
messages: render("#message"),
|
||||||
};
|
};
|
||||||
json.forEach(function(network) {
|
json.forEach(function(network) {
|
||||||
html += render("#window", network, partials);
|
html += render("#window", network, partials);
|
||||||
|
@ -40,7 +40,7 @@ models.Message = Backbone.Model.extend({
|
|||||||
defaults: {
|
defaults: {
|
||||||
type: "",
|
type: "",
|
||||||
time: "",
|
time: "",
|
||||||
from: "",
|
from: "-!-",
|
||||||
message: "",
|
message: "",
|
||||||
},
|
},
|
||||||
initialize: function() {
|
initialize: function() {
|
||||||
|
101
lib/server.js
101
lib/server.js
@ -59,8 +59,8 @@ function connect(host) {
|
|||||||
client.user("t_user", "temp user");
|
client.user("t_user", "temp user");
|
||||||
|
|
||||||
events.forEach(function(e) {
|
events.forEach(function(e) {
|
||||||
client.on(e, function(data) {
|
client.on(e, function() {
|
||||||
event.apply(network, [e, data]);
|
event.apply(network, [e, arguments]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -127,6 +127,16 @@ function input(json) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case "query":
|
||||||
|
case "whois":
|
||||||
|
if (client && args[1]) {
|
||||||
|
client["whois"](args[1]);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "kick":
|
||||||
|
break;
|
||||||
|
|
||||||
case "quit":
|
case "quit":
|
||||||
case "disconnect":
|
case "disconnect":
|
||||||
networks.remove(network);
|
networks.remove(network);
|
||||||
@ -142,10 +152,10 @@ function event(event, data) {
|
|||||||
switch (event) {
|
switch (event) {
|
||||||
|
|
||||||
case "join":
|
case "join":
|
||||||
var chan = channels.findWhere({name: data.channel}) || channels.add({name: data.channel});
|
var chan = channels.findWhere({name: data[0].channel}) || channels.add({name: data[0].channel});
|
||||||
chan.addUser({name: data.nick});
|
chan.addUser({name: data[0].nick});
|
||||||
chan.addMessage({
|
chan.addMessage({
|
||||||
from: data.nick,
|
from: data[0].nick,
|
||||||
type: "join",
|
type: "join",
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
@ -155,53 +165,65 @@ function event(event, data) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case "message":
|
case "message":
|
||||||
var chan = channels.findWhere({name: data.to}) || channels.add({type: "query", name: data.from});
|
var chan = channels.findWhere({name: data[0].to}) || channels.add({type: "query", name: data[0].from});
|
||||||
chan.addMessage({
|
chan.addMessage({
|
||||||
from: data.from,
|
from: data[0].from,
|
||||||
message: data.message
|
message: data[0].message
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "names":
|
case "names":
|
||||||
var chan = channels.findWhere({name: data.channel});
|
var chan = channels.findWhere({name: data[0].channel});
|
||||||
chan.get("users").reset(_.map(data.names, function(n) { return {name: n}; }));
|
chan.get("users").reset(
|
||||||
|
_.map(data[0].names, function(n) {
|
||||||
|
return {name: n};
|
||||||
|
})
|
||||||
|
);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "nick":
|
case "nick":
|
||||||
|
if (data[0].new == this.get("client").me) {
|
||||||
|
channels.first().addMessage({
|
||||||
|
message: "You're now known as " + data[0]["new"],
|
||||||
|
});
|
||||||
|
}
|
||||||
channels.each(function(chan) {
|
channels.each(function(chan) {
|
||||||
var users = chan.get("users");
|
var users = chan.get("users");
|
||||||
var user = users.findWhere({name: data.nick});
|
var user = users.findWhere({name: data[0].nick});
|
||||||
if (!user) {
|
if (!user) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
user.set("name", data["new"]);
|
user.set("name", data[0]["new"]);
|
||||||
users.trigger("change", {}, users);
|
users.trigger("change", {}, users);
|
||||||
|
|
||||||
chan.addMessage({
|
chan.addMessage({
|
||||||
from: data.nick,
|
from: data[0].nick,
|
||||||
message: data["new"],
|
message: data[0]["new"],
|
||||||
type: "nick",
|
type: "nick",
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "notice":
|
case "notice":
|
||||||
channels.first().addMessage(data);
|
if (data[0].to = "*") {
|
||||||
|
data[0].from = "-!-";
|
||||||
|
}
|
||||||
|
channels.first().addMessage(data[0]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "part":
|
case "part":
|
||||||
var i = data.channels.length;
|
var i = data[0].channels.length;
|
||||||
while (i--) {
|
while (i--) {
|
||||||
var chan = channels.findWhere({name: data.channels[i]});
|
var chan = channels.findWhere({name: data[0].channels[i]});
|
||||||
if (data.nick == this.get("client").me) {
|
if (data[0].nick == this.get("client").me) {
|
||||||
channels.remove(chan);
|
channels.remove(chan);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var users = chan.get("users");
|
var users = chan.get("users");
|
||||||
users.remove(users.findWhere({name: data.nick}));
|
users.remove(users.findWhere({name: data[0].nick}));
|
||||||
chan.addMessage({
|
chan.addMessage({
|
||||||
from: data.nick,
|
from: data[0].nick,
|
||||||
type: "part",
|
type: "part",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -210,11 +232,11 @@ function event(event, data) {
|
|||||||
case "quit":
|
case "quit":
|
||||||
channels.each(function(chan) {
|
channels.each(function(chan) {
|
||||||
var users = chan.get("users");
|
var users = chan.get("users");
|
||||||
var user = users.findWhere({name: data.nick});
|
var user = users.findWhere({name: data[0].nick});
|
||||||
if (user) {
|
if (user) {
|
||||||
users.remove(user);
|
users.remove(user);
|
||||||
chan.addMessage({
|
chan.addMessage({
|
||||||
from: data.nick,
|
from: data[0].nick,
|
||||||
type: "quit",
|
type: "quit",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -222,29 +244,50 @@ function event(event, data) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case "topic":
|
case "topic":
|
||||||
var chan = channels.findWhere({name: data.channel});
|
var chan = channels.findWhere({name: data[0].channel});
|
||||||
var from = data.nick;
|
var from = data[0].nick;
|
||||||
if (from == this.get("client").me) {
|
if (from == this.get("client").me) {
|
||||||
from = data.channel;
|
from = data[0].channel;
|
||||||
}
|
}
|
||||||
chan.addMessage({
|
chan.addMessage({
|
||||||
from: from,
|
from: from,
|
||||||
message: data.topic,
|
message: data[0].topic,
|
||||||
type: "topic",
|
type: "topic",
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "welcome":
|
case "welcome":
|
||||||
channels.first().addMessage({message: "Connected."});
|
channels.first().addMessage([
|
||||||
|
{message: "You're now connected to " + this.get("host")},
|
||||||
|
{message: "You're now known as " + data[0]}
|
||||||
|
]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "whois":
|
case "whois":
|
||||||
// ..
|
// If this value is null, an error has occured.
|
||||||
|
if (data[1] == null) {
|
||||||
|
channels.first().addMessage({
|
||||||
|
type: "error",
|
||||||
|
message: data[0]
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
var name = data[1].nickname;
|
||||||
|
var chan = channels.findWhere({name: name}) || channels.add({type: "query", name: name});
|
||||||
|
|
||||||
|
var i = 0;
|
||||||
|
for (var k in data[1]) {
|
||||||
|
if (i++ == 5) break;
|
||||||
|
chan.addMessage({
|
||||||
|
message: k + ": " + data[1][k]
|
||||||
|
});
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Debug
|
// Debug
|
||||||
console.log(event + ":");
|
console.log(event);
|
||||||
console.log(data);
|
console.log(data);
|
||||||
}
|
}
|
1
node_modules/slate-irc
generated
vendored
Submodule
1
node_modules/slate-irc
generated
vendored
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit 6f23d25c4e8163fff06c6d0751219b5d96a3916c
|
Loading…
Reference in New Issue
Block a user