Support TTS. Closes #67
This commit is contained in:
parent
bf3f2c548a
commit
64af0e5f4a
1 changed files with 20 additions and 4 deletions
24
restapi.go
24
restapi.go
|
@ -759,17 +759,17 @@ func (s *Session) ChannelMessageAck(channelID, messageID string) (err error) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// ChannelMessageSend sends a message to the given channel.
|
// channelMessageSend sends a message to the given channel.
|
||||||
// channelID : The ID of a Channel.
|
// channelID : The ID of a Channel.
|
||||||
// content : The message to send.
|
// content : The message to send.
|
||||||
// NOTE, mention and tts parameters may be added in 2.x branch.
|
// tts : Whether to send the message with TTS.
|
||||||
func (s *Session) ChannelMessageSend(channelID string, content string) (st *Message, err error) {
|
func (s *Session) channelMessageSend(channelID, content string, tts bool) (st *Message, err error) {
|
||||||
|
|
||||||
// TODO: nonce string ?
|
// TODO: nonce string ?
|
||||||
data := struct {
|
data := struct {
|
||||||
Content string `json:"content"`
|
Content string `json:"content"`
|
||||||
TTS bool `json:"tts"`
|
TTS bool `json:"tts"`
|
||||||
}{content, false}
|
}{content, tts}
|
||||||
|
|
||||||
// Send the message to the given channel
|
// Send the message to the given channel
|
||||||
response, err := s.Request("POST", CHANNEL_MESSAGES(channelID), data)
|
response, err := s.Request("POST", CHANNEL_MESSAGES(channelID), data)
|
||||||
|
@ -781,6 +781,22 @@ func (s *Session) ChannelMessageSend(channelID string, content string) (st *Mess
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ChannelMessageSend sends a message to the given channel.
|
||||||
|
// channelID : The ID of a Channel.
|
||||||
|
// content : The message to send.
|
||||||
|
func (s *Session) ChannelMessageSend(channelID string, content string) (st *Message, err error) {
|
||||||
|
|
||||||
|
return s.channelMessageSend(channelID, content, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ChannelMessageSendTTS sends a message to the given channel with Text to Speech.
|
||||||
|
// channelID : The ID of a Channel.
|
||||||
|
// content : The message to send.
|
||||||
|
func (s *Session) ChannelMessageSendTTS(channelID string, content string) (st *Message, err error) {
|
||||||
|
|
||||||
|
return s.channelMessageSend(channelID, content, true)
|
||||||
|
}
|
||||||
|
|
||||||
// ChannelMessageEdit edits an existing message, replacing it entirely with
|
// ChannelMessageEdit edits an existing message, replacing it entirely with
|
||||||
// the given content.
|
// the given content.
|
||||||
// channeld : The ID of a Channel
|
// channeld : The ID of a Channel
|
||||||
|
|
Loading…
Reference in a new issue