minor
This commit is contained in:
parent
c859f99b1e
commit
d0b882f362
1
.gitignore
vendored
1
.gitignore
vendored
@ -32,6 +32,7 @@ go.work.sum
|
|||||||
config.json
|
config.json
|
||||||
accounts.txt
|
accounts.txt
|
||||||
ircserver
|
ircserver
|
||||||
|
irc.db
|
||||||
# Editor/IDE
|
# Editor/IDE
|
||||||
# .idea/
|
# .idea/
|
||||||
# .vscode/
|
# .vscode/
|
||||||
|
|||||||
22
main.go
22
main.go
@ -486,10 +486,24 @@ func (c *Client) serveHistory(subcmd, target string, count int, params []string)
|
|||||||
|
|
||||||
switch subcmd {
|
switch subcmd {
|
||||||
case "LATEST":
|
case "LATEST":
|
||||||
if count > len(ch.history) {
|
if count <= len(ch.history) {
|
||||||
count = len(ch.history)
|
msgs = ch.history[len(ch.history)-count:]
|
||||||
|
} else {
|
||||||
|
extra := count - len(ch.history)
|
||||||
|
rows, err := db.Query(`SELECT msgid, timestamp, prefix, command, msg
|
||||||
|
FROM messages
|
||||||
|
WHERE channel=?
|
||||||
|
ORDER BY timestamp DESC LIMIT ?`,
|
||||||
|
target, extra)
|
||||||
|
if err != nil {
|
||||||
|
c.fwrite(":server 718 %s %s :No history available\r\n", c.nick, target)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
defer rows.Close()
|
||||||
|
|
||||||
|
dbMsgs := scanRows(rows, target)
|
||||||
|
msgs = append(dbMsgs, ch.history...)
|
||||||
}
|
}
|
||||||
msgs = ch.history[len(ch.history)-count:]
|
|
||||||
|
|
||||||
case "BEFORE":
|
case "BEFORE":
|
||||||
if len(params) < 4 {
|
if len(params) < 4 {
|
||||||
@ -799,7 +813,7 @@ func (c *Client) checkRegistration() {
|
|||||||
c.registered = true
|
c.registered = true
|
||||||
c.fwrite(":server 001 %s :Welcome to Gocirc, %s!\r\n", c.nick, c.nick)
|
c.fwrite(":server 001 %s :Welcome to Gocirc, %s!\r\n", c.nick, c.nick)
|
||||||
c.fwrite(":server 002 %s :Your host is server\r\n", c.nick)
|
c.fwrite(":server 002 %s :Your host is server\r\n", c.nick)
|
||||||
c.fwrite(":server 003 %s :This server was created just now\r\n", c.nick)
|
c.fwrite(":server 003 %s :This server has %d users right now\r\n", c.nick, len(clients))
|
||||||
c.fwrite(":server 004 %s server irc 0.1\r\n", c.nick)
|
c.fwrite(":server 004 %s server irc 0.1\r\n", c.nick)
|
||||||
fmt.Fprintf(c.conn, ":server 375 %s :- Message of the Day -\r\n", c.nick)
|
fmt.Fprintf(c.conn, ":server 375 %s :- Message of the Day -\r\n", c.nick)
|
||||||
if motdString != nil {
|
if motdString != nil {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user