Update main.go

This commit is contained in:
meer 2026-07-26 10:59:03 +00:00
parent f9adf66d3b
commit 7c532f9233

18
main.go
View File

@ -485,11 +485,25 @@ func handleConn(conn net.Conn) {
client.fwrite(":server 303 %s :%s\r\n", client.nick, strings.Join(online, " "))
// ircv3 stuff
case "CHATHISTORY":
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
}
subcmd := strings.ToUpper(msg.Params[0])
target := historyTargetName(msg.Params[1])
count, convErr := strconv.Atoi(msg.Params[3])
if convErr != nil || count <= 0 {
@ -497,6 +511,8 @@ func handleConn(conn net.Conn) {
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)