mirror of
https://codeberg.org/emersion/gamja.git
synced 2024-11-14 19:05:01 -05:00
Add support for TOPIC messages
This commit is contained in:
parent
e7a0274172
commit
9a3409e970
2 changed files with 27 additions and 1 deletions
|
@ -92,6 +92,10 @@ function createMessageElement(msg) {
|
|||
line.appendChild(createNickElement(msg.prefix.name));
|
||||
line.appendChild(document.createTextNode(" has left"));
|
||||
break;
|
||||
case "TOPIC":
|
||||
line.appendChild(createNickElement(msg.prefix.name));
|
||||
line.appendChild(document.createTextNode(" changed the topic to: " + msg.params[1]));
|
||||
break;
|
||||
default:
|
||||
line.appendChild(document.createTextNode(" " + msg.command + " " + msg.params.join(" ")));
|
||||
}
|
||||
|
@ -118,8 +122,9 @@ function createBuffer(name) {
|
|||
var buf = {
|
||||
name: name,
|
||||
li: li,
|
||||
messages: [],
|
||||
readOnly: false,
|
||||
topic: null,
|
||||
messages: [],
|
||||
|
||||
addMessage: function(msg) {
|
||||
buf.messages.push(msg);
|
||||
|
@ -208,6 +213,16 @@ function connect() {
|
|||
});
|
||||
}
|
||||
break;
|
||||
case RPL_TOPIC:
|
||||
var channel = msg.params[1];
|
||||
var topic = msg.params[2];
|
||||
|
||||
var buf = buffers[channel];
|
||||
if (!buf) {
|
||||
break;
|
||||
}
|
||||
buf.topic = topic;
|
||||
break;
|
||||
case ERR_PASSWDMISMATCH:
|
||||
console.error("Password mismatch");
|
||||
disconnect();
|
||||
|
@ -248,6 +263,16 @@ function connect() {
|
|||
}
|
||||
// TODO: append message to all buffers the user is a member of
|
||||
break;
|
||||
case "TOPIC":
|
||||
var channel = msg.params[0];
|
||||
var topic = msg.params[1];
|
||||
var buf = buffers[channel];
|
||||
if (!buf) {
|
||||
break;
|
||||
}
|
||||
buf.topic = topic;
|
||||
buf.addMessage(msg);
|
||||
break;
|
||||
default:
|
||||
serverBuffer.addMessage(msg);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
const RPL_WELCOME = "001";
|
||||
const RPL_TOPIC = "332";
|
||||
const ERR_PASSWDMISMATCH = "464";
|
||||
|
||||
function parsePrefix(s) {
|
||||
|
|
Loading…
Reference in a new issue