mirror of
https://github.com/shazow/ssh-chat.git
synced 2025-05-31 15:49:37 +03:00
Beep command.
This commit is contained in:
parent
460b81be2e
commit
8b4f05b344
@ -20,6 +20,7 @@ const HELP_TEXT string = SYSTEM_MESSAGE_FORMAT + `-> Available commands:
|
||||
/nick $NAME - Rename yourself to a new name
|
||||
/whois $NAME - Display information about another connected user
|
||||
/msg $NAME $MESSAGE
|
||||
/beep - Enable BEL notifications on mention.
|
||||
` + RESET
|
||||
|
||||
const OP_HELP_TEXT string = SYSTEM_MESSAGE_FORMAT + `-> Available operator commands:
|
||||
@ -54,6 +55,7 @@ type Client struct {
|
||||
termHeight int
|
||||
silencedUntil time.Time
|
||||
lastTX time.Time
|
||||
beepMe bool
|
||||
}
|
||||
|
||||
func NewClient(server *Server, conn *ssh.ServerConn) *Client {
|
||||
@ -160,6 +162,13 @@ func (c *Client) handleShell(channel ssh.Channel) {
|
||||
c.WriteLines(strings.Split(ABOUT_TEXT, "\n"))
|
||||
case "/uptime":
|
||||
c.Write(c.Server.Uptime())
|
||||
case "/beep":
|
||||
c.beepMe = !c.beepMe
|
||||
if c.beepMe {
|
||||
c.SysMsg("I'll beep you good.")
|
||||
} else {
|
||||
c.SysMsg("No more beeps. :(")
|
||||
}
|
||||
case "/me":
|
||||
me := strings.TrimLeft(line, "/me")
|
||||
if me == "" {
|
||||
|
@ -93,7 +93,12 @@ func (s *Server) Broadcast(msg string, except *Client) {
|
||||
if except != nil && client == except {
|
||||
continue
|
||||
}
|
||||
client.Msg <- msg
|
||||
/* Add an ascii BEL to ding clients when they're mentioned */
|
||||
if client.beepMe && strings.Contains(msg, client.Name) {
|
||||
client.Msg <- msg + BEEP
|
||||
} else {
|
||||
client.Msg <- msg
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user