mirror of
https://github.com/shazow/ssh-chat.git
synced 2025-04-12 15:17:16 +03:00
Improve /list
This commit is contained in:
parent
6b765e7a6c
commit
b646abffb8
@ -8,7 +8,7 @@ Coming real soon.
|
||||
* [x] Welcome message.
|
||||
* [x] set term width properly
|
||||
* [x] client map rather than list
|
||||
* [ ] backfill chat history
|
||||
* [x] backfill chat history
|
||||
* [ ] tab completion
|
||||
* [ ] /kick
|
||||
* [x] /help
|
||||
@ -16,4 +16,4 @@ Coming real soon.
|
||||
* [x] /list
|
||||
* [x] /nick
|
||||
* [ ] pubkey fingerprint
|
||||
* [ ] truncate usernames
|
||||
* [x] truncate usernames
|
||||
|
@ -124,7 +124,8 @@ func (c *Client) handleShell(channel ssh.Channel) {
|
||||
c.Msg <- fmt.Sprintf("-> Missing $NAME from: /whois $NAME\r\n")
|
||||
}
|
||||
case "/list":
|
||||
c.Msg <- fmt.Sprintf("-> Connected: %s\r\n", strings.Join(c.Server.List(nil), ","))
|
||||
names := c.Server.List(nil)
|
||||
c.Msg <- fmt.Sprintf("-> %d connected: %s\r\n", len(names), strings.Join(names, ","))
|
||||
default:
|
||||
c.Msg <- fmt.Sprintf("-> Invalid command: %s\r\n", line)
|
||||
}
|
||||
|
@ -1,3 +1,4 @@
|
||||
// TODO: Split this out into its own module, it's kinda neat.
|
||||
package main
|
||||
|
||||
type History struct {
|
||||
|
@ -57,8 +57,12 @@ func NewServer(privateKey []byte) (*Server, error) {
|
||||
return &server, nil
|
||||
}
|
||||
|
||||
func (s *Server) Len() int {
|
||||
return len(s.clients)
|
||||
}
|
||||
|
||||
func (s *Server) Broadcast(msg string, except *Client) {
|
||||
logger.Debugf("Broadcast to %d: %s", len(s.clients), strings.TrimRight(msg, "\r\n"))
|
||||
logger.Debugf("Broadcast to %d: %s", s.Len(), strings.TrimRight(msg, "\r\n"))
|
||||
s.history.Add(msg)
|
||||
|
||||
for _, client := range s.clients {
|
||||
|
Loading…
x
Reference in New Issue
Block a user