mirror of
https://github.com/shazow/ssh-chat.git
synced 2025-04-27 05:42:16 +03:00
Revert 7634d0b170df6bfda41f32e8c66bb75f6144bf69
This commit is contained in:
parent
b9a929d0d4
commit
64e0dbc5c4
@ -293,7 +293,7 @@ func (c *Client) handleShell(channel ssh.Channel) {
|
|||||||
client.SysMsg("Banned by %s.", c.ColoredName())
|
client.SysMsg("Banned by %s.", c.ColoredName())
|
||||||
c.Server.Ban(fingerprint, nil)
|
c.Server.Ban(fingerprint, nil)
|
||||||
client.Conn.Close()
|
client.Conn.Close()
|
||||||
c.Server.Broadcast(fmt.Sprintf("* %s was banned by %s", parts[1], c.ColoredName()), nil, true)
|
c.Server.Broadcast(fmt.Sprintf("* %s was banned by %s", parts[1], c.ColoredName()), nil)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case "/op":
|
case "/op":
|
||||||
@ -323,7 +323,7 @@ func (c *Client) handleShell(channel ssh.Channel) {
|
|||||||
} else {
|
} else {
|
||||||
client.SysMsg("Kicked by %s.", c.ColoredName())
|
client.SysMsg("Kicked by %s.", c.ColoredName())
|
||||||
client.Conn.Close()
|
client.Conn.Close()
|
||||||
c.Server.Broadcast(fmt.Sprintf("* %s was kicked by %s", parts[1], c.ColoredName()), nil, true)
|
c.Server.Broadcast(fmt.Sprintf("* %s was kicked by %s", parts[1], c.ColoredName()), nil)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case "/silence":
|
case "/silence":
|
||||||
@ -360,7 +360,7 @@ func (c *Client) handleShell(channel ssh.Channel) {
|
|||||||
}
|
}
|
||||||
// Shutdown after 5 seconds
|
// Shutdown after 5 seconds
|
||||||
go func() {
|
go func() {
|
||||||
c.Server.Broadcast(ColorString("31", msg), nil, true)
|
c.Server.Broadcast(ColorString("31", msg), nil)
|
||||||
time.Sleep(time.Second * 5)
|
time.Sleep(time.Second * 5)
|
||||||
c.Server.Stop()
|
c.Server.Stop()
|
||||||
}()
|
}()
|
||||||
@ -435,7 +435,7 @@ func (c *Client) handleShell(channel ssh.Channel) {
|
|||||||
c.SysMsg("Message rejected.")
|
c.SysMsg("Message rejected.")
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
c.Server.Broadcast(msg, c, true)
|
c.Server.Broadcast(msg, c)
|
||||||
c.lastTX = time.Now()
|
c.lastTX = time.Now()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
10
server.go
10
server.go
@ -92,11 +92,11 @@ func (s *Server) Len() int {
|
|||||||
|
|
||||||
// SysMsg broadcasts the given message to everyone
|
// SysMsg broadcasts the given message to everyone
|
||||||
func (s *Server) SysMsg(msg string, args ...interface{}) {
|
func (s *Server) SysMsg(msg string, args ...interface{}) {
|
||||||
s.Broadcast(ContinuousFormat(systemMessageFormat, " * "+fmt.Sprintf(msg, args...)), nil, false)
|
s.Broadcast(ContinuousFormat(systemMessageFormat, " * "+fmt.Sprintf(msg, args...)), nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Broadcast broadcasts the given message to everyone except for the given client
|
// Broadcast broadcasts the given message to everyone except for the given client
|
||||||
func (s *Server) Broadcast(msg string, except *Client, canHighlight bool) {
|
func (s *Server) Broadcast(msg string, except *Client) {
|
||||||
logger.Debugf("Broadcast to %d: %s", s.Len(), msg)
|
logger.Debugf("Broadcast to %d: %s", s.Len(), msg)
|
||||||
s.history.Add(msg)
|
s.history.Add(msg)
|
||||||
|
|
||||||
@ -105,7 +105,7 @@ func (s *Server) Broadcast(msg string, except *Client, canHighlight bool) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if strings.Contains(msg, client.Name) && canHighlight {
|
if strings.Contains(msg, client.Name) {
|
||||||
// Turn message red if client's name is mentioned, and send BEL if they have enabled beeping
|
// Turn message red if client's name is mentioned, and send BEL if they have enabled beeping
|
||||||
personalMsg := strings.Replace(msg, client.Name, highlightFormat+client.Name+Reset, -1)
|
personalMsg := strings.Replace(msg, client.Name, highlightFormat+client.Name+Reset, -1)
|
||||||
if client.beepMe {
|
if client.beepMe {
|
||||||
@ -151,8 +151,8 @@ func (s *Server) MotdBroadcast(client *Client) {
|
|||||||
if s.motd == "" {
|
if s.motd == "" {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
s.Broadcast(ContinuousFormat(systemMessageFormat, fmt.Sprintf(" * New MOTD set by %s.", client.ColoredName())), client, false)
|
s.Broadcast(ContinuousFormat(systemMessageFormat, fmt.Sprintf(" * New MOTD set by %s.", client.ColoredName())), client)
|
||||||
s.Broadcast(s.motd, client, false)
|
s.Broadcast(s.motd, client)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add adds the client to the list of clients
|
// Add adds the client to the list of clients
|
||||||
|
Loading…
x
Reference in New Issue
Block a user