mirror of
https://github.com/shazow/ssh-chat.git
synced 2025-04-12 23:27:17 +03:00
Improve /list
This commit is contained in:
parent
6b765e7a6c
commit
b646abffb8
@ -8,7 +8,7 @@ Coming real soon.
|
|||||||
* [x] Welcome message.
|
* [x] Welcome message.
|
||||||
* [x] set term width properly
|
* [x] set term width properly
|
||||||
* [x] client map rather than list
|
* [x] client map rather than list
|
||||||
* [ ] backfill chat history
|
* [x] backfill chat history
|
||||||
* [ ] tab completion
|
* [ ] tab completion
|
||||||
* [ ] /kick
|
* [ ] /kick
|
||||||
* [x] /help
|
* [x] /help
|
||||||
@ -16,4 +16,4 @@ Coming real soon.
|
|||||||
* [x] /list
|
* [x] /list
|
||||||
* [x] /nick
|
* [x] /nick
|
||||||
* [ ] pubkey fingerprint
|
* [ ] 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")
|
c.Msg <- fmt.Sprintf("-> Missing $NAME from: /whois $NAME\r\n")
|
||||||
}
|
}
|
||||||
case "/list":
|
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:
|
default:
|
||||||
c.Msg <- fmt.Sprintf("-> Invalid command: %s\r\n", line)
|
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
|
package main
|
||||||
|
|
||||||
type History struct {
|
type History struct {
|
||||||
|
@ -57,8 +57,12 @@ func NewServer(privateKey []byte) (*Server, error) {
|
|||||||
return &server, nil
|
return &server, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *Server) Len() int {
|
||||||
|
return len(s.clients)
|
||||||
|
}
|
||||||
|
|
||||||
func (s *Server) Broadcast(msg string, except *Client) {
|
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)
|
s.history.Add(msg)
|
||||||
|
|
||||||
for _, client := range s.clients {
|
for _, client := range s.clients {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user