message

package
v1.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 9, 2026 License: MIT Imports: 49 Imported by: 0

Documentation

Index

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"
	ErrInvalidAttachments           = "invalid attachments"

	// Validation error messages
	ErrMessagePayloadRequired = "message content, attachments, or embeds are required"
	ErrMessageUpdateRequired  = "message content, embeds, or flags update 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'"
	ErrFlagsInvalid           = "flags must be non-negative"
)
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 GetAttachmentType(contentType string) string

func HasURL

func HasURL(text string) bool

HasURL returns true if the input string contains at least one URL.

func MentionsExtractor added in v1.5.0

func MentionsExtractor(content string) (users, roles []int64, everyone, here bool)

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 New

func New(cql *db.CQLCon, pg *pgdb.DB, t mq.SendTransporter, imq *indexmq.IndexMQ, emq embedQueue, uploadLimit int64, attachTTLSeconds int64, cache cache.Cache, log *slog.Logger) server.Entity

func UniqueAttachmentTypes

func UniqueAttachmentTypes(types []string) []string

Types

type Direction

type Direction string

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 helper.StringInt64Array `json:"attachments" example:"2230469276416868352"` // IDs of attached files
	Mentions    helper.StringInt64Array `json:"mentions" example:"2230469276416868352"`    // IDs of mentioned users
	Embeds      []embed.Embed           `json:"embeds,omitempty"`                          // Manual embeds supplied by the client. These are stored separately from generated URL embeds.
}

func (SendMessageRequest) Validate

func (r SendMessageRequest) Validate() error

type UpdateMessageRequest

type UpdateMessageRequest struct {
	Content *string        `json:"content,omitempty" example:"Hello world!"` // Message content
	Embeds  *[]embed.Embed `json:"embeds,omitempty"`                         // Full replacement for the manual embed array. Generated embeds are managed by the embedder service.
	Flags   *int           `json:"flags,omitempty" example:"4"`              // Message flags bitmask. Use 4 to suppress URL embed generation and clear generated embeds.
}

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL