Merge pull request #1 from shazow/master

Merge to latest
This commit is contained in:
Sam Mauldin 2014-12-13 14:37:58 -06:00
commit c28e5b38b1
2 changed files with 26 additions and 1 deletions

View File

@ -20,10 +20,12 @@ 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:
/ban $NAME - Banish a user from the chat /ban $NAME - Banish a user from the chat
/kick $NAME - Kick em' out.
/op $NAME - Promote a user to server operator /op $NAME - Promote a user to server operator
/silence $NAME - Revoke a user's ability to speak /silence $NAME - Revoke a user's ability to speak
` `
@ -54,6 +56,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 +163,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 == "" {
@ -227,6 +237,21 @@ func (c *Client) handleShell(channel ssh.Channel) {
c.Server.Op(fingerprint) c.Server.Op(fingerprint)
} }
} }
case "/kick":
if !c.Server.IsOp(c) {
c.SysMsg("You're not an admin.")
} else if len(parts) != 2 {
c.SysMsg("Missing $NAME from: /kick $NAME")
} else {
client := c.Server.Who(parts[1])
if client == nil {
c.SysMsg("No such name: %s", parts[1])
} else {
client.SysMsg2("Kicked by %s.", c.ColoredName())
client.Conn.Close()
c.Server.Broadcast(fmt.Sprintf("* %s was kicked by %s", parts[1], c.ColoredName()), nil)
}
}
case "/silence": case "/silence":
if !c.Server.IsOp(c) { if !c.Server.IsOp(c) {
c.SysMsg("You're not an admin.") c.SysMsg("You're not an admin.")

View File

@ -94,7 +94,7 @@ func (s *Server) Broadcast(msg string, except *Client) {
continue continue
} }
/* Add an ascii BEL to ding clients when they're mentioned */ /* Add an ascii BEL to ding clients when they're mentioned */
if strings.HasPrefix(msg, fmt.Sprintf("%s:", client.Name)) { if client.beepMe && strings.Contains(msg, client.Name) {
client.Msg <- msg + BEEP client.Msg <- msg + BEEP
} else { } else {
client.Msg <- msg client.Msg <- msg