mirror of
https://github.com/shazow/ssh-chat.git
synced 2025-06-08 19:32:17 +03:00
Use 'sysmsg' for private message system messages
That way it gets nice and pretty colors
This commit is contained in:
parent
cc01deb4bb
commit
0c7c53eee1
10
client.go
10
client.go
@ -78,7 +78,7 @@ func NewClient(server *Server, conn *ssh.ServerConn) *Client {
|
|||||||
func (c *Client) ColoredName() string {
|
func (c *Client) ColoredName() string {
|
||||||
return ColorString(c.Color, c.Name)
|
return ColorString(c.Color, c.Name)
|
||||||
}
|
}
|
||||||
|
v
|
||||||
func (c *Client) SysMsg(msg string, args ...interface{}) {
|
func (c *Client) SysMsg(msg string, args ...interface{}) {
|
||||||
c.Msg <- ContinuousFormat(SYSTEM_MESSAGE_FORMAT, "-> "+fmt.Sprintf(msg, args...))
|
c.Msg <- ContinuousFormat(SYSTEM_MESSAGE_FORMAT, "-> "+fmt.Sprintf(msg, args...))
|
||||||
}
|
}
|
||||||
@ -301,15 +301,15 @@ func (c *Client) handleShell(channel ssh.Channel) {
|
|||||||
case "/msg": /* Send a PM */
|
case "/msg": /* Send a PM */
|
||||||
/* Make sure we have a recipient and a message */
|
/* Make sure we have a recipient and a message */
|
||||||
if len(parts) < 2 {
|
if len(parts) < 2 {
|
||||||
c.Msg <- fmt.Sprintf("-> Missing $NAME from: /msg $NAME $MESSAGE")
|
c.SysMsg("Missing $NAME from: /msg $NAME $MESSAGE")
|
||||||
break
|
break
|
||||||
} else if len(parts) < 3 {
|
} else if len(parts) < 3 {
|
||||||
c.Msg <- fmt.Sprintf("-> Missing $MESSAGE from: /msg $NAME $MESSAGE")
|
c.SysMsg("Missing $MESSAGE from: /msg $NAME $MESSAGE")
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
/* Ask the server to send the message */
|
/* Ask the server to send the message */
|
||||||
if err := c.Server.Privmsg(parts[1], parts[2], c); nil != err {
|
if err := c.Server.Privmsg(parts[1], parts[2], c); nil != err {
|
||||||
c.Msg <- fmt.Sprintf("Unable to send message to %v: %v", parts[1], err)
|
c.SysMsg("Unable to send message to %v: %v", parts[1], err)
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -321,7 +321,7 @@ func (c *Client) handleShell(channel ssh.Channel) {
|
|||||||
msg := fmt.Sprintf("%s: %s", c.ColoredName(), line)
|
msg := fmt.Sprintf("%s: %s", c.ColoredName(), line)
|
||||||
/* Rate limit */
|
/* Rate limit */
|
||||||
if time.Now().Sub(c.lastTX) < REQUIRED_WAIT {
|
if time.Now().Sub(c.lastTX) < REQUIRED_WAIT {
|
||||||
c.Msg <- fmt.Sprintf("-> Rate limiting in effect.")
|
c.SysMsg("Rate limiting in effect.")
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if c.IsSilenced() || len(msg) > 1000 || len(msg) == 0 {
|
if c.IsSilenced() || len(msg) > 1000 || len(msg) == 0 {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user