Beep command.

This commit is contained in:
Andrey Petrov 2014-12-13 11:22:43 -08:00
parent 460b81be2e
commit 8b4f05b344
2 changed files with 15 additions and 1 deletions

View File

@ -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 == "" {

View File

@ -93,9 +93,14 @@ func (s *Server) Broadcast(msg string, except *Client) {
if except != nil && client == except { if except != nil && client == except {
continue continue
} }
/* 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 client.Msg <- msg
} }
} }
}
/* Send a message to a particular nick, if it exists */ /* Send a message to a particular nick, if it exists */
func (s *Server) Privmsg(nick, message string, sender *Client) error { func (s *Server) Privmsg(nick, message string, sender *Client) error {