Adding troutslap command

This commit is contained in:
Lawrence Craft 2014-12-15 20:44:53 +00:00 committed by Peter Hellberg
parent 82ae125c0e
commit f9e4e9f88f

View File

@ -173,6 +173,15 @@ func (c *Client) Fingerprint() string {
return c.Conn.Permissions.Extensions["fingerprint"]
}
// Emote formats and sends an emote
func (c *Client) Emote(message string) {
formatted := fmt.Sprintf("** %s%s", c.ColoredName(), message)
if c.IsSilenced() || len(message) > 1000 {
c.SysMsg("Message rejected")
}
c.Server.Broadcast(formatted, nil)
}
func (c *Client) handleShell(channel ssh.Channel) {
defer channel.Close()
@ -216,6 +225,8 @@ func (c *Client) handleShell(channel ssh.Channel) {
c.beepCommand()
case "/me":
c.meCommand(line)
case "/slap":
c.slapCommand(parts)
case "/nick":
c.nickCommand(parts)
case "/whois":
@ -305,12 +316,18 @@ func (c *Client) meCommand(line string) {
if me == "" {
me = " is at a loss for words."
}
msg := fmt.Sprintf("** %s%s", c.ColoredName(), me)
if c.IsSilenced() || len(msg) > 1000 {
c.SysMsg("Message rejected.")
} else {
c.Server.Broadcast(msg, nil)
c.Emote(me)
}
func (c *Client) slapCommand(parts []string) {
slappee := "themself"
if len(parts) > 1 {
slappee = parts[1]
if len(parts[1]) > 100 {
slappee = "some long-named jerk"
}
}
c.Emote(fmt.Sprintf(" slaps %s around a bit with a large trout.", slappee))
}
func (c *Client) nickCommand(parts []string) {