Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
738bf5caf5 | |||
3b6caba1dd | |||
a1ea1288bf | |||
c8ff7699c8 |
10
channel.go
10
channel.go
@ -220,3 +220,13 @@ func (c Channel) DeleteGroupRecipient(user_id string) error {
|
||||
_, err := c.Client.Request("DELETE", "/channels/"+c.Id+"/recipients/"+user_id, []byte{})
|
||||
return err
|
||||
}
|
||||
|
||||
// Send a typing start event to the channel.
|
||||
func (c *Channel) BeginTyping() {
|
||||
c.Client.Socket.SendText(fmt.Sprintf("{\"type\":\"BeginTyping\",\"channel\":\"%s\"}", c.Id))
|
||||
}
|
||||
|
||||
// End the typing event in the channel.
|
||||
func (c *Channel) EndTyping() {
|
||||
c.Client.Socket.SendText(fmt.Sprintf("{\"type\":\"EndTyping\",\"channel\":\"%s\"}", c.Id))
|
||||
}
|
||||
|
34
other.go
34
other.go
@ -7,14 +7,27 @@ import (
|
||||
|
||||
// Similar to message, but created for send message function.
|
||||
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"`
|
||||
} `json:"replies,omitempty"`
|
||||
Content string `json:"content"`
|
||||
Nonce string `json:"nonce,omitempty"`
|
||||
Attachments []string `json:"attachments,omitempty"`
|
||||
Replies []Replies `json:"replies,omitempty"`
|
||||
Embeds []SendableEmbed `json:"embeds,omitempty"`
|
||||
DeleteAfter uint `json:"-"`
|
||||
}
|
||||
|
||||
type SendableEmbed struct {
|
||||
Type string `json:"type"`
|
||||
IconUrl string `json:"icon_url,omitempty"`
|
||||
Url string `json:"url,omitempty"`
|
||||
Title string `json:"title,omitempty"`
|
||||
Description string `json:"description,omitempty"`
|
||||
Media string `json:"media,omitempty"`
|
||||
Colour string `json:"colour,omitempty"`
|
||||
}
|
||||
|
||||
type Replies struct {
|
||||
Id string `json:"id"`
|
||||
Mention bool `json:"mention"`
|
||||
}
|
||||
|
||||
// Set content.
|
||||
@ -43,10 +56,7 @@ func (sms *SendMessage) AddAttachment(attachment string) *SendMessage {
|
||||
|
||||
// Add a new reply.
|
||||
func (sms *SendMessage) AddReply(id string, mention bool) *SendMessage {
|
||||
sms.Replies = append(sms.Replies, struct {
|
||||
Id string "json:\"id,omitempty\""
|
||||
Mention bool "json:\"mention\""
|
||||
}{
|
||||
sms.Replies = append(sms.Replies, Replies{
|
||||
Id: id,
|
||||
Mention: mention,
|
||||
})
|
||||
|
@ -25,6 +25,8 @@ func (c *Client) Start() {
|
||||
}
|
||||
|
||||
c.Socket.OnTextMessage = func(message string, _ gowebsocket.Socket) {
|
||||
fmt.Println(message)
|
||||
|
||||
// Parse data
|
||||
rawData := &struct {
|
||||
Type string `json:"type"`
|
||||
@ -67,7 +69,7 @@ func (c *Client) Destroy() {
|
||||
func (c *Client) ping() {
|
||||
for {
|
||||
time.Sleep(30 * time.Second)
|
||||
c.Socket.SendText(fmt.Sprintf("{\"type\":\"Ping\",\"time\":%d}", time.Now().Unix()))
|
||||
c.Socket.SendText("{\"type\":\"Ping\",\"data\":0}")
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user