Merge pull request #15 from Kealper/master

Colors in /list, fancier tab completion, more /help fixes.
This commit is contained in:
Andrey Petrov 2014-12-13 13:40:59 -08:00
commit 832b455762
2 changed files with 27 additions and 16 deletions

View File

@ -13,22 +13,22 @@ const MSG_BUFFER int = 50
const MAX_MSG_LENGTH int = 512 const MAX_MSG_LENGTH int = 512
const HELP_TEXT string = SYSTEM_MESSAGE_FORMAT + `-> Available commands: const HELP_TEXT string = SYSTEM_MESSAGE_FORMAT + `-> Available commands:
/about - About this chat /about - About this chat.
/exit - Exit the chat /exit - Exit the chat.
/help - Show this help text /help - Show this help text.
/list - List the users that are currently connected /list - List the users that are currently connected.
/beep - Enable BEL notifications on mention. /beep - Enable BEL notifications on mention.
/me $ACTION - Show yourself doing an action /me $ACTION - Show yourself doing an action.
/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 - Sends a private message to a user.
` + 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. /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.
` `
const ABOUT_TEXT string = SYSTEM_MESSAGE_FORMAT + `-> ssh-chat is made by @shazow. const ABOUT_TEXT string = SYSTEM_MESSAGE_FORMAT + `-> ssh-chat is made by @shazow.
@ -217,8 +217,15 @@ func (c *Client) handleShell(channel ssh.Channel) {
c.SysMsg("Missing $NAME from: /whois $NAME") c.SysMsg("Missing $NAME from: /whois $NAME")
} }
case "/list": case "/list":
names := c.Server.List(nil) names := ""
c.SysMsg("%d connected: %s", len(names), strings.Join(names, ", ")) nameList := c.Server.List(nil)
for _, name := range nameList {
names += c.Server.Who(name).ColoredName() + SYSTEM_MESSAGE_FORMAT + ", "
}
if len(names) > 2 {
names = names[:len(names) - 2]
}
c.SysMsg("%d connected: %s", len(nameList), names)
case "/ban": case "/ban":
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

@ -308,7 +308,11 @@ func (s *Server) AutoCompleteFunction(line string, pos int, key rune) (newLine s
if len(nicks) > 0 { if len(nicks) > 0 {
nick := nicks[len(nicks)-1] nick := nicks[len(nicks)-1]
posPartialNick := pos - len(partialNick) posPartialNick := pos - len(partialNick)
if len(shortLine) < 2 {
nick += ": "
} else {
nick += " "
}
newLine = strings.Replace(line[posPartialNick:], newLine = strings.Replace(line[posPartialNick:],
partialNick, nick, 1) partialNick, nick, 1)
newLine = line[:posPartialNick] + newLine newLine = line[:posPartialNick] + newLine