mirror of
https://github.com/shazow/ssh-chat.git
synced 2025-04-13 15:47:17 +03:00
Formatting, simplified motd.
This commit is contained in:
parent
5f31e548a7
commit
a7a2173c3f
12
client.go
12
client.go
@ -27,9 +27,8 @@ const (
|
||||
/nick $NAME - Rename yourself to a new name.
|
||||
/whois $NAME - Display information about another connected user.
|
||||
/msg $NAME $MESSAGE - Sends a private message to a user.
|
||||
/motd - Prints the Message of the Day
|
||||
/theme [color|mono] - Set client theme
|
||||
` + Reset
|
||||
/motd - Prints the Message of the Day.
|
||||
/theme [color|mono] - Set client theme.` + Reset
|
||||
|
||||
// OpHelpText is the additional text returned by /help if the client is an Op
|
||||
OpHelpText string = systemMessageFormat + `-> Available operator commands:
|
||||
@ -37,10 +36,9 @@ const (
|
||||
/kick $NAME - Kick em' out.
|
||||
/op $NAME - Promote a user to server operator.
|
||||
/silence $NAME - Revoke a user's ability to speak.
|
||||
/shutdown $MESSAGE - Broadcast message and shutdown server
|
||||
/motd $MESSAGE - Sets the Message of the Day
|
||||
/whitelist $FINGERPRINT - Adds pubkey fingerprint to the connection whitelist
|
||||
` + Reset
|
||||
/shutdown $MESSAGE - Broadcast message and shutdown server.
|
||||
/motd $MESSAGE - Set message shown whenever somebody joins.
|
||||
/whitelist $FINGERPRINT - Add fingerprint to whitelist, prevent anyone else from joining.` + Reset
|
||||
|
||||
// AboutText is the text returned by /about
|
||||
AboutText string = systemMessageFormat + `-> ssh-chat is made by @shazow.
|
||||
|
1
motd.txt
Normal file
1
motd.txt
Normal file
@ -0,0 +1 @@
|
||||
[39;05;91mWelcome to chat.shazow.net, enter /help for more. [0m
|
13
server.go
13
server.go
@ -55,7 +55,7 @@ func NewServer(privateKey []byte) (*Server, error) {
|
||||
clients: Clients{},
|
||||
count: 0,
|
||||
history: NewHistory(historyLength),
|
||||
motd: "Message of the Day! Modify with /motd",
|
||||
motd: "",
|
||||
whitelist: map[string]struct{}{},
|
||||
admins: map[string]struct{}{},
|
||||
bannedPK: map[string]*time.Time{},
|
||||
@ -139,13 +139,19 @@ func (s *Server) SetMotd(motd string) {
|
||||
|
||||
// MotdUnicast sends the MOTD as a SysMsg
|
||||
func (s *Server) MotdUnicast(client *Client) {
|
||||
client.SysMsg("MOTD:\r\n" + ColorString("36", s.motd)) /* a nice cyan color */
|
||||
if s.motd == "" {
|
||||
return
|
||||
}
|
||||
client.SysMsg(s.motd)
|
||||
}
|
||||
|
||||
// MotdBroadcast broadcasts the MOTD
|
||||
func (s *Server) MotdBroadcast(client *Client) {
|
||||
if s.motd == "" {
|
||||
return
|
||||
}
|
||||
s.Broadcast(ContinuousFormat(systemMessageFormat, fmt.Sprintf(" * New MOTD set by %s.", client.ColoredName())), client)
|
||||
s.Broadcast(ColorString("36", s.motd), client)
|
||||
s.Broadcast(s.motd, client)
|
||||
}
|
||||
|
||||
// Add adds the client to the list of clients
|
||||
@ -153,7 +159,6 @@ func (s *Server) Add(client *Client) {
|
||||
go func() {
|
||||
s.MotdUnicast(client)
|
||||
client.SendLines(s.history.Get(10))
|
||||
client.SysMsg("Welcome to ssh-chat. Enter /help for more.")
|
||||
}()
|
||||
|
||||
s.Lock()
|
||||
|
Loading…
x
Reference in New Issue
Block a user