Colors in /list and fancier tab completion

This commit is contained in:
Ken Piper 2014-12-13 16:31:35 -05:00
parent 820372a975
commit b058fb4e40
2 changed files with 27 additions and 16 deletions

View File

@ -12,22 +12,22 @@ import (
const MSG_BUFFER int = 10
const HELP_TEXT string = SYSTEM_MESSAGE_FORMAT + `-> Available commands:
/about - About this chat
/exit - Exit the chat
/help - Show this help text
/list - List the users that are currently connected
/me $ACTION - Show yourself doing an action
/nick $NAME - Rename yourself to a new name
/whois $NAME - Display information about another connected user
/msg $NAME $MESSAGE
/beep - Enable BEL notifications on mention.
/about - About this chat.
/exit - Exit the chat.
/help - Show this help text.
/list - List the users that are currently connected.
/me $ACTION - Show yourself doing an action.
/nick $NAME - Rename yourself to a new name.
/whois $NAME - Display information about another connected user.
/msg $NAME $MESSAGE - Send a private message to another user.
/beep - Enable BEL notifications on mention.
` + RESET
const OP_HELP_TEXT string = SYSTEM_MESSAGE_FORMAT + `-> Available operator commands:
/ban $NAME - Banish a user from the chat
/kick $NAME - Kick em' out.
/op $NAME - Promote a user to server operator
/silence $NAME - Revoke a user's ability to speak
/ban $NAME - Banish a user from the chat
/kick $NAME - Kick em' out.
/op $NAME - Promote a user to server operator.
/silence $NAME - Revoke a user's ability to speak.
`
const ABOUT_TEXT string = SYSTEM_MESSAGE_FORMAT + `
@ -203,8 +203,15 @@ func (c *Client) handleShell(channel ssh.Channel) {
c.SysMsg("Missing $NAME from: /whois $NAME")
}
case "/list":
names := c.Server.List(nil)
c.SysMsg("%d connected: %s", len(names), strings.Join(names, ", "))
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":
if !c.Server.IsOp(c) {
c.SysMsg("You're not an admin.")

View File

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