diff --git a/client.go b/client.go index 1168893..acc7cdf 100644 --- a/client.go +++ b/client.go @@ -233,7 +233,7 @@ func (c *Client) handleShell(channel ssh.Channel) { if c.IsSilenced() || len(msg) > 1000 { c.SysMsg("Message rejected.") } else { - c.Server.Broadcast(msg, nil) + c.Server.Broadcast(msg, nil, false) } case "/nick": if len(parts) == 2 { @@ -280,7 +280,7 @@ func (c *Client) handleShell(channel ssh.Channel) { client.SysMsg("Banned by %s.", c.ColoredName()) c.Server.Ban(fingerprint, nil) client.Conn.Close() - c.Server.Broadcast(fmt.Sprintf("* %s was banned by %s", parts[1], c.ColoredName()), nil) + c.Server.Broadcast(fmt.Sprintf("* %s was banned by %s", parts[1], c.ColoredName()), nil, true) } } case "/op": @@ -310,7 +310,7 @@ func (c *Client) handleShell(channel ssh.Channel) { } else { client.SysMsg("Kicked by %s.", c.ColoredName()) client.Conn.Close() - c.Server.Broadcast(fmt.Sprintf("* %s was kicked by %s", parts[1], c.ColoredName()), nil) + c.Server.Broadcast(fmt.Sprintf("* %s was kicked by %s", parts[1], c.ColoredName()), nil, true) } } case "/silence": @@ -347,7 +347,7 @@ func (c *Client) handleShell(channel ssh.Channel) { } // Shutdown after 5 seconds go func() { - c.Server.Broadcast(ColorString("31", msg), nil) + c.Server.Broadcast(ColorString("31", msg), nil, true) time.Sleep(time.Second * 5) c.Server.Stop() }() @@ -422,7 +422,7 @@ func (c *Client) handleShell(channel ssh.Channel) { c.SysMsg("Message rejected.") continue } - c.Server.Broadcast(msg, c) + c.Server.Broadcast(msg, c, true) c.lastTX = time.Now() } diff --git a/server.go b/server.go index ef2cb82..b629688 100644 --- a/server.go +++ b/server.go @@ -91,11 +91,11 @@ func (s *Server) Len() int { // SysMsg broadcasts the given message to everyone func (s *Server) SysMsg(msg string, args ...interface{}) { - s.Broadcast(ContinuousFormat(systemMessageFormat, " * "+fmt.Sprintf(msg, args...)), nil) + s.Broadcast(ContinuousFormat(systemMessageFormat, " * "+fmt.Sprintf(msg, args...)), nil, false) } // Broadcast broadcasts the given message to everyone except for the given client -func (s *Server) Broadcast(msg string, except *Client) { +func (s *Server) Broadcast(msg string, except *Client, canHighlight bool) { logger.Debugf("Broadcast to %d: %s", s.Len(), msg) s.history.Add(msg) @@ -104,7 +104,7 @@ func (s *Server) Broadcast(msg string, except *Client) { continue } - if strings.Contains(msg, client.Name) { + if strings.Contains(msg, client.Name) && canHighlight { // Turn message red if client's name is mentioned, and send BEL if they have enabled beeping tmpMsg := strings.Split(msg, Reset) if client.beepMe { @@ -150,8 +150,8 @@ func (s *Server) MotdBroadcast(client *Client) { if s.motd == "" { return } - s.Broadcast(ContinuousFormat(systemMessageFormat, fmt.Sprintf(" * New MOTD set by %s.", client.ColoredName())), client) - s.Broadcast(s.motd, client) + s.Broadcast(ContinuousFormat(systemMessageFormat, fmt.Sprintf(" * New MOTD set by %s.", client.ColoredName())), client, false) + s.Broadcast(s.motd, client, false) } // Add adds the client to the list of clients @@ -174,7 +174,7 @@ func (s *Server) Add(client *Client) { num := len(s.clients) s.Unlock() - s.Broadcast(ContinuousFormat(systemMessageFormat, fmt.Sprintf(" * %s joined. (Total connected: %d)", client.ColoredName(), num)), client) + s.Broadcast(ContinuousFormat(systemMessageFormat, fmt.Sprintf(" * %s joined. (Total connected: %d)", client.ColoredName(), num)), client, false) } // Remove removes the given client from the list of clients