mirror of
https://github.com/shazow/ssh-chat.git
synced 2025-04-18 17:57:41 +03:00
Colors in /list and fancier tab completion
This commit is contained in:
parent
820372a975
commit
b058fb4e40
37
client.go
37
client.go
@ -12,22 +12,22 @@ import (
|
|||||||
const MSG_BUFFER int = 10
|
const MSG_BUFFER int = 10
|
||||||
|
|
||||||
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.
|
||||||
/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 - Send a private message to another user.
|
||||||
/beep - Enable BEL notifications on mention.
|
/beep - Enable BEL notifications on mention.
|
||||||
` + 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 + `
|
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")
|
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.")
|
||||||
|
@ -313,7 +313,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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user