From 7c532f9233669f1a4092cbe1d11ab621e65803ec Mon Sep 17 00:00:00 2001 From: meer Date: Sun, 26 Jul 2026 10:59:03 +0000 Subject: [PATCH] Update main.go --- main.go | 40 ++++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/main.go b/main.go index 8a7c77a..a63e05e 100644 --- a/main.go +++ b/main.go @@ -485,18 +485,34 @@ func handleConn(conn net.Conn) { client.fwrite(":server 303 %s :%s\r\n", client.nick, strings.Join(online, " ")) // ircv3 stuff case "CHATHISTORY": - if len(msg.Params) < 4 { - client.fwrite(":server 461 %s CHATHISTORY :Not enough parameters\r\n", client.nick) - continue - } - subcmd := strings.ToUpper(msg.Params[0]) - target := historyTargetName(msg.Params[1]) - count, convErr := strconv.Atoi(msg.Params[3]) - if convErr != nil || count <= 0 { - client.fwrite(":server 461 %s CHATHISTORY :Invalid message count\r\n", client.nick) - continue - } - client.serveHistory(subcmd, target, count, msg.Params) + subcmd := strings.ToUpper(msg.Params[0]) + + if subcmd == "LATEST" { + if len(msg.Params) < 3 { + client.fwrite(":server 461 %s CHATHISTORY :Not enough parameters\r\n", client.nick) + continue + } + target := historyTargetName(msg.Params[1]) + count, convErr := strconv.Atoi(msg.Params[2]) + if convErr != nil || count <= 0 { + client.fwrite(":server 461 %s CHATHISTORY :Invalid message count\r\n", client.nick) + continue + } + client.serveHistory(subcmd, target, count, msg.Params) + } else { + if len(msg.Params) < 4 { + client.fwrite(":server 461 %s CHATHISTORY :Not enough parameters\r\n", client.nick) + continue + } + target := historyTargetName(msg.Params[1]) + count, convErr := strconv.Atoi(msg.Params[3]) + if convErr != nil || count <= 0 { + client.fwrite(":server 461 %s CHATHISTORY :Invalid message count\r\n", client.nick) + continue + } + client.serveHistory(subcmd, target, count, msg.Params) + } + case "MONITOR": if len(msg.Params) < 1 { client.fwrite(":server 461 %s MONITOR :Not enough parameters\r\n", client.nick)