diff --git a/go.mod b/go.mod index fc036e8..06dbd06 100644 --- a/go.mod +++ b/go.mod @@ -4,6 +4,7 @@ go 1.17 require ( github.com/gorilla/websocket v1.4.2 // indirect + github.com/oklog/ulid/v2 v2.0.2 // indirect github.com/sacOO7/go-logger v0.0.0-20180719173527-9ac9add5a50d // indirect github.com/sacOO7/gowebsocket v0.0.0-20210515122958-9396f1a71e23 // indirect ) diff --git a/go.sum b/go.sum index 958dc06..fab05d4 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,8 @@ github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc= github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/oklog/ulid/v2 v2.0.2 h1:r4fFzBm+bv0wNKNh5eXTwU7i85y5x+uwkxCUTNVQqLc= +github.com/oklog/ulid/v2 v2.0.2/go.mod h1:mtBL0Qe/0HAx6/a4Z30qxVIAL1eQDweXq5lxOEiwQ68= +github.com/pborman/getopt v0.0.0-20170112200414-7148bc3a4c30/go.mod h1:85jBQOZwpVEaDAr341tbn15RS4fCAsIst0qp7i8ex1o= github.com/sacOO7/go-logger v0.0.0-20180719173527-9ac9add5a50d h1:5T+fbRuQbpi+WZtB2yfuu59r00F6T2HV/zGYrwX8nvE= github.com/sacOO7/go-logger v0.0.0-20180719173527-9ac9add5a50d/go.mod h1:L5EJe2k8GwpBoGXDRLAEs58R239jpZuE7NNEtW+T7oo= github.com/sacOO7/gowebsocket v0.0.0-20210515122958-9396f1a71e23 h1:yjnkNJTpQPCx10KF1jypuIhAVc6EYn2M9lJgwSTHQYs= diff --git a/message.go b/message.go new file mode 100644 index 0000000..a7604d6 --- /dev/null +++ b/message.go @@ -0,0 +1,73 @@ +package revoltgo + +// Message struct +type Message struct { + Client *Client + + Id string `json:"_id"` + Nonce string `json:"nonce"` + ChannelId string `json:"channel"` + AuthorId string `json:"author"` + Content string `json:"content"` + Attachments []*Attachment `json:"attachments"` + Mentions []string `json:"mentions"` + Replies []string `json:"replies"` +} + +// Attachment struct. +type Attachment struct { + Id string `json:"_id"` + Tag string `json:"tag"` + Size int `json:"size"` + FileName string `json:"filename"` + Metadata *AttachmentMetadata + ContentType string `json:"content_type"` + Embeds []*MessageEmbed +} + +// Attachment metadata struct. +type AttachmentMetadata struct { + Type string `json:"type"` + Width int `json:"width"` + Height int `json:"height"` +} + +// Message edited struct. +type MessageEdited struct { + Date int `json:"$date"` +} + +// Message embed struct. +type MessageEmbed struct { + Type string `json:"type"` + Url string `json:"url"` + Special *MessageSpecialEmbed + Title string `json:"title"` + Description string `json:"description"` + Image *MessageEmbeddedImage `json:"image"` + Video *MessageEmbeddedVideo `json:"video"` + IconUrl string `json:"icon_url"` + Color string `json:"color"` +} + +// Message special embed struct. +type MessageSpecialEmbed struct { + Type string `json:"type"` + Id string `json:"id"` + ContentType string `json:"content_type"` +} + +// Message embedded image struct +type MessageEmbeddedImage struct { + Size string `json:"size"` + Url string `json:"url"` + Width int `json:"width"` + Height int `json:"height"` +} + +// Message embedded video struct +type MessageEmbeddedVideo struct { + Url string `json:"url"` + Width int `json:"width"` + Height int `json:"height"` +}