Update main.go

This commit is contained in:
meer 2026-07-26 13:47:38 +00:00
parent ead0c8e3c9
commit 69beb1340e

27
main.go
View File

@ -725,7 +725,34 @@ func (c *Client) serveHistory(subcmd, target string, count int, params []string)
} }
defer rows.Close() defer rows.Close()
msgs = scanRows(rows, target) msgs = scanRows(rows, target)
case "TARGETS":
if len(params) < 4 {
c.fwrite(":server 461 %s CHATHISTORY :Not enough parameters\r\n", c.nick)
return
}
// Parse start and end timestamps
startStr := strings.TrimPrefix(params[1], "timestamp=")
endStr := strings.TrimPrefix(params[2], "timestamp=")
startTime, err1 := time.Parse(time.RFC3339Nano, startStr)
endTime, err2 := time.Parse(time.RFC3339Nano, endStr)
if err1 != nil || err2 != nil {
c.fwrite(":server 461 %s CHATHISTORY :Invalid timestamp\r\n", c.nick)
return
}
rows, err := db.Query(`SELECT msgid, timestamp, prefix, command, msg
FROM messages
WHERE timestamp BETWEEN ? AND ?
ORDER BY timestamp ASC LIMIT ?`,
startTime.UnixNano(), endTime.UnixNano(), count)
if err != nil {
c.fwrite(":server 718 %s * :No history available\r\n", c.nick)
return
}
defer rows.Close()
msgs = scanRows(rows, "")
case "AROUND": case "AROUND":
if len(params) < 4 { if len(params) < 4 {
c.fwrite(":server 461 %s CHATHISTORY :Not enough parameters\r\n", c.nick) c.fwrite(":server 461 %s CHATHISTORY :Not enough parameters\r\n", c.nick)