mirror of
https://github.com/shazow/ssh-chat.git
synced 2025-04-15 16:40:36 +03:00
Added comments and /shutdown command.
This commit is contained in:
parent
0fd74cb163
commit
d0ea3f2ca6
20
client.go
20
client.go
@ -308,6 +308,24 @@ func (c *Client) handleShell(channel ssh.Channel) {
|
||||
client.SysMsg("Silenced for %s by %s.", duration, c.ColoredName())
|
||||
}
|
||||
}
|
||||
case "/shutdown":
|
||||
if !c.Server.IsOp(c) {
|
||||
c.SysMsg("You're not an admin.")
|
||||
} else {
|
||||
var split []string = strings.SplitN(line, " ", 2)
|
||||
var msg string
|
||||
if len(split) > 1 {
|
||||
msg = split[1]
|
||||
} else {
|
||||
msg = ""
|
||||
}
|
||||
// Shutdown after 5 seconds
|
||||
go func() {
|
||||
c.Server.Broadcast(ColorString("31", msg), nil)
|
||||
time.Sleep(time.Second * 5)
|
||||
c.Server.Stop()
|
||||
}()
|
||||
}
|
||||
case "/msg": /* Send a PM */
|
||||
/* Make sure we have a recipient and a message */
|
||||
if len(parts) < 2 {
|
||||
@ -341,11 +359,13 @@ func (c *Client) handleShell(channel ssh.Channel) {
|
||||
c.SysMsg("Missing $THEME from: /theme $THEME")
|
||||
c.SysMsg("Choose either color or mono")
|
||||
} else {
|
||||
// Sets colorMe attribute of client
|
||||
if parts[1] == "mono" {
|
||||
c.colorMe = false
|
||||
} else if parts[1] == "color" {
|
||||
c.colorMe = true
|
||||
}
|
||||
// Rename to reset prompt
|
||||
c.Rename(c.Name)
|
||||
}
|
||||
|
||||
|
@ -17,10 +17,11 @@ const BLINK string = "\033[5m"
|
||||
const INVERT string = "\033[7m"
|
||||
|
||||
var colors = []string { "31", "32", "33", "34", "35", "36", "37", "91", "92", "93", "94", "95", "96", "97" }
|
||||
var r *regexp.Regexp = regexp.MustCompile("\033\\[[\\d;]+m")
|
||||
// For removing ANSI Escapes
|
||||
var deColor *regexp.Regexp = regexp.MustCompile("\033\\[[\\d;]+m")
|
||||
|
||||
func DeColorString(s string) string {
|
||||
s = r.ReplaceAllString(s, "")
|
||||
s = deColor.ReplaceAllString(s, "")
|
||||
return s
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user