Documentation
¶
Index ¶
- Constants
- func GetAttachmentType(contentType string) string
- func HasURL(text string) bool
- func MentionsExtractor(content string) (users, roles []int64, everyone, here bool)
- func New(cql *db.CQLCon, pg *pgdb.DB, t mq.SendTransporter, imq *indexmq.IndexMQ, ...) server.Entity
- func UniqueAttachmentTypes(types []string) []string
- type Direction
- type GetMessagesRequest
- type SendMessageRequest
- type UpdateMessageRequest
- type UploadAttachmentRequest
Constants ¶
View Source
const ( ErrUnableToGetUserToken = "unable to get user token" ErrUnableToParseBody = "unable to parse body" ErrPermissionsRequired = "permissions required" ErrUnableToCreateAttachment = "unable to create attachment" ErrUnableToCreateUploadURL = "unable to create upload url" ErrIncorrectChannelID = "incorrect channel ID" ErrIncorrectMessageID = "incorrect message ID" ErrFileIsTooBig = "file is too big" ErrUnableToSendMessage = "unable to send message" ErrUnableToUpdateMessage = "unable to update message" ErrUnableToGetUser = "unable to get user" ErrUnableToGetGuild = "unable to get guild" ErrUnableToGetUserDiscriminator = "unable to get discriminator" ErrUnableToGetAttachements = "unable to get attachments" ErrUnableToSentToThisChannel = "unable to send to this channel" ErrUnableToReadFromThisChannel = "unable to read from this channel" ErrUnableToGetMessage = "unable to get message" ErrUnableToSetReadState = "unable to set read state" ErrUnableToSendTypingEvent = "unable to send typing event" // Validation error messages ErrMessageContentRequired = "message content is required" ErrMessageContentTooLong = "message content must be less than 2000 characters" ErrAttachmentIdInvalid = "attachment ID must be positive" ErrMentionIdInvalid = "mention ID must be positive" ErrFilenameRequired = "filename is required" ErrFilenameTooLong = "filename must be less than 255 characters" ErrFileSizeInvalid = "file size must be positive" ErrFileSizeTooBig = "file size must be less than 100MB" ErrDimensionsInvalid = "width and height must be non-negative" ErrLimitInvalid = "limit must be between 1 and 100" ErrFromIdInvalid = "from ID must be positive" ErrDirectionInvalid = "direction must be 'before' or 'after'" )
View Source
const ( DirectionBefore = Direction("before") DirectionAfter = Direction("after") DirectionAround = Direction("around") )
View Source
const (
DefaultLimit = int(50)
)
View Source
const (
MaxBatchSize = 50
)
Variables ¶
This section is empty.
Functions ¶
func GetAttachmentType ¶
func MentionsExtractor ¶ added in v1.5.0
MentionsExtractor extract mentions from the text message <@2226021950625415168> - extracts all as user ids <@&2226021950625415168> - extracts all as role ids
@here - if present in content returns true for here mentions @everyone - if present in content returns true for everyone mentions
Example: "Hello <@2226021950625415168> and <@2229920912390488064>" returns slice if users [2226021950625415168, 2229920912390488064]
func UniqueAttachmentTypes ¶
Types ¶
type GetMessagesRequest ¶
type GetMessagesRequest struct {
From *int64 `query:"from" json:"from" example:"2230469276416868352"` // ID of the message whe start to look from
Limit *int `query:"limit" json:"limit" example:"30"` // Number of messages to return.
Direction *Direction `query:"direction" json:"direction" enums:"before,after,around" example:"before"` // Direction to look for messages
}
func (GetMessagesRequest) Validate ¶
func (r GetMessagesRequest) Validate() error
type SendMessageRequest ¶
type SendMessageRequest struct {
Content string `json:"content" example:"Hello world!"` // Message content
Attachments []int64 `json:"attachments" example:"2230469276416868352"` // IDs of attached files
Mentions []int64 `json:"mentions" example:"2230469276416868352"` // IDs of mentioned users
}
func (SendMessageRequest) Validate ¶
func (r SendMessageRequest) Validate() error
type UpdateMessageRequest ¶
type UpdateMessageRequest struct {
Content string `json:"content" example:"Hello world!"` // Message content
}
func (UpdateMessageRequest) Validate ¶
func (r UpdateMessageRequest) Validate() error
type UploadAttachmentRequest ¶
type UploadAttachmentRequest struct {
Filename string `json:"filename" example:"image.png"` // File name
FileSize int64 `json:"file_size" example:"100000"` // File size in bytes
Width int64 `json:"width" example:"800"` // Image width in pixels
Height int64 `json:"height" example:"600"` // Image height in pixels
ContentType string `json:"content_type" example:"image/png"` // File content-type meta data
}
func (UploadAttachmentRequest) Validate ¶
func (r UploadAttachmentRequest) Validate() error
Click to show internal directories.
Click to hide internal directories.