Documentation ¶
Index ¶
- Constants
- Variables
- func IsOurProblem(e error) bool
- type Category
- type Contributor
- type ContributorCategory
- type DB
- func (db *DB) AddCategory(name string) (id int, err error)
- func (db *DB) AddContributor(cat int64, userID discord.UserID, name string) (err error)
- func (db *DB) AddContributorCategory(name string, roleID *discord.RoleID) (cat ContributorCategory, err error)
- func (db *DB) AddExplanation(e *Explanation) (ex *Explanation, err error)
- func (db *DB) AddFile(filename, contentType string, data []byte) (f *File, err error)
- func (db *DB) AddPronoun(p PronounSet) (id int, err error)
- func (db *DB) AddTerm(t *Term) (*Term, error)
- func (db *DB) AddToBlacklist(guildID string, channelIDs []string) (err error)
- func (db *DB) CaptureError(ctx bcr.Contexter, e error) *sentry.EventID
- func (db *DB) CategoryFromID(id int) (c *Category)
- func (db *DB) CategoryFromRole(id discord.RoleID) *ContributorCategory
- func (db *DB) CategoryID(s string) (id int, err error)
- func (db *DB) Context() (context.Context, context.CancelFunc)
- func (db *DB) ContributorCategories() ([]ContributorCategory, error)
- func (db *DB) ContributorCategory(name string) *ContributorCategory
- func (db *DB) Contributors(id int64) ([]Contributor, error)
- func (db *DB) CreateServerIfNotExists(guildID string) (exists bool, err error)
- func (db *DB) CtxInBlacklist(ctx bcr.Contexter) bool
- func (db *DB) DeleteServer(guildID string) (err error)
- func (db *DB) Error(id string) (e *Error, err error)
- func (db *DB) Exec(ctx context.Context, sql string, args ...interface{}) (pgconn.CommandTag, error)
- func (db *DB) File(id snowflake.ID) (f File, err error)
- func (db *DB) FileName(s string) (f []File, err error)
- func (db *DB) Files() (f []File, err error)
- func (db *DB) GetAllExplanations() (e []*Explanation, err error)
- func (db *DB) GetBlacklist(guildID string) (b []string, err error)
- func (db *DB) GetCategories() (c []*Category, err error)
- func (db *DB) GetCategoryTerms(id int, mask search.TermFlag) (terms []*Term, err error)
- func (db *DB) GetCmdExplanations() (e []*Explanation, err error)
- func (db *DB) GetExplanation(s string) (e *Explanation, err error)
- func (db *DB) GetPronoun(forms ...string) (sets []*PronounSet, err error)
- func (db *DB) GetTerm(id int) (t *Term, err error)
- func (db *DB) GetTerms(mask search.TermFlag) (terms []*Term, err error)
- func (db *DB) IncrementPronounUse(p *PronounSet)
- func (db *DB) InternalError(ctx bcr.Contexter, e error) error
- func (db *DB) IsBlacklisted(guildID, channelID string) (b bool)
- func (db *DB) LinkTerms(input string) string
- func (db *DB) OverrideContributorName(userID discord.UserID, override *string) (err error)
- func (db *DB) Pronouns(order PronounOrder) (p []*PronounSet, err error)
- func (db *DB) Query(ctx context.Context, sql string, args ...interface{}) (pgx.Rows, error)
- func (db *DB) QueryRow(ctx context.Context, sql string, args ...interface{}) pgx.Row
- func (db *DB) RandomPronouns() (p *PronounSet, err error)
- func (db *DB) RandomTerm(ignore []string) (t *Term, err error)
- func (db *DB) RandomTermCategory(id int, ignore []string) (t *Term, err error)
- func (db *DB) RemoveFromBlacklist(guildID, channelID string) (err error)
- func (db *DB) RemoveTerm(id int) (err error)
- func (db *DB) SetAsCommand(id int, b bool) (err error)
- func (db *DB) SetCW(id int, text string) (err error)
- func (db *DB) SetFlags(id int, flags search.TermFlag) (err error)
- func (db *DB) SetNote(id int, note string) (err error)
- func (db *DB) SetSentry(hub *sentry.Hub)
- func (db *DB) TagTerms(tag string) (t []*Term, err error)
- func (db *DB) Tags() (s []string, err error)
- func (db *DB) TermCount() (count int)
- func (db *DB) TermEmbed(t *Term) discord.Embed
- func (db *DB) TermName(n string) (t []*Term, err error)
- func (db *DB) TermsSince(d time.Time) (t []*Term, err error)
- func (db *DB) Time(s snowflake.ID) time.Time
- func (db *DB) UntaggedTerms() (t []*Term, err error)
- func (db *DB) UpdateAliases(id int, aliases []string) (err error)
- func (db *DB) UpdateContributorName(userID discord.UserID, newName string) (err error)
- func (db *DB) UpdateDesc(id int, desc string) (err error)
- func (db *DB) UpdateImage(id int, img string) (err error)
- func (db *DB) UpdateSource(id int, source string) (err error)
- func (db *DB) UpdateTags(id int, tags []string) (err error)
- func (db *DB) UpdateTitle(id int, title string) (err error)
- type Error
- type Explanation
- type File
- type PronounOrder
- type PronounSet
- type Term
Constants ¶
const DisputedText = "" /* 248-byte string literal not displayed */
DisputedText ...
const EmbedColour = 0xd14171
EmbedColour is the embed colour used throughout the bot
Variables ¶
var ( ErrorAlreadyBlacklisted = errors.New("channel is already blacklisted") ErrorNotBlacklisted = errors.New("channel is not blacklisted") )
Errors for setting the blacklist
var ( ErrMoreThanOneRow = errors.New("more than one row returned") ErrTooManyForms = errors.New("too many forms given") ErrNoForms = errors.New("no forms given") )
Errors ...
var Debug = func(template string, args ...interface{}) {}
Debug is a debug logging function
var (
ErrorNoRowsAffected = errors.New("no rows affected")
)
Errors related to database operations
Functions ¶
func IsOurProblem ¶
IsOurProblem checks if an error is "our problem", as in, should be in the logs and reported to Sentry. Will be expanded eventually once we get more insight into what type of errors we get.
Types ¶
type Contributor ¶
Contributor is a single contributor.
type ContributorCategory ¶
ContributorCategory is a category of contributors, optionally with a role.
type DB ¶
type DB struct { // Embedded search methods search.Searcher *pgxpool.Pool GuildCache *ttlcache.Cache Config common.Config Snowflake *snowflake.Generator Timeout time.Duration TermBaseURL string IncFunc func() // contains filtered or unexported fields }
Db ...
func (*DB) AddContributor ¶
AddContributor adds a contributor.
func (*DB) AddContributorCategory ¶
func (db *DB) AddContributorCategory(name string, roleID *discord.RoleID) (cat ContributorCategory, err error)
AddContributorCategory adds a contributor category.
func (*DB) AddExplanation ¶
func (db *DB) AddExplanation(e *Explanation) (ex *Explanation, err error)
AddExplanation adds an explanation to the database
func (*DB) AddPronoun ¶
func (db *DB) AddPronoun(p PronounSet) (id int, err error)
AddPronoun adds a pronoun set, returning the ID
func (*DB) AddToBlacklist ¶
AddToBlacklist adds the given channelID to the blacklist for guildID
func (*DB) CaptureError ¶
CaptureError captures an error with additional context
func (*DB) CategoryFromRole ¶
func (db *DB) CategoryFromRole(id discord.RoleID) *ContributorCategory
CategoryFromRole gets a contributor category from a role ID.
func (*DB) CategoryID ¶
CategoryID gets the ID from a category name
func (*DB) Context ¶
func (db *DB) Context() (context.Context, context.CancelFunc)
Context is a convenience method to get a context.Context with the database's timeout
func (*DB) ContributorCategories ¶
func (db *DB) ContributorCategories() ([]ContributorCategory, error)
ContributorCategories ...
func (*DB) ContributorCategory ¶
func (db *DB) ContributorCategory(name string) *ContributorCategory
ContributorCategory ...
func (*DB) Contributors ¶
func (db *DB) Contributors(id int64) ([]Contributor, error)
Contributors ...
func (*DB) CreateServerIfNotExists ¶
CreateServerIfNotExists returns true if the server exists
func (*DB) CtxInBlacklist ¶
CtxInBlacklist is a wrapper around IsBlacklisted for bcr
func (*DB) DeleteServer ¶
DeleteServer deletes a server's database entry
func (*DB) GetAllExplanations ¶
func (db *DB) GetAllExplanations() (e []*Explanation, err error)
GetAllExplanations ...
func (*DB) GetBlacklist ¶
GetBlacklist returns the channel blacklist for guildID
func (*DB) GetCategories ¶
GetCategories ...
func (*DB) GetCategoryTerms ¶
GetCategoryTerms gets terms by category
func (*DB) GetCmdExplanations ¶
func (db *DB) GetCmdExplanations() (e []*Explanation, err error)
GetCmdExplanations ...
func (*DB) GetExplanation ¶
func (db *DB) GetExplanation(s string) (e *Explanation, err error)
GetExplanation ...
func (*DB) GetPronoun ¶
func (db *DB) GetPronoun(forms ...string) (sets []*PronounSet, err error)
GetPronoun gets a pronoun from the database gods this function is shit but idc, if it works it works
func (*DB) IncrementPronounUse ¶
func (db *DB) IncrementPronounUse(p *PronounSet)
func (*DB) InternalError ¶
InternalError sends an error message and logs the error to the database
func (*DB) IsBlacklisted ¶
IsBlacklisted returns true if a channel is blacklisted
func (*DB) OverrideContributorName ¶
OverrideContributorName overrides the contributor's name.
func (*DB) Pronouns ¶
func (db *DB) Pronouns(order PronounOrder) (p []*PronounSet, err error)
Pronouns ...
func (*DB) RandomPronouns ¶
func (db *DB) RandomPronouns() (p *PronounSet, err error)
RandomPronouns gets a random pronoun set from the database
func (*DB) RandomTerm ¶
RandomTerm gets a random term from the database
func (*DB) RandomTermCategory ¶
RandomTermCategory gets a random term from the database from the specified category
func (*DB) RemoveFromBlacklist ¶
RemoveFromBlacklist removes the given channelID from the blacklist for guildID
func (*DB) RemoveTerm ¶
RemoveTerm removes a term from the database
func (*DB) TermsSince ¶
TermsSince returns all terms added since the specified date
func (*DB) UpdateAliases ¶
UpdateAliases updates the aliases for a term
func (*DB) UpdateContributorName ¶
UpdateContributorName updates the contributor's Discord name.
func (*DB) UpdateDesc ¶
UpdateDesc updates the description for a term
func (*DB) UpdateImage ¶
UpdateImage updates the image for a term
func (*DB) UpdateSource ¶
UpdateSource updates the source for a term
func (*DB) UpdateTags ¶
UpdateTags updates the tags for a term
type Error ¶
type Error struct { ID uuid.UUID Command string UserID discord.UserID Channel discord.ChannelID Error string Time time.Time }
Error ...
type Explanation ¶
type Explanation struct { ID int `json:"id"` Name string `json:"name"` Aliases []string `json:"aliases"` Description string `json:"description"` Created time.Time `json:"created"` AsCommand bool `json:"-"` }
Explanation is a single explanation
type File ¶
type File struct { ID snowflake.ID Filename string ContentType string Source string Description string Data []byte // contains filtered or unexported fields }
File is a single file
type PronounOrder ¶
type PronounOrder int
const ( AlphabeticPronounOrder PronounOrder = iota UsesPronounOrder RandomPronounOrder )
type PronounSet ¶
type PronounSet struct { ID int `json:"id"` Subjective string `json:"subjective"` Objective string `json:"objective"` PossDet string `json:"possessive_determiner"` PossPro string `json:"possessive_pronoun"` Reflexive string `json:"reflexive"` Uses int64 `json:"uses"` Sorting int `json:"-"` }
PronounSet is a single set of pronouns
func (PronounSet) String ¶
func (p PronounSet) String() string
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package search contains types for searching for terms.
|
Package search contains types for searching for terms. |
pg
Package pg implements the search.Searcher interface with the existing PostgreSQL database.
|
Package pg implements the search.Searcher interface with the existing PostgreSQL database. |
typesense
Package typesense implements search methods with a Typesense search server.
|
Package typesense implements search methods with a Typesense search server. |