1
0
Fork 0
forked from External/ergo

Allow formatting codes in the MOTD

This commit is contained in:
Daniel Oaks 2017-10-08 20:17:49 +10:00
parent 095e71b2fe
commit 695faefd93
6 changed files with 82 additions and 2 deletions

View file

@ -1423,7 +1423,7 @@ func (server *Server) applyConfig(config *Config, initial bool) error {
newISupportReplies = oldISupportList.GetDifference(server.isupport)
}
server.loadMOTD(config.Server.MOTD)
server.loadMOTD(config.Server.MOTD, config.Server.MOTDFormatting)
// reload logging config
err = server.logger.ApplyConfig(config.Logging)
@ -1462,7 +1462,7 @@ func (server *Server) applyConfig(config *Config, initial bool) error {
return nil
}
func (server *Server) loadMOTD(motdPath string) error {
func (server *Server) loadMOTD(motdPath string, useFormatting bool) error {
server.logger.Debug("rehash", "Loading MOTD")
motdLines := make([]string, 0)
if motdPath != "" {
@ -1477,6 +1477,11 @@ func (server *Server) loadMOTD(motdPath string) error {
break
}
line = strings.TrimRight(line, "\r\n")
if useFormatting {
line = ircfmt.Unescape(line)
}
// "- " is the required prefix for MOTD, we just add it here to make
// bursting it out to clients easier
line = fmt.Sprintf("- %s", line)