mirror of
https://github.com/shazow/ssh-chat.git
synced 2025-06-07 10:53:07 +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
|
/nick $NAME - Rename yourself to a new name
|
||||||
/whois $NAME - Display information about another connected user
|
/whois $NAME - Display information about another connected user
|
||||||
/msg $NAME $MESSAGE
|
/msg $NAME $MESSAGE
|
||||||
|
/beep - Enable BEL notifications on mention.
|
||||||
` + RESET
|
` + RESET
|
||||||
|
|
||||||
const OP_HELP_TEXT string = SYSTEM_MESSAGE_FORMAT + `-> Available operator commands:
|
const OP_HELP_TEXT string = SYSTEM_MESSAGE_FORMAT + `-> Available operator commands:
|
||||||
@ -54,6 +55,7 @@ type Client struct {
|
|||||||
termHeight int
|
termHeight int
|
||||||
silencedUntil time.Time
|
silencedUntil time.Time
|
||||||
lastTX time.Time
|
lastTX time.Time
|
||||||
|
beepMe bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewClient(server *Server, conn *ssh.ServerConn) *Client {
|
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"))
|
c.WriteLines(strings.Split(ABOUT_TEXT, "\n"))
|
||||||
case "/uptime":
|
case "/uptime":
|
||||||
c.Write(c.Server.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":
|
case "/me":
|
||||||
me := strings.TrimLeft(line, "/me")
|
me := strings.TrimLeft(line, "/me")
|
||||||
if me == "" {
|
if me == "" {
|
||||||
|
@ -93,7 +93,12 @@ func (s *Server) Broadcast(msg string, except *Client) {
|
|||||||
if except != nil && client == except {
|
if except != nil && client == except {
|
||||||
continue
|
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