Documentation ¶
Index ¶
- Constants
- Variables
- func InitObjectStorage(db *gorm.DB, fqdn string, bucketName string) error
- func WithoutFallbackToSelf() optionFunc
- type AutomodWait
- type BucketType
- type BucketUpdate
- type Consumer
- type DiffChannel
- type DiffEmoji
- type DiffGuild
- type DiffInvites
- type DiffMember
- type DiffRole
- type DiffWebhooks
- type Event
- func (e *Event) AddAttachement(attachement *discordgo.MessageAttachment) (*FileInfo, error)
- func (e *Event) AddFile(data []byte, file *FileInfo) (*FileInfo, error)
- func (e *Event) AddFileFromURL(link string, filename string) (*FileInfo, error)
- func (e *Event) BotMention() bool
- func (e *Event) Command() bool
- func (e *Event) Context() context.Context
- func (e *Event) DB() *gorm.DB
- func (e *Event) DM() bool
- func (e *Event) DeleteFile(file *FileInfo) error
- func (e *Event) Discord() *discord.Session
- func (e *Event) Except(err error, fields ...string)
- func (e *Event) ExceptSilent(err error, fields ...string)
- func (e *Event) FeatureFlagger() *featureflag.FeatureFlagger
- func (e *Event) Fields() []string
- func (e *Event) FieldsVariadic(start int) string
- func (e *Event) FindAnyChannel(opts ...optionFunc) (*discordgo.Channel, error)
- func (e *Event) FindChannel(opts ...optionFunc) (*discordgo.Channel, error)
- func (e *Event) FindMember(opts ...optionFunc) (*discordgo.User, error)
- func (e *Event) FindMessageLink(link string) (*discordgo.Message, error)
- func (e *Event) FindRole(opts ...optionFunc) (*discordgo.Role, error)
- func (e *Event) FindUser(opts ...optionFunc) (*discordgo.User, error)
- func (e *Event) GetUserStorageUsage() (*UserStorageInfo, error)
- func (e *Event) HTTPClient() *http.Client
- func (e *Event) Has(firstPermission interfaces.Permission, permissions ...interfaces.Permission) bool
- func (e *Event) HasOr(firstPermission interfaces.Permission, permissions ...interfaces.Permission) bool
- func (e *Event) IsEnabled(key string, fallback bool) bool
- func (e *Event) Localizations() []interfaces.Localization
- func (e *Event) Logger() *zap.Logger
- func (e *Event) OriginalCommand() string
- func (e *Event) Paginator() *paginator.Paginator
- func (e *Event) Parse()
- func (e *Event) Prefix() string
- func (e *Event) Publisher() *Publisher
- func (e *Event) Questionnaire() *Questionnaire
- func (e *Event) React(emojiID string, emojiIDs ...string) error
- func (e *Event) Redis() *redis.Client
- func (e *Event) Require(callback func(), firstPermission interfaces.Permission, ...)
- func (e *Event) RequireOr(callback func(), firstPermission interfaces.Permission, ...)
- func (e *Event) Respond(message string, values ...interface{}) ([]*discordgo.Message, error)
- func (e *Event) RespondComplex(message *discordgo.MessageSend, values ...interface{}) ([]*discordgo.Message, error)
- func (e *Event) RespondDM(message string, values ...interface{}) ([]*discordgo.Message, error)
- func (e *Event) Send(channelID, message string, values ...interface{}) ([]*discordgo.Message, error)
- func (e *Event) SendComplex(channelID string, message *discordgo.MessageSend, values ...interface{}) ([]*discordgo.Message, error)
- func (e *Event) SendComplexDM(userID string, message *discordgo.MessageSend, values ...interface{}) ([]*discordgo.Message, error)
- func (e *Event) SendDM(userID, message string, values ...interface{}) ([]*discordgo.Message, error)
- func (e *Event) SetTimezone(timezone *time.Location) error
- func (e *Event) State() *state.State
- func (e *Event) Storage() *Storage
- func (e *Event) Timezone() *time.Location
- func (e *Event) Translate(key string, values ...interface{}) string
- func (e *Event) Typing()
- func (e *Event) UpdateFileInfo(file FileInfo) error
- func (e *Event) WithContext(ctx context.Context)
- func (e *Event) WithDB(db *gorm.DB)
- func (e *Event) WithFeatureFlagger(featureFlagger *featureflag.FeatureFlagger)
- func (e *Event) WithHTTPClient(client *http.Client)
- func (e *Event) WithLocalizations(localizations []interfaces.Localization)
- func (e *Event) WithLogger(logger *zap.Logger)
- func (e *Event) WithPaginator(paginator *paginator.Paginator)
- func (e *Event) WithPublisher(publisher *Publisher)
- func (e *Event) WithQuestionnaire(questionnaire *Questionnaire)
- func (e *Event) WithRedis(redisClient *redis.Client)
- func (e *Event) WithState(state *state.State)
- func (e *Event) WithStorage(storage *Storage)
- func (e *Event) WithTokens(tokens map[string]string)
- type EventlogUpdate
- type FileInfo
- type Publisher
- type Questionnaire
- func (q *Questionnaire) Do(ctx context.Context, event *Event) (bool, error)
- func (q *Questionnaire) Redo(event *Event) error
- func (q *Questionnaire) Register(key string, filter QuestionnaireFilter, payload map[string]interface{}) error
- func (q *Questionnaire) RegisterWithExpiration(key string, filter QuestionnaireFilter, payload map[string]interface{}, ...) error
- type QuestionnaireFilter
- type QuestionnaireMatch
- type QuickactionRemind
- type ServerlistServerExpire
- type SpanContext
- type Storage
- type Type
- type UserError
- type UserStorageInfo
Constants ¶
const ( NoStorageSpace string = "common.noStorageSpace" NoStoragePermission string = "common.noStoragePermission" FileTooBig string = "common.fileTooBig" CouldNotExtractFilename string = "common.couldNotExtractFilename" )
Variables ¶
var ( SpanLabelEventingType = label.Key("eventing_type") SpanLabelEventingIsCommand = label.Key("eventing_is_command") SpanLabelEventingCommand = label.Key("eventing_command") SpanLabelDiscordBotUserID = label.Key("discord_bot_user_id") SpanLabelDiscordGuildID = label.Key("discord_guild_id") SpanLabelDiscordChannelID = label.Key("discord_channel_id") SpanLabelDiscordUserID = label.Key("discord_user_id") SpanLabelDiscordMessageID = label.Key("discord_message_id") )
Functions ¶
Types ¶
type AutomodWait ¶
type AutomodWait struct {
EnvData []byte
}
type BucketType ¶
type BucketType string
BucketType specifies the scope of a bucket
const ( GuildBucketType BucketType = "guild_bucket" ChannelBucketType BucketType = "channel_bucket" UserBucketType BucketType = "user_bucket" )
defines various bucket scopes
type BucketUpdate ¶
type BucketUpdate struct { Type BucketType Tag string GuildID string KeySuffix string EnvDatas [][]byte }
type Consumer ¶
type Consumer struct {
// contains filtered or unexported fields
}
Consumer processes incoming events
type DiffChannel ¶
type DiffInvites ¶
type DiffMember ¶
type DiffWebhooks ¶
type Event ¶
type Event struct { ID string `json:"id"` CacheKey string `json:"cache_key"` Type Type `json:"type"` ReceivedAt time.Time `json:"received_at" dynamodbav:"received_at,unixtime"` BotUserID string `json:"bot_user_id"` GuildID string `json:"guild_id,omitempty"` ChannelID string `json:"channel_id,omitempty"` UserID string `json:"user_id,omitempty"` MessageID string `json:"message_id,omitempty"` SuperUser bool `json:"super_user"` SpanContext SpanContext `json:"span_context"` // discordgo event data ChannelCreate *discordgo.ChannelCreate `json:"discord_channel_create,omitempty"` ChannelDelete *discordgo.ChannelDelete `json:"discord_channel_delete,omitempty"` ChannelPinsUpdate *discordgo.ChannelPinsUpdate `json:"discord_channel_pins_update,omitempty"` ChannelUpdate *discordgo.ChannelUpdate `json:"discord_channel_update,omitempty"` GuildBanAdd *discordgo.GuildBanAdd `json:"discord_guild_ban_add,omitempty"` GuildBanRemove *discordgo.GuildBanRemove `json:"discord_guild_ban_remove,omitempty"` GuildCreate *discordgo.GuildCreate `json:"discord_guild_create,omitempty"` GuildDelete *discordgo.GuildDelete `json:"discord_guild_delete,omitempty"` GuildEmojisUpdate *discordgo.GuildEmojisUpdate `json:"discord_guild_emojis_update,omitempty"` GuildMemberAdd *discordgo.GuildMemberAdd `json:"discord_guild_member_add,omitempty"` // GuildMemberAddExtra *GuildMemberAddExtra `json:"cacophony_guild_member_add_extra,omitempty"` GuildMemberRemove *discordgo.GuildMemberRemove `json:"discord_guild_member_remove,omitempty"` GuildMemberUpdate *discordgo.GuildMemberUpdate `json:"discord_guild_member_update,omitempty"` GuildMembersChunk *discordgo.GuildMembersChunk `json:"discord_guild_members_chunk,omitempty"` GuildRoleCreate *discordgo.GuildRoleCreate `json:"discord_guild_role_create,omitempty"` GuildRoleDelete *discordgo.GuildRoleDelete `json:"discord_guild_role_delete,omitempty"` GuildRoleUpdate *discordgo.GuildRoleUpdate `json:"discord_guild_role_update,omitempty"` GuildUpdate *discordgo.GuildUpdate `json:"discord_guild_update,omitempty"` MessageCreate *discordgo.MessageCreate `json:"discord_message_create,omitempty"` MessageDelete *discordgo.MessageDelete `json:"discord_message_delete,omitempty"` MessageReactionAdd *discordgo.MessageReactionAdd `json:"discord_message_reaction_add,omitempty"` MessageReactionRemove *discordgo.MessageReactionRemove `json:"discord_message_reaction_remove,omitempty"` MessageReactionRemoveAll *discordgo.MessageReactionRemoveAll `json:"discord_message_reaction_remove_all,omitempty"` MessageUpdate *discordgo.MessageUpdate `json:"discord_message_update,omitempty"` PresenceUpdate *discordgo.PresenceUpdate `json:"discord_presence_update,omitempty"` GuildIntegrationsUpdate *discordgo.GuildIntegrationsUpdate `json:"discord_guild_integrations_update,omitempty"` MessageDeleteBulk *discordgo.MessageDeleteBulk `json:"discord_message_delete_bulk,omitempty"` UserUpdate *discordgo.UserUpdate `json:"discord_user_update,omitempty"` VoiceStateUpdate *discordgo.VoiceStateUpdate `json:"discord_voice_state_update,omitempty"` VoiceServerUpdate *discordgo.VoiceServerUpdate `json:"discord_voice_server_update,omitempty"` WebhooksUpdate *discordgo.WebhooksUpdate `json:"discord_webhooks_update,omitempty"` InteractionCreate *discordgo.InteractionCreate `json:"discord_interaction_create,omitempty"` // Cacophony Event Data BucketUpdate *BucketUpdate `json:"cacophony_bucket_update,omitempty"` ServerlistServerExpire *ServerlistServerExpire `json:"cacophony_serverlist_server_expire,omitempty"` QuickactionRemind *QuickactionRemind `json:"cacophony_quickaction_remind,omitempty"` QuestionnaireMatch *QuestionnaireMatch `json:"cacophony_questionnaire_match,omitempty"` AutomodWait *AutomodWait `json:"cacophony_automod_wait,omitempty"` EventlogUpdate *EventlogUpdate `json:"cacophony_eventlog_update,omitempty"` DiffGuild *DiffGuild `json:"cacophony_diff_guild,omitempty"` DiffMember *DiffMember `json:"cacophony_diff_member,omitempty"` DiffChannel *DiffChannel `json:"cacophony_diff_channel,omitempty"` DiffRole *DiffRole `json:"cacophony_diff_role,omitempty"` DiffEmoji *DiffEmoji `json:"cacophony_diff_emoji,omitempty"` DiffWebhooks *DiffWebhooks `json:"cacophony_diff_webhooks,omitempty"` DiffInvites *DiffInvites `json:"cacophony_diff_invites,omitempty"` // contains filtered or unexported fields }
Event represents an Event nolint: maligned
func GenerateEventFromDiscordgoEvent ¶
func GenerateEventFromDiscordgoEvent( botUserID string, eventItem interface{}, ) ( *Event, time.Duration, error, )
GenerateEventFromDiscordgoEvent generates an Event from a Discordgo Event
func (*Event) AddAttachement ¶
func (e *Event) AddAttachement(attachement *discordgo.MessageAttachment) (*FileInfo, error)
func (*Event) AddFileFromURL ¶
func (*Event) BotMention ¶
Command returns true if the event is a @Bot
func (*Event) DeleteFile ¶
func (*Event) ExceptSilent ¶
func (*Event) FeatureFlagger ¶
func (e *Event) FeatureFlagger() *featureflag.FeatureFlagger
func (*Event) FieldsVariadic ¶
FieldsVariadic gives a string of all fields starting a given position, eg `_test foo bar baz qux quux` => `e.FieldsVariadic(2) => `"bar baz qux quux"`
func (*Event) FindAnyChannel ¶
FindAnyChannel finds any kind of target channel in the command channels have to be on the current guild
func (*Event) FindChannel ¶
FindChannel finds a target text channel in the command channels have to be on the current guild
func (*Event) FindMember ¶
FindMember finds any kind of member in the command
func (*Event) FindMessageLink ¶
func (*Event) FindRole ¶
FindRole finds a target role in the command the role has to be on the current guild
func (*Event) GetUserStorageUsage ¶
func (e *Event) GetUserStorageUsage() (*UserStorageInfo, error)
func (*Event) HTTPClient ¶
func (*Event) Has ¶
func (e *Event) Has( firstPermission interfaces.Permission, permissions ...interfaces.Permission, ) bool
Has returns true if the user has all the required permissions
func (*Event) HasOr ¶
func (e *Event) HasOr( firstPermission interfaces.Permission, permissions ...interfaces.Permission, ) bool
HasOr returns true if the user has one of the required permissions
func (*Event) Localizations ¶
func (e *Event) Localizations() []interfaces.Localization
Localizations retrieves the localizations from the event
func (*Event) OriginalCommand ¶
OriginalCommand returns the first command without any modifications to casing
mainly used for custom commands module
func (*Event) Questionnaire ¶
func (e *Event) Questionnaire() *Questionnaire
func (*Event) Require ¶
func (e *Event) Require( callback func(), firstPermission interfaces.Permission, permissions ...interfaces.Permission, )
Require calls the callback if the user has all of the required permissions
func (*Event) RequireOr ¶
func (e *Event) RequireOr( callback func(), firstPermission interfaces.Permission, permissions ...interfaces.Permission, )
RequireOr calls the callback if the user has one of the required permissions
func (*Event) RespondComplex ¶
func (e *Event) RespondComplex(message *discordgo.MessageSend, values ...interface{}) ([]*discordgo.Message, error)
RespondComplex sends a message to the source channel, translates it if possible
func (*Event) Send ¶
func (e *Event) Send(channelID, message string, values ...interface{}) ([]*discordgo.Message, error)
Send sends a message to the given channel, translates it if possible TODO: check language
func (*Event) SendComplex ¶
func (e *Event) SendComplex(channelID string, message *discordgo.MessageSend, values ...interface{}) ([]*discordgo.Message, error)
SendComplex sends a message to the given channel, translates it if possible TODO: check language
func (*Event) SendComplexDM ¶
func (*Event) UpdateFileInfo ¶
func (*Event) WithContext ¶
WithContext sets the context for the event
func (*Event) WithFeatureFlagger ¶
func (e *Event) WithFeatureFlagger(featureFlagger *featureflag.FeatureFlagger)
func (*Event) WithHTTPClient ¶
func (*Event) WithLocalizations ¶
func (e *Event) WithLocalizations(localizations []interfaces.Localization)
WithLocalizations stores the localizations in the event
func (*Event) WithLogger ¶
WithLogger stores a logger in the event
func (*Event) WithPaginator ¶
WithPaginator stores the Paginator in the event
func (*Event) WithPublisher ¶
func (*Event) WithQuestionnaire ¶
func (e *Event) WithQuestionnaire(questionnaire *Questionnaire)
func (*Event) WithStorage ¶
WithStorage stores the storage bucket in the event
func (*Event) WithTokens ¶
type EventlogUpdate ¶
type FileInfo ¶
type Publisher ¶
type Publisher struct {
// contains filtered or unexported fields
}
type Questionnaire ¶
type Questionnaire struct {
// contains filtered or unexported fields
}
func NewQuestionnaire ¶
func (*Questionnaire) Redo ¶
func (q *Questionnaire) Redo(event *Event) error
Redo Will register a questionnaire event again. Helper function to easily remake questionnaires with the same payloads and keys
func (*Questionnaire) Register ¶
func (q *Questionnaire) Register( key string, filter QuestionnaireFilter, payload map[string]interface{}, ) error
func (*Questionnaire) RegisterWithExpiration ¶
func (q *Questionnaire) RegisterWithExpiration( key string, filter QuestionnaireFilter, payload map[string]interface{}, expiration time.Duration, ) error
type QuestionnaireFilter ¶
QuestionnaireFilter matches the fields with the events
type QuestionnaireMatch ¶
type QuestionnaireMatch struct { Key string Payload map[string]interface{} Filter QuestionnaireFilter }
type QuickactionRemind ¶
type ServerlistServerExpire ¶
type SpanContext ¶
func (*SpanContext) Get ¶
func (sp *SpanContext) Get(key string) string
func (*SpanContext) Set ¶
func (sp *SpanContext) Set(key, value string)
type Type ¶
type Type string
Type defines the type for a Event
const ( // Discord Events ChannelCreateType Type = "discord_channel_create" ChannelDeleteType Type = "discord_channel_delete" ChannelPinsUpdateType Type = "discord_channel_pins_update" ChannelUpdateType Type = "discord_channel_update" GuildBanAddType Type = "discord_guild_ban_add" GuildBanRemoveType Type = "discord_guild_ban_remove" GuildCreateType Type = "discord_guild_create" GuildDeleteType Type = "discord_guild_delete" GuildEmojisUpdateType Type = "discord_guild_emojis_update" GuildMemberAddType Type = "discord_guild_member_add" GuildMemberRemoveType Type = "discord_guild_member_remove" GuildMemberUpdateType Type = "discord_guild_member_update" GuildMembersChunkType Type = "discord_guild_members_chunk" GuildRoleCreateType Type = "discord_guild_role_create" GuildRoleDeleteType Type = "discord_guild_role_delete" GuildRoleUpdateType Type = "discord_guild_role_update" GuildUpdateType Type = "discord_guild_update" GuildIntegrationsUpdateType Type = "discord_guild_integrations_update" MessageCreateType Type = "discord_message_create" MessageDeleteType Type = "discord_message_delete" MessageDeleteBulkType Type = "discord_message_delete_bulk" MessageReactionAddType Type = "discord_message_reaction_add" MessageReactionRemoveType Type = "discord_message_reaction_remove" MessageReactionRemoveAllType Type = "discord_message_reaction_remove_all" MessageUpdateType Type = "discord_message_update" PresenceUpdateType Type = "discord_presence_update" UserUpdateType Type = "discord_user_update" VoiceStateUpdateType Type = "discord_voice_state_update" VoiceServerUpdateType Type = "discord_voice_server_update" WebhooksUpdateType Type = "discord_webhooks_update" InteractionCreateType Type = "discord_interaction_create" // Cacophony Events CacophonyBucketUpdate Type = "cacophony_bucket_update" CacophonyServerlistServerExpire Type = "cacophony_serverlist_server_expire" CacophonyQuickactionRemind Type = "cacophony_quickaction_remind" CacophonyQuestionnaireMatch Type = "cacophony_questionnaire_match" CacophonyAutomodWait Type = "cacophony_automod_wait" CacophonyEventlogUpdate Type = "cacophony_eventlog_update" CacophonyDiffGuild Type = "cacophony_diff_guild" CacophonyDiffMember Type = "cacophony_diff_member" CacophonyDiffChannel Type = "cacophony_diff_channel" CacophonyDiffRole Type = "cacophony_diff_role" CacophonyDiffEmoji Type = "cacophony_diff_emoji" CacophonyDiffWebhooks Type = "cacophony_diff_webhooks" CacophonyDiffInvites Type = "cacophony_diff_invites" CacophonyGuildMemberAddExtra Type = "cacophony_extra_guild_member_add" )
defines various Event Types
type UserStorageInfo ¶
Source Files ¶
- consumer.go
- consumer_handle.go
- event.go
- event_command.go
- event_config.go
- event_discord.go
- event_except.go
- event_featureflag.go
- event_find.go
- event_permissions.go
- event_span.go
- event_translate.go
- event_values.go
- generating.go
- keys.go
- new.go
- publisher.go
- pubsub.go
- questionnaire.go
- questionnaire_filter.go
- questionnaire_register.go
- storage.go
- storage_file.go
- type.go
- user_error.go