load chat history when connecting

This commit is contained in:
Lephenixnoir 2023-06-17 12:46:57 +02:00
parent 9d24cb671b
commit 0774035512
Signed by: Lephenixnoir
GPG Key ID: 1BBA026E13FC0495
1 changed files with 21 additions and 10 deletions

View File

@ -276,12 +276,29 @@ let irc = new function() {
conn.password = undefined;
irc.onAuthenticated();
["#annonces"].forEach(channel => {
send("CHATHISTORY", ["LATEST", channel, "*", "100"]);
});
if(conn.caps.includes("draft/chathistory")) {
["#annonces", "#projets", "#hs"].forEach(channel => {
send("CHATHISTORY", ["LATEST", channel, "*", "100"]);
});
}
}
if(msg.command == "PRIVMSG" && msg.args.length == 2) {
if(msg.command == "PRIVMSG")
processPRIVMSG(msg);
}
function processBatch(batch) {
const batchArgs = batch[0].args.slice(1);
if(batchArgs.length === 2 && batchArgs[0] === "chathistory") {
batch.forEach(msg => {
if(msg.command === "PRIVMSG")
processPRIVMSG(msg);
});
}
}
function processPRIVMSG(msg) {
if(msg.args.length == 2) {
let source = msg.source;
if(source.includes("!"))
source = source.substr(0, source.indexOf("!"));
@ -289,12 +306,6 @@ let irc = new function() {
}
}
function processBatch(batch) {
const batchArgs = batch[0].args.slice(1);
console.log(batchArgs);
console.log(batch);
}
this.postMessage = function(channel, message) {
if(message.startsWith("/")) {
sendRaw(message.substring(1));