Documentation ¶
Index ¶
- Constants
- Variables
- func ParseServiceResponse(session *discordgo.Session, channelID string, response interface{}, err error)
- type AuthClient
- func (authClient *AuthClient) Authorize(guildID, userID, command, action string) bool
- func (authClient *AuthClient) DeletePermission(guildID, ID, command, action string, isRole bool) error
- func (authClient *AuthClient) GetPermissiveFlagValue(guildID string) (bool, error)
- func (authClient *AuthClient) Handle(session *discordgo.Session, message *discordgo.Message)
- func (authClient *AuthClient) Help(session *discordgo.Session, channelID string)
- func (authClient *AuthClient) IsCommand(message string) bool
- func (authClient *AuthClient) SetPermission(guildID, ID, command, action string, isRole, isAllowed bool) error
- func (authClient *AuthClient) SetPermissiveFlagValue(guildID string, value bool) error
- type BooleanCommandSuccess
- type FlamingoService
- type Pasta
- type PastaClient
- func (pastaClient *PastaClient) EditPasta(guildID, channelID, requester, alias, pasta string) (string, error)
- func (pastaClient *PastaClient) GetPasta(guildID, alias string) (string, error)
- func (pastaClient *PastaClient) Handle(session *discordgo.Session, message *discordgo.Message)
- func (pastaClient *PastaClient) Help(session *discordgo.Session, channelID string)
- func (pastaClient *PastaClient) IsCommand(message string) bool
- func (pastaClient *PastaClient) ListPasta(session *discordgo.Session, guildID, channelID, userID string)
- func (pastaClient *PastaClient) SavePasta(guildID, owner, alias, pasta string) (bool, error)
- type PastaKey
- type PermissionKey
- type PermissionObject
- type ReactClient
- func (reactClient *ReactClient) DeleteReaction(channelID, userID, alias string) (string, error)
- func (reactClient *ReactClient) GetReaction(channelID, userID, alias string) (string, error)
- func (reactClient *ReactClient) Handle(session *discordgo.Session, message *discordgo.Message)
- func (reactClient *ReactClient) Help(session *discordgo.Session, channelID string)
- func (reactClient *ReactClient) IsCommand(message string) bool
- func (reactClient *ReactClient) ListReactions(session *discordgo.Session, channelID, userID string)
- func (reactClient *ReactClient) PutReaction(channelID, userID, alias, url string) (bool, error)
- type SpoilerClient
- type Strike
- type StrikeClient
- func (strikeClient *StrikeClient) BatchGetStrikesForUser(guildID, channelID string, users []*discordgo.User) (interface{}, error)
- func (strikeClient *StrikeClient) ClearStrikesForUser(guildID, channelID, userID string) (string, error)
- func (strikeClient *StrikeClient) GetStrikesForUser(guildID, channelID, userID string) (string, error)
- func (strikeClient *StrikeClient) Handle(session *discordgo.Session, message *discordgo.Message)
- func (strikeClient *StrikeClient) Help(session *discordgo.Session, channelID string)
- func (strikeClient *StrikeClient) IsCommand(message string) bool
- func (strikeClient *StrikeClient) StrikeUser(guildID, channelID, userID string) (string, error)
- func (strikeClient *StrikeClient) SuperStrikeUser(guildID, channelID, userID string) (string, error)
- type StrikeKey
- type Template
- type TemplateClient
- func (templateClient *TemplateClient) EditTemplate(guildID, channelID, requester, alias, template string) (string, error)
- func (templateClient *TemplateClient) GetTemplate(guildID, alias, sub string) (string, error)
- func (templateClient *TemplateClient) Handle(session *discordgo.Session, message *discordgo.Message)
- func (templateClient *TemplateClient) Help(session *discordgo.Session, channelID string)
- func (templateClient *TemplateClient) IsCommand(message string) bool
- func (templateClient *TemplateClient) ListTemplate(session *discordgo.Session, guildID, channelID, userID string)
- func (templateClient *TemplateClient) SaveTemplate(guildID, owner, alias, template string) (bool, error)
- type TemplateKey
Constants ¶
const ( // CommandPrefix is the prefix the bot listens for to identify commands. CommandPrefix string = "~" )
Variables ¶
var ( // Commands is the source of truth for all available commands and command actions Commands = map[string][]string{ "strike": {"", "super", "get", "clear", "help"}, "pasta": {"get", "save", "edit", "list", "help"}, "template": {"get", "save", "edit", "list", "help"}, "react": {"get", "save", "delete", "list", "help"}, "auth": {"set", "delete", "test", "permissive", "list", "help"}, } )
Functions ¶
Types ¶
type AuthClient ¶
type AuthClient struct { DiscordClient *discordgo.Session DynamoClient *dynamodb.DynamoDB MetricsClient *flamingolog.FlamingoMetricsClient AuthServiceLogger *log.Logger AuthErrorLogger *log.Logger }
AuthClient is responsible for enforcing permissions and handling permssions update commands
func NewAuthClient ¶
func NewAuthClient(discordClient *discordgo.Session, dynamoClient *dynamodb.DynamoDB, metricsClient *flamingolog.FlamingoMetricsClient) *AuthClient
NewAuthClient constructs an AuthClient
func (*AuthClient) Authorize ¶
func (authClient *AuthClient) Authorize(guildID, userID, command, action string) bool
Authorize determines a user's eligibility to invoke a command returns true if authorized, false otherwise
func (*AuthClient) DeletePermission ¶
func (authClient *AuthClient) DeletePermission(guildID, ID, command, action string, isRole bool) error
DeletePermission deletes the records associated with a permission
func (*AuthClient) GetPermissiveFlagValue ¶
func (authClient *AuthClient) GetPermissiveFlagValue(guildID string) (bool, error)
GetPermissiveFlagValue checks for the value of the permissive flag for a guild.
func (*AuthClient) Handle ¶
func (authClient *AuthClient) Handle(session *discordgo.Session, message *discordgo.Message)
Handle parses a command message and performs the commanded action
func (*AuthClient) Help ¶
func (authClient *AuthClient) Help(session *discordgo.Session, channelID string)
Help provides assistance with the auth command by sending a help dialogue
func (*AuthClient) IsCommand ¶
func (authClient *AuthClient) IsCommand(message string) bool
IsCommand identifies a message as a potential command
func (*AuthClient) SetPermission ¶
func (authClient *AuthClient) SetPermission(guildID, ID, command, action string, isRole, isAllowed bool) error
SetPermission sets the value of a permission
func (*AuthClient) SetPermissiveFlagValue ¶
func (authClient *AuthClient) SetPermissiveFlagValue(guildID string, value bool) error
SetPermissiveFlagValue sets the value of the permissiveness flag to true for the first time
type BooleanCommandSuccess ¶
BooleanCommandSuccess is a wrapper for the return value of commands that return a boolean
type FlamingoService ¶
type FlamingoService interface { IsCommand(message string) bool Handle(session *discordgo.Session, message *discordgo.Message) }
FlamingoService is an interface for services. Services are responsible for identifying a potential invocation. If a message is identified as a command, the service is responsible for replying.
type Pasta ¶
type Pasta struct { Guild string `dynamodbav:"guild"` Alias string `dynamodbav:"alias"` Owner string `dynamodbav:"owner"` Pasta string `dynamodbav:"pasta"` }
Pasta represents the schema of a pasta stored in DDB
type PastaClient ¶
type PastaClient struct { DynamoClient *dynamodb.DynamoDB MetricsClient *flamingolog.FlamingoMetricsClient AuthClient *AuthClient PastaServiceLogger *log.Logger PastaErrorLogger *log.Logger }
PastaClient is responsible for handling "pasta" commands
func NewPastaClient ¶
func NewPastaClient(dynamoClient *dynamodb.DynamoDB, metricsClient *flamingolog.FlamingoMetricsClient, authClient *AuthClient) *PastaClient
NewPastaClient constructs a PastaClient
func (*PastaClient) EditPasta ¶
func (pastaClient *PastaClient) EditPasta(guildID, channelID, requester, alias, pasta string) (string, error)
EditPasta updates an existing pasta, provided the requester is the author of said pasta
func (*PastaClient) GetPasta ¶
func (pastaClient *PastaClient) GetPasta(guildID, alias string) (string, error)
GetPasta returns a guild pasta by alias
func (*PastaClient) Handle ¶
func (pastaClient *PastaClient) Handle(session *discordgo.Session, message *discordgo.Message)
Handle parses a command message and performs the commanded action
func (*PastaClient) Help ¶
func (pastaClient *PastaClient) Help(session *discordgo.Session, channelID string)
Help provides assistance with the pasta command by sending a help dialogue
func (*PastaClient) IsCommand ¶
func (pastaClient *PastaClient) IsCommand(message string) bool
IsCommand identifies a message as a potential command
type PastaKey ¶
PastaKey is a convenience struct for marshaling Go types into a key for DDB requests for a given pasta
type PermissionKey ¶
type PermissionKey struct { Guild string `dynamodbav:"guild"` Permission string `dynamodbav:"perm"` }
PermissionKey is a convenience struct for marshalling Go types into DDB types
type PermissionObject ¶
type PermissionObject struct { Guild string `dynamodbav:"guild"` Permission string `dynamodbav:"perm"` Allow bool `dynamodbav:"allow"` }
PermissionObject represents the schema of permissions
type ReactClient ¶
type ReactClient struct { S3Client *s3.S3 MetricsClient *flamingolog.FlamingoMetricsClient AuthClient *AuthClient ReactServiceLogger *log.Logger ReactErrorLogger *log.Logger }
ReactClient is responsible for handling "react" commands
func NewReactClient ¶
func NewReactClient(s3Client *s3.S3, metricsClient *flamingolog.FlamingoMetricsClient, authClient *AuthClient) *ReactClient
NewReactClient constructs a ReactClient
func (*ReactClient) DeleteReaction ¶
func (reactClient *ReactClient) DeleteReaction(channelID, userID, alias string) (string, error)
DeleteReaction deletes a users reaction image by alias
func (*ReactClient) GetReaction ¶
func (reactClient *ReactClient) GetReaction(channelID, userID, alias string) (string, error)
GetReaction retrieves a reaction by alias and returns the url
func (*ReactClient) Handle ¶
func (reactClient *ReactClient) Handle(session *discordgo.Session, message *discordgo.Message)
Handle parses a command message and performs the commanded action
func (*ReactClient) Help ¶
func (reactClient *ReactClient) Help(session *discordgo.Session, channelID string)
Help provides assistance with the react command by sending a help dialogue
func (*ReactClient) IsCommand ¶
func (reactClient *ReactClient) IsCommand(message string) bool
IsCommand identifies a message as a potential command
func (*ReactClient) ListReactions ¶
func (reactClient *ReactClient) ListReactions(session *discordgo.Session, channelID, userID string)
ListReactions lists all reactions a user has saved via dm
func (*ReactClient) PutReaction ¶
func (reactClient *ReactClient) PutReaction(channelID, userID, alias, url string) (bool, error)
PutReaction saves an aspect-ratio preserved thumbnail of an image for later use
type SpoilerClient ¶
type SpoilerClient struct {
AuthClient *AuthClient
}
SpoilerClient is responsible for auto-decoding spoilers
func NewSpoilerClient ¶
func NewSpoilerClient(authClient *AuthClient) *SpoilerClient
NewSpoilerClient constructs a SpoilerClient
func (*SpoilerClient) Handle ¶
func (spoilerClient *SpoilerClient) Handle(session *discordgo.Session, message *discordgo.Message)
Handle parses a command message and performs the commanded action
func (*SpoilerClient) IsCommand ¶
func (spoilerClient *SpoilerClient) IsCommand(message string) bool
IsCommand identifies a message as a potential command
type StrikeClient ¶
type StrikeClient struct { DynamoClient *dynamodb.DynamoDB MetricsClient *flamingolog.FlamingoMetricsClient AuthClient *AuthClient StrikeServiceLogger *log.Logger StrikeErrorLogger *log.Logger }
StrikeClient is responsible for handling "strike" commands
func NewStrikeClient ¶
func NewStrikeClient(dynamoClient *dynamodb.DynamoDB, metricsClient *flamingolog.FlamingoMetricsClient, authClient *AuthClient) *StrikeClient
NewStrikeClient constructs a StrikeClient
func (*StrikeClient) BatchGetStrikesForUser ¶
func (strikeClient *StrikeClient) BatchGetStrikesForUser(guildID, channelID string, users []*discordgo.User) (interface{}, error)
BatchGetStrikesForUser retreives the number of strikes for up to 20 users
func (*StrikeClient) ClearStrikesForUser ¶
func (strikeClient *StrikeClient) ClearStrikesForUser(guildID, channelID, userID string) (string, error)
ClearStrikesForUser resets the strikes of a user
func (*StrikeClient) GetStrikesForUser ¶
func (strikeClient *StrikeClient) GetStrikesForUser(guildID, channelID, userID string) (string, error)
GetStrikesForUser retreives the number of strikes a user has
func (*StrikeClient) Handle ¶
func (strikeClient *StrikeClient) Handle(session *discordgo.Session, message *discordgo.Message)
Handle parses a command message and performs the commanded action
func (*StrikeClient) Help ¶
func (strikeClient *StrikeClient) Help(session *discordgo.Session, channelID string)
Help provides assistance with the strike command by sending a help dialogue
func (*StrikeClient) IsCommand ¶
func (strikeClient *StrikeClient) IsCommand(message string) bool
IsCommand identifies a message as a potential command
func (*StrikeClient) StrikeUser ¶
func (strikeClient *StrikeClient) StrikeUser(guildID, channelID, userID string) (string, error)
StrikeUser adds 1 to the strike count of a user
func (*StrikeClient) SuperStrikeUser ¶
func (strikeClient *StrikeClient) SuperStrikeUser(guildID, channelID, userID string) (string, error)
SuperStrikeUser adds 10 to the strike count of a user
type StrikeKey ¶
type StrikeKey struct {
ID string `dynamodbav:"guild!user"`
}
StrikeKey is a convenience struct for marshalling Go types into a key for DDB requests for a given user
type Template ¶
type Template struct { Guild string `dynamodbav:"guild"` Alias string `dynamodbav:"alias"` Owner string `dynamodbav:"owner"` Template string `dynamodbav:"template"` }
Template represents the schema of a template input stored in DDB
type TemplateClient ¶
type TemplateClient struct { DynamoClient *dynamodb.DynamoDB MetricsClient *flamingolog.FlamingoMetricsClient AuthClient *AuthClient TemplateServiceLogger *log.Logger TemplateErrorLogger *log.Logger }
TemplateClient is responsible for identifying and handling template commands
func NewTemplateClient ¶
func NewTemplateClient(dynamoClient *dynamodb.DynamoDB, metricsClient *flamingolog.FlamingoMetricsClient, authClient *AuthClient) *TemplateClient
func (*TemplateClient) EditTemplate ¶
func (templateClient *TemplateClient) EditTemplate(guildID, channelID, requester, alias, template string) (string, error)
func (*TemplateClient) GetTemplate ¶
func (templateClient *TemplateClient) GetTemplate(guildID, alias, sub string) (string, error)
func (*TemplateClient) Handle ¶
func (templateClient *TemplateClient) Handle(session *discordgo.Session, message *discordgo.Message)
func (*TemplateClient) Help ¶
func (templateClient *TemplateClient) Help(session *discordgo.Session, channelID string)
func (*TemplateClient) IsCommand ¶
func (templateClient *TemplateClient) IsCommand(message string) bool
func (*TemplateClient) ListTemplate ¶
func (templateClient *TemplateClient) ListTemplate(session *discordgo.Session, guildID, channelID, userID string)
func (*TemplateClient) SaveTemplate ¶
func (templateClient *TemplateClient) SaveTemplate(guildID, owner, alias, template string) (bool, error)