mirror of
https://github.com/shazow/ssh-chat.git
synced 2025-06-08 19:32:17 +03:00
Merge branch 'help'
This commit is contained in:
commit
c5c6a6558f
25
client.go
25
client.go
@ -12,13 +12,18 @@ import (
|
|||||||
const MSG_BUFFER int = 10
|
const MSG_BUFFER int = 10
|
||||||
|
|
||||||
const HELP_TEXT string = `-> Available commands:
|
const HELP_TEXT string = `-> Available commands:
|
||||||
/about
|
/about - About this chat
|
||||||
/exit
|
/exit - Exit the chat
|
||||||
/help
|
/help - Show this help text
|
||||||
/list
|
/list - List the users that are currently connected
|
||||||
/uptime
|
/me $ACTION - Show yourself doing an action
|
||||||
/nick $NAME
|
/nick $NAME - Rename yourself to a new name
|
||||||
/whois $NAME
|
/whois $NAME - Display information about another connected user
|
||||||
|
`
|
||||||
|
const OP_HELP_TEXT string = `-> Available operator commands:
|
||||||
|
/ban $NAME - Banish a user from the chat
|
||||||
|
/op $NAME - Promote a user to server operator
|
||||||
|
/silence $NAME - Revoke a user's ability to speak
|
||||||
`
|
`
|
||||||
|
|
||||||
const ABOUT_TEXT string = `-> ssh-chat is made by @shazow.
|
const ABOUT_TEXT string = `-> ssh-chat is made by @shazow.
|
||||||
@ -30,6 +35,7 @@ const ABOUT_TEXT string = `-> ssh-chat is made by @shazow.
|
|||||||
|
|
||||||
For more, visit shazow.net or follow at twitter.com/shazow
|
For more, visit shazow.net or follow at twitter.com/shazow
|
||||||
`
|
`
|
||||||
|
|
||||||
type Client struct {
|
type Client struct {
|
||||||
Server *Server
|
Server *Server
|
||||||
Conn *ssh.ServerConn
|
Conn *ssh.ServerConn
|
||||||
@ -132,6 +138,9 @@ func (c *Client) handleShell(channel ssh.Channel) {
|
|||||||
channel.Close()
|
channel.Close()
|
||||||
case "/help":
|
case "/help":
|
||||||
c.WriteLines(strings.Split(HELP_TEXT, "\n"))
|
c.WriteLines(strings.Split(HELP_TEXT, "\n"))
|
||||||
|
if c.Server.IsOp(c) {
|
||||||
|
c.WriteLines(strings.Split(OP_HELP_TEXT, "\n"))
|
||||||
|
}
|
||||||
case "/about":
|
case "/about":
|
||||||
c.WriteLines(strings.Split(ABOUT_TEXT, "\n"))
|
c.WriteLines(strings.Split(ABOUT_TEXT, "\n"))
|
||||||
case "/uptime":
|
case "/uptime":
|
||||||
@ -231,7 +240,7 @@ func (c *Client) handleShell(channel ssh.Channel) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
msg := fmt.Sprintf("%s: %s", c.ColoredName(), line)
|
msg := fmt.Sprintf("%s: %s", c.ColoredName(), line)
|
||||||
if c.IsSilenced() || len(msg) > 1000 {
|
if c.IsSilenced() || len(msg) > 1000 || len(line) < 1 {
|
||||||
c.Msg <- fmt.Sprintf("-> Message rejected.")
|
c.Msg <- fmt.Sprintf("-> Message rejected.")
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user