From 288d953b28d5957c4c3ef9ef819ee69ebcbeac62 Mon Sep 17 00:00:00 2001 From: nmeum Date: Wed, 30 Dec 2020 01:19:53 +0100 Subject: [PATCH] event: Use different source format for PRIVMSG and NOTICE (#44) This allows distinguishing the two commands in the output of the Pretty() function. This is useful for IRC client which use the output of the Pretty() function for formating IRC messages. --- event.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/event.go b/event.go index ef4633f..0297060 100644 --- a/event.go +++ b/event.go @@ -363,7 +363,15 @@ func (e *Event) Pretty() (out string, ok bool) { return fmt.Sprintf("[*] CTCP query from %s: %s%s", ctcp.Source.Name, ctcp.Command, " "+ctcp.Text), true } - return fmt.Sprintf("[%s] (%s) %s", strings.Join(e.Params[0:len(e.Params)-1], ","), e.Source.Name, e.Last()), true + + var source string + if e.Command == PRIVMSG { + source = fmt.Sprintf("(%s)", e.Source.Name) + } else { // NOTICE + source = fmt.Sprintf("--%s--", e.Source.Name) + } + + return fmt.Sprintf("[%s] (%s) %s", strings.Join(e.Params[0:len(e.Params)-1], ","), source, e.Last()), true } if e.Command == RPL_MOTD || e.Command == RPL_MOTDSTART ||