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.
This commit is contained in:
nmeum 2020-12-30 01:19:53 +01:00 committed by GitHub
parent 4fc93959e1
commit 288d953b28
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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 ||