diff --git a/client.go b/client.go index 62d5d91..b843c3f 100644 --- a/client.go +++ b/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. diff --git a/motd.txt b/motd.txt new file mode 100644 index 0000000..ac8395e --- /dev/null +++ b/motd.txt @@ -0,0 +1 @@ +Welcome to chat.shazow.net, enter /help for more.  \ No newline at end of file diff --git a/server.go b/server.go index df832b2..dd47bba 100644 --- a/server.go +++ b/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()