mirror of
https://github.com/shazow/ssh-chat.git
synced 2025-04-18 17:57:41 +03:00
Share the op.
This commit is contained in:
parent
af20d755e7
commit
69d56919f8
16
client.go
16
client.go
@ -117,6 +117,7 @@ func (c *Client) handleShell(channel ssh.Channel) {
|
||||
isCmd := strings.HasPrefix(parts[0], "/")
|
||||
|
||||
if isCmd {
|
||||
// TODO: Factor this out.
|
||||
switch parts[0] {
|
||||
case "/exit":
|
||||
channel.Close()
|
||||
@ -161,6 +162,21 @@ func (c *Client) handleShell(channel ssh.Channel) {
|
||||
c.Server.Broadcast(fmt.Sprintf("* %s was banned by %s", parts[1], c.Name), nil)
|
||||
}
|
||||
}
|
||||
case "/op":
|
||||
if !c.Server.IsOp(c) {
|
||||
c.Msg <- fmt.Sprintf("-> You're not an admin.")
|
||||
} else if len(parts) != 2 {
|
||||
c.Msg <- fmt.Sprintf("-> Missing $NAME from: /op $NAME")
|
||||
} else {
|
||||
client := c.Server.Who(parts[1])
|
||||
if client == nil {
|
||||
c.Msg <- fmt.Sprintf("-> No such name: %s", parts[1])
|
||||
} else {
|
||||
fingerprint := client.Fingerprint()
|
||||
client.Write(fmt.Sprintf("-> Made op by %s.", c.Name))
|
||||
c.Server.Op(fingerprint)
|
||||
}
|
||||
}
|
||||
default:
|
||||
c.Msg <- fmt.Sprintf("-> Invalid command: %s", line)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user