diff --git a/channel.go b/channel.go index d05233c..69b5fef 100644 --- a/channel.go +++ b/channel.go @@ -74,6 +74,13 @@ func (c Channel) SendMessage(message *SendMessage) (*Message, error) { return respMessage, err } + if message.DeleteAfter != 0 { + go func() { + time.Sleep(time.Second * time.Duration(message.DeleteAfter)) + respMessage.Delete() + }() + } + return respMessage, nil } diff --git a/message.go b/message.go index 9d34b0a..31956b3 100644 --- a/message.go +++ b/message.go @@ -144,5 +144,12 @@ func (m Message) Reply(mention bool, sm *SendMessage) (*Message, error) { return respMessage, err } + if sm.DeleteAfter != 0 { + go func() { + time.Sleep(time.Second * time.Duration(sm.DeleteAfter)) + respMessage.Delete() + }() + } + return respMessage, nil } diff --git a/other.go b/other.go index 12943a6..807dacb 100644 --- a/other.go +++ b/other.go @@ -7,6 +7,7 @@ type SendMessage struct { Content string `json:"content,omitempty"` Attachments []string `json:"attachments,omitempty"` Nonce string `json:"nonce,omitempty"` + DeleteAfter uint `json:"-"` Replies []struct { Id string `json:"id,omitempty"` Mention bool `json:"mention,omitempty"` @@ -25,6 +26,12 @@ func (sms *SendMessage) SetContentf(format string, values ...interface{}) *SendM return sms } +// Set delete after option. +func (sms *SendMessage) SetDeleteAfter(second uint) *SendMessage { + sms.DeleteAfter = second + return sms +} + // Add a new attachment. func (sms *SendMessage) AddAttachment(attachment string) *SendMessage { sms.Attachments = append(sms.Attachments, attachment)