added delete after option.
This commit is contained in:
parent
f2d47011cb
commit
1045db4f49
@ -74,6 +74,13 @@ func (c Channel) SendMessage(message *SendMessage) (*Message, error) {
|
|||||||
return respMessage, err
|
return respMessage, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if message.DeleteAfter != 0 {
|
||||||
|
go func() {
|
||||||
|
time.Sleep(time.Second * time.Duration(message.DeleteAfter))
|
||||||
|
respMessage.Delete()
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
|
||||||
return respMessage, nil
|
return respMessage, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,5 +144,12 @@ func (m Message) Reply(mention bool, sm *SendMessage) (*Message, error) {
|
|||||||
return respMessage, err
|
return respMessage, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if sm.DeleteAfter != 0 {
|
||||||
|
go func() {
|
||||||
|
time.Sleep(time.Second * time.Duration(sm.DeleteAfter))
|
||||||
|
respMessage.Delete()
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
|
||||||
return respMessage, nil
|
return respMessage, nil
|
||||||
}
|
}
|
||||||
|
7
other.go
7
other.go
@ -7,6 +7,7 @@ type SendMessage struct {
|
|||||||
Content string `json:"content,omitempty"`
|
Content string `json:"content,omitempty"`
|
||||||
Attachments []string `json:"attachments,omitempty"`
|
Attachments []string `json:"attachments,omitempty"`
|
||||||
Nonce string `json:"nonce,omitempty"`
|
Nonce string `json:"nonce,omitempty"`
|
||||||
|
DeleteAfter uint `json:"-"`
|
||||||
Replies []struct {
|
Replies []struct {
|
||||||
Id string `json:"id,omitempty"`
|
Id string `json:"id,omitempty"`
|
||||||
Mention bool `json:"mention,omitempty"`
|
Mention bool `json:"mention,omitempty"`
|
||||||
@ -25,6 +26,12 @@ func (sms *SendMessage) SetContentf(format string, values ...interface{}) *SendM
|
|||||||
return sms
|
return sms
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set delete after option.
|
||||||
|
func (sms *SendMessage) SetDeleteAfter(second uint) *SendMessage {
|
||||||
|
sms.DeleteAfter = second
|
||||||
|
return sms
|
||||||
|
}
|
||||||
|
|
||||||
// Add a new attachment.
|
// Add a new attachment.
|
||||||
func (sms *SendMessage) AddAttachment(attachment string) *SendMessage {
|
func (sms *SendMessage) AddAttachment(attachment string) *SendMessage {
|
||||||
sms.Attachments = append(sms.Attachments, attachment)
|
sms.Attachments = append(sms.Attachments, attachment)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user