Documentation
¶
Index ¶
- type AllowedMentions
- type Attachment
- type Client
- type CodeBlockBuilder
- type DataEncoder
- type Discord
- func (d *Discord) Name() string
- func (d *Discord) PostWebhookJSON(ctx context.Context, web *WebhookContext) error
- func (d *Discord) PostWebhookMultipart(ctx context.Context, web *WebhookContext) error
- func (d *Discord) SendMessage(ctx context.Context, msg maleo.MessageContext)
- func (d *Discord) Wait(ctx context.Context) error
- type DiscordErrorResponse
- type DiscordOption
- func WithBucket(bucket bucket.Bucket) DiscordOption
- func WithClient(client Client) DiscordOption
- func WithCodeBlockBuilder(codeBlockBuilder CodeBlockBuilder) DiscordOption
- func WithCooldown(cooldown time.Duration) DiscordOption
- func WithDataEncoder(dataEncoder DataEncoder) DiscordOption
- func WithEmbedBuilder(builder EmbedBuilder) DiscordOption
- func WithGlobalKey(key string) DiscordOption
- func WithHook(hook Hook) DiscordOption
- func WithLock(lock locker.Locker) DiscordOption
- func WithName(name string) DiscordOption
- func WithSemaphore(sem chan struct{}) DiscordOption
- func WithTrace(trace maleo.TraceCapturer) DiscordOption
- type Embed
- type EmbedAuthor
- type EmbedBuilder
- type EmbedBuilderFunc
- type EmbedField
- type EmbedFooter
- type EmbedImage
- type EmbedProvider
- type EmbedThumbnail
- type EmbedVideo
- type ExtraInformation
- type HighlightHint
- type Hook
- type ImageSizeHint
- type JSONCodeBlockBuilder
- type JSONDataEncoder
- type Job
- type MimetypeHint
- type NoopHook
- func (n NoopHook) PostBucketUploadHook(context.Context, *WebhookContext, []bucket.UploadResult)
- func (n NoopHook) PostMessageHook(context.Context, *WebhookContext, error)
- func (n NoopHook) PreBucketUploadHook(ctx context.Context, _ *WebhookContext) context.Context
- func (n NoopHook) PreMessageHook(ctx context.Context, _ *WebhookContext) context.Context
- type WebhookContext
- type WebhookFile
- type WebhookPayload
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AllowedMentions ¶
type Attachment ¶
type Attachment struct {
ID int `json:"id"`
Filename string `json:"filename,omitempty"`
Description string `json:"description,omitempty"`
ContentType string `json:"content_type,omitempty"`
Size int `json:"size,omitempty"`
URL string `json:"url,omitempty"`
ProxyURL string `json:"proxy_url,omitempty"`
Height int `json:"height,omitempty"`
Width int `json:"width,omitempty"`
Ephemeral bool `json:"ephemeral,omitempty"`
}
type CodeBlockBuilder ¶
type DataEncoder ¶
type Discord ¶
type Discord struct {
// contains filtered or unexported fields
}
func NewDiscordBot ¶
func NewDiscordBot(webhook string, opts ...DiscordOption) *Discord
NewDiscordBot creates a new discord bot.
func (*Discord) PostWebhookJSON ¶
func (d *Discord) PostWebhookJSON(ctx context.Context, web *WebhookContext) error
func (*Discord) PostWebhookMultipart ¶
func (d *Discord) PostWebhookMultipart(ctx context.Context, web *WebhookContext) error
func (*Discord) SendMessage ¶
func (d *Discord) SendMessage(ctx context.Context, msg maleo.MessageContext)
SendMessage implements maleo.Messenger interface.
type DiscordErrorResponse ¶
type DiscordErrorResponse struct {
Code int `json:"code"`
Message string `json:"Message"`
StatusCode int `json:"status_code"`
Raw json.RawMessage `json:"raw"`
}
func (DiscordErrorResponse) Error ¶
func (d DiscordErrorResponse) Error() string
func (DiscordErrorResponse) PrintJSON ¶
func (d DiscordErrorResponse) PrintJSON()
func (DiscordErrorResponse) String ¶
func (d DiscordErrorResponse) String() string
type DiscordOption ¶
type DiscordOption interface {
// contains filtered or unexported methods
}
func WithBucket ¶
func WithBucket(bucket bucket.Bucket) DiscordOption
func WithClient ¶
func WithClient(client Client) DiscordOption
func WithCodeBlockBuilder ¶
func WithCodeBlockBuilder(codeBlockBuilder CodeBlockBuilder) DiscordOption
func WithCooldown ¶
func WithCooldown(cooldown time.Duration) DiscordOption
func WithDataEncoder ¶
func WithDataEncoder(dataEncoder DataEncoder) DiscordOption
func WithEmbedBuilder ¶
func WithEmbedBuilder(builder EmbedBuilder) DiscordOption
func WithGlobalKey ¶
func WithGlobalKey(key string) DiscordOption
func WithHook ¶
func WithHook(hook Hook) DiscordOption
func WithSemaphore ¶
func WithSemaphore(sem chan struct{}) DiscordOption
WithSemaphore sets the number of concurrent workers.
type Embed ¶
type Embed struct {
// Title of embed.
Title string `json:"title,omitempty"`
// Type of embed (always "rich" for webhook embeds).
Type string `json:"type,omitempty"`
// Description of embed.
Description string `json:"description,omitempty"`
// URL of embed.
Url string `json:"url,omitempty"`
// Timestamp of embed content.
Timestamp string `json:"timestamp,omitempty"`
// Color code of the embed.
Color int `json:"color,omitempty"`
Footer *EmbedFooter `json:"footer,omitempty"`
// Image information.
Image *EmbedImage `json:"image,omitempty"`
// Thumbnail information.
Thumbnail *EmbedThumbnail `json:"thumbnail,omitempty"`
// Video information.
Video *EmbedVideo `json:"video,omitempty"`
// Provider information.
Provider *EmbedProvider `json:"provider,omitempty"`
// Author information.
Author *EmbedAuthor `json:"author,omitempty"`
// Fields information.
Fields []*EmbedField `json:"fields,omitempty"`
}
type EmbedAuthor ¶
type EmbedAuthor struct {
// Name of author.
Name string `json:"name,omitempty"`
// URL of author.
Url string `json:"url,omitempty"`
// URL of author icon (only supports http(s) and attachments).
IconUrl string `json:"icon_url,omitempty"`
// A proxied url of author icon.
ProxyIconUrl string `json:"proxy_icon_url,omitempty"`
}
type EmbedBuilder ¶
type EmbedBuilder interface {
BuildEmbed(ctx context.Context, msg maleo.MessageContext, info *ExtraInformation) ([]*Embed, []bucket.File)
}
type EmbedBuilderFunc ¶
type EmbedBuilderFunc func(ctx context.Context, msg maleo.MessageContext, info *ExtraInformation) ([]*Embed, []bucket.File)
func (EmbedBuilderFunc) BuildEmbed ¶
func (e EmbedBuilderFunc) BuildEmbed(ctx context.Context, msg maleo.MessageContext, info *ExtraInformation) ([]*Embed, []bucket.File)
type EmbedField ¶
type EmbedFooter ¶
type EmbedImage ¶
type EmbedImage struct {
// Source url of image (only supports http(s) and attachments).
Url string `json:"url,omitempty"`
// A proxied url of the image.
ProxyUrl string `json:"proxy_url,omitempty"`
// Height of image.
Height int `json:"height,omitempty"`
// Width of image.
Width int `json:"width,omitempty"`
}
type EmbedProvider ¶
type EmbedThumbnail ¶
type EmbedThumbnail struct {
// Source url of thumbnail (only supports http(s) and attachments).
Url string `json:"url,omitempty"`
// A proxied url of the thumbnail.
ProxyUrl string `json:"proxy_url,omitempty"`
// Height of thumbnail.
Height int `json:"height,omitempty"`
// Width of thumbnail.
Width int `json:"width,omitempty"`
}
type EmbedVideo ¶
type ExtraInformation ¶
type HighlightHint ¶
type HighlightHint interface {
DiscordHighlight() string
}
type Hook ¶
type Hook interface {
PreMessageHook(ctx context.Context, web *WebhookContext) context.Context
PostMessageHook(ctx context.Context, web *WebhookContext, err error)
PreBucketUploadHook(ctx context.Context, web *WebhookContext) context.Context
PostBucketUploadHook(ctx context.Context, web *WebhookContext, results []bucket.UploadResult)
}
type ImageSizeHint ¶
type ImageSizeHint interface {
ImageSize() (height, width int)
}
type JSONCodeBlockBuilder ¶
type JSONCodeBlockBuilder struct{}
func (JSONCodeBlockBuilder) Build ¶
func (J JSONCodeBlockBuilder) Build(w io.Writer, value []any) error
func (JSONCodeBlockBuilder) BuildError ¶
func (J JSONCodeBlockBuilder) BuildError(w io.Writer, e error) error
type JSONDataEncoder ¶
type JSONDataEncoder struct{}
func (JSONDataEncoder) ContentType ¶
func (J JSONDataEncoder) ContentType() string
func (JSONDataEncoder) FileExtension ¶
func (J JSONDataEncoder) FileExtension() string
type MimetypeHint ¶
type MimetypeHint interface {
Mimetype() string
}
type NoopHook ¶
type NoopHook struct{}
func (NoopHook) PostBucketUploadHook ¶
func (n NoopHook) PostBucketUploadHook(context.Context, *WebhookContext, []bucket.UploadResult)
func (NoopHook) PostMessageHook ¶
func (n NoopHook) PostMessageHook(context.Context, *WebhookContext, error)
func (NoopHook) PreBucketUploadHook ¶
func (NoopHook) PreMessageHook ¶
type WebhookContext ¶
type WebhookContext struct {
Message maleo.MessageContext
Files []bucket.File
Payload *WebhookPayload
Extra *ExtraInformation
// Populated on PostMessageHook, otherwise Nil.
//
// Body is the response body from Discord.
// Nil if the request failed to receive response from Discord.
ResponseBody []byte
// Populated on PostMessageHook if the request received response from Discord, otherwise nil.
// Body is already consumed. Use ResponseBody instead to read the response body.
Response *http.Response
Maleo *maleo.Maleo
}
type WebhookFile ¶
type WebhookPayload ¶
type WebhookPayload struct {
Wait bool `json:"-"`
ThreadID snowflake.ID `json:"-"`
Content string `json:"content,omitempty"`
Username string `json:"username,omitempty"`
AvatarURL string `json:"avatarURL,omitempty"`
TTS bool `json:"TTS,omitempty"`
Embeds []*Embed `json:"embeds,omitempty"`
AllowedMentions *AllowedMentions `json:"allowed_mentions,omitempty"`
Attachments []*Attachment `json:"attachments,omitempty"`
}
func (*WebhookPayload) BuildMultipartPayloadJSON ¶
func (w *WebhookPayload) BuildMultipartPayloadJSON() ([]byte, error)
Click to show internal directories.
Click to hide internal directories.