mirror of
https://github.com/jeremyd/ergo.git
synced 2026-07-23 15:48:10 -07:00
capability: Add server-time
This commit is contained in:
@@ -16,11 +16,13 @@ type Capability string
|
||||
const (
|
||||
MultiPrefix Capability = "multi-prefix"
|
||||
SASL Capability = "sasl"
|
||||
ServerTime Capability = "server-time"
|
||||
)
|
||||
|
||||
var (
|
||||
SupportedCapabilities = CapabilitySet{
|
||||
MultiPrefix: true,
|
||||
ServerTime: true,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@@ -343,6 +343,16 @@ func (client *Client) destroy() {
|
||||
|
||||
// Send sends an IRC line to the client.
|
||||
func (client *Client) Send(tags *map[string]ircmsg.TagValue, prefix string, command string, params ...string) error {
|
||||
// attach server-time
|
||||
if client.capabilities[ServerTime] {
|
||||
if tags == nil {
|
||||
tags = ircmsg.MakeTags("time", time.Now().Format(time.RFC3339))
|
||||
} else {
|
||||
(*tags)["time"] = ircmsg.MakeTagValue(time.Now().Format(time.RFC3339))
|
||||
}
|
||||
}
|
||||
|
||||
// send out the message
|
||||
ircmsg := ircmsg.MakeMessage(tags, prefix, command, params...)
|
||||
line, err := ircmsg.Line()
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user