upstream: don't populate time tag for numerics
Allows us to save a few bytes, e.g. in WHO replies.
This commit is contained in:
parent
09513e63fe
commit
16e43ee3a3
12
irc.go
12
irc.go
@ -848,3 +848,15 @@ func (cr *capRegistry) SetEnabled(name string, enabled bool) {
|
||||
delete(cr.Enabled, name)
|
||||
}
|
||||
}
|
||||
|
||||
func isNumeric(cmd string) bool {
|
||||
if len(cmd) != 3 {
|
||||
return false
|
||||
}
|
||||
for i := 0; i < 3; i++ {
|
||||
if cmd[i] < '0' || cmd[i] > '9' {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
@ -450,7 +450,7 @@ func (uc *upstreamConn) handleMessage(ctx context.Context, msg *irc.Message) err
|
||||
msg.Prefix = uc.serverPrefix
|
||||
}
|
||||
|
||||
if _, ok := msg.Tags["time"]; !ok {
|
||||
if _, ok := msg.Tags["time"]; !ok && !isNumeric(msg.Command) {
|
||||
msg.Tags["time"] = irc.TagValue(formatServerTime(time.Now()))
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user