Merge pull request #26 from IQAndreas/minor-color-fixes

Minor color fixes
This commit is contained in:
Andrey Petrov 2014-12-13 15:55:39 -08:00
commit 356e89c241
2 changed files with 6 additions and 5 deletions

View File

@ -303,15 +303,15 @@ func (c *Client) handleShell(channel ssh.Channel) {
case "/msg": /* Send a PM */ case "/msg": /* Send a PM */
/* Make sure we have a recipient and a message */ /* Make sure we have a recipient and a message */
if len(parts) < 2 { if len(parts) < 2 {
c.Msg <- fmt.Sprintf("-> Missing $NAME from: /msg $NAME $MESSAGE") c.SysMsg("Missing $NAME from: /msg $NAME $MESSAGE")
break break
} else if len(parts) < 3 { } else if len(parts) < 3 {
c.Msg <- fmt.Sprintf("-> Missing $MESSAGE from: /msg $NAME $MESSAGE") c.SysMsg("Missing $MESSAGE from: /msg $NAME $MESSAGE")
break break
} }
/* Ask the server to send the message */ /* Ask the server to send the message */
if err := c.Server.Privmsg(parts[1], parts[2], c); nil != err { if err := c.Server.Privmsg(parts[1], parts[2], c); nil != err {
c.Msg <- fmt.Sprintf("Unable to send message to %v: %v", parts[1], err) c.SysMsg("Unable to send message to %v: %v", parts[1], err)
} }
case "/motd": /* print motd */ case "/motd": /* print motd */
if !c.Server.IsOp(c) { if !c.Server.IsOp(c) {
@ -338,7 +338,7 @@ func (c *Client) handleShell(channel ssh.Channel) {
msg := fmt.Sprintf("%s: %s", c.ColoredName(), line) msg := fmt.Sprintf("%s: %s", c.ColoredName(), line)
/* Rate limit */ /* Rate limit */
if time.Now().Sub(c.lastTX) < REQUIRED_WAIT { if time.Now().Sub(c.lastTX) < REQUIRED_WAIT {
c.Msg <- fmt.Sprintf("-> Rate limiting in effect.") c.SysMsg("Rate limiting in effect.")
continue continue
} }
if c.IsSilenced() || len(msg) > 1000 || len(line) < 1 { if c.IsSilenced() || len(msg) > 1000 || len(line) < 1 {

View File

@ -17,6 +17,7 @@ const MAX_NAME_LENGTH = 32
const HISTORY_LEN = 20 const HISTORY_LEN = 20
const SYSTEM_MESSAGE_FORMAT string = "\033[1;3;90m" const SYSTEM_MESSAGE_FORMAT string = "\033[1;3;90m"
const PRIVATE_MESSAGE_FORMAT string = "\033[3m"
const BEEP string = "\007" const BEEP string = "\007"
var RE_STRIP_TEXT = regexp.MustCompile("[^0-9A-Za-z_.-]") var RE_STRIP_TEXT = regexp.MustCompile("[^0-9A-Za-z_.-]")
@ -112,7 +113,7 @@ func (s *Server) Privmsg(nick, message string, sender *Client) error {
return fmt.Errorf("no client with that nick") return fmt.Errorf("no client with that nick")
} }
/* Send the message */ /* Send the message */
target.Msg <- fmt.Sprintf(BEEP+"[PM from %v] %v", sender.Name, message) target.Msg <- fmt.Sprintf(BEEP+"[PM from %v] %s%v%s", sender.ColoredName(), PRIVATE_MESSAGE_FORMAT, message, RESET)
logger.Debugf("PM from %v to %v: %v", sender.Name, nick, message) logger.Debugf("PM from %v to %v: %v", sender.Name, nick, message)
return nil return nil
} }