Documentation ¶
Index ¶
- Variables
- func AddReplacementHistory(d DBLike, event *ReplacementHistory) error
- func AliasUpdater(d DBLike, input chan apitypes.TAliasData) error
- func ClearAliasIndex(d DBLike) error
- func ClearCatsException(d DBLike, tag string) error
- func CommitAndYieldErrorf(format string, args ...interface{}) error
- func CountTags(d DBLike, sfx chan string) error
- func DBInit(dburl string) error
- func DefaultTransact(callback func(DBLike) error) error
- func DelTagTypoByTag(d DBLike, typo TypoData) error
- func DeleteBlitByName(d DBLike, name string) error
- func DeleteCatByTagNames(d DBLike, cat CatData) error
- func DeleteReplacement(d DBLike, id int64) error
- func DeleteUserCreds(d DBLike, id tgtypes.UserID) error
- func DeleteUserSettings(d DBLike, id tgtypes.UserID) error
- func DeleteUserTagRules(d DBLike, id tgtypes.UserID) error
- func EnumerateAllBlits(d DBLike) (map[string]bool, error)
- func EnumerateAllTags(d DBLike, orderByCount bool) (apitypes.TTagInfoArray, error)
- func EnumerateCatsExceptions(d DBLike) ([]string, error)
- func EraseDialogPost(d DBLike, msg_id tgtypes.MsgID, chat_id tgtypes.ChatID) error
- func FindCachedMp4ForWebm(d DBLike, md5 string) (*tgtypes.FileID, error)
- func GetAliasedTags(d DBLike) (apitypes.TTagInfoArray, error)
- func GetAliasesFor(d DBLike, tag string) (apitypes.TTagInfoArray, error)
- func GetBlits(d DBLike, yes, no, wild bool) ([]BlitData, []BlitData, []BlitData, error)
- func GetCats(d DBLike, yes, no bool) ([]CatData, []CatData, error)
- func GetHighestPostID(d DBLike) (int, error)
- func GetLastTag(d DBLike) (*apitypes.TTagData, error)
- func GetMostRecentlyUpdatedPost(d DBLike) (*apitypes.TPostInfo, error)
- func GetReplacementHistorySince(d DBLike, post_ids []int, since time.Time) (map[ReplacementHistoryKey]ReplacementHistory, error)
- func GetTag(tx *sql.Tx, id int) (*apitypes.TTagData, error)
- func GetTagByName(d DBLike, name string, createPhantom bool) (*apitypes.TTagData, error)
- func GetTagTypos(d DBLike, tag string) (map[string]TypoData, error)
- func GetTags(tx *sql.Tx, ids []int) (apitypes.TTagInfoArray, error)
- func GetTagsWithCountEqual(tx *sql.Tx, count int) (apitypes.TTagInfoArray, error)
- func GetTagsWithCountGreater(tx *sql.Tx, count int) (apitypes.TTagInfoArray, error)
- func GetTagsWithCountLess(tx *sql.Tx, count int) (apitypes.TTagInfoArray, error)
- func GetUserTagRules(d DBLike, id tgtypes.UserID, name string) (string, error)
- func ImportPostTagsFromNameToID(d DBLike, sfx chan string) error
- func MarkBlit(tx *sql.Tx, id int, mark bool) error
- func MarkBlitByName(d DBLike, name string, mark bool) error
- func MarkPostDeleted(d DBLike, post_id int) error
- func NewCommitAndYield(message string) error
- func NewRollbackAndMask(message string) error
- func NewTxRequired(message string) error
- func PaginatedGetAllReplacements(d DBLike, page_size int) chan ReplacersPage
- func PaginatedPostsById(d DBLike, ids []int, pageSize int) chan PostsPage
- func PostByID(d DBLike, id int) (*apitypes.TPostInfo, error)
- func PostByMD5(d DBLike, md5 string) (*apitypes.TPostInfo, error)
- func PostDeleter(d DBLike, input chan []int) error
- func PostUpdater(d DBLike, input chan apitypes.TPostInfo) error
- func PostsById(d DBLike, ids []int) ([]apitypes.TPostInfo, error)
- func PostsWithTag(d DBLike, tag apitypes.TTagData, includeDeleted bool) (apitypes.TPostInfoArray, error)
- func PrefixedTagToTypedTag(name string) (string, int)
- func RecalculateAliasedCounts(d DBLike) error
- func RollbackAndMaskErrorf(format string, args ...interface{}) error
- func SaveCachedMp4ForWebm(d DBLike, md5 string, id tgtypes.FileID) error
- func SavePromptPost(d DBLike, id int, x *PromptPostInfo) error
- func SetCatByTagNames(d DBLike, cat CatData, marked, autofix bool) error
- func SetCatsException(d DBLike, tag string) error
- func SetTagTypoByTag(d DBLike, typo TypoData, marked, autofix bool) error
- func TagUpdater(d DBLike, input chan apitypes.TTagData) error
- func Transact(db_connection *sql.DB, callback func(DBLike) error) (err error)
- func UpdatePost(d DBLike, post apitypes.TPostInfo) error
- func UpdateReplacement(d DBLike, repl Replacer) error
- func WrapExec(_ sql.Result, err error) error
- func WriteDialogPost(d DBLike, dialog_id tgtypes.DialogID, msg_id tgtypes.MsgID, ...) error
- func WriteUserCreds(d DBLike, creds UserCreds) error
- func WriteUserSettings(d DBLike, s *UserSettings) error
- func WriteUserTagRules(d DBLike, id tgtypes.UserID, name, rules string) error
- type BlitData
- type CatData
- type CommitAndYield
- type CorrectionMode
- type DBLike
- type DialogPost
- type PostSuggestedEdit
- func (this PostSuggestedEdit) Append(other PostSuggestedEdit) PostSuggestedEdit
- func (this *PostSuggestedEdit) Apply()
- func (this *PostSuggestedEdit) Deselect(from string, index int)
- func (this *PostSuggestedEdit) DeselectAll()
- func (this *PostSuggestedEdit) DeselectDirect(api_string string)
- func (this PostSuggestedEdit) Flatten() tags.TagDiff
- func (this PostSuggestedEdit) GetChangeToApply() tags.TagDiff
- func (this *PostSuggestedEdit) Scan(value interface{}) error
- func (this *PostSuggestedEdit) Select(from string, index int)
- func (this *PostSuggestedEdit) SelectAll()
- func (this *PostSuggestedEdit) SelectAutofix()
- func (this *PostSuggestedEdit) SelectDirect(api_string string)
- func (this PostSuggestedEdit) Value() (driver.Value, error)
- type PostsPage
- type PromptPostInfo
- type Queryable
- type ReplacementHistory
- type ReplacementHistoryKey
- type Replacer
- type ReplacerMatcher
- type ReplacersPage
- type RequiresTransaction
- type RollbackAndMask
- type TypoData
- type UserCreds
- type UserSettings
Constants ¶
This section is empty.
Variables ¶
var Db_pool *sql.DB
var ErrNoLogin error = NewCommitAndYield("no stored credentials for telegram user")
var ErrNoTag = errors.New("no corresponding tag exists")
Functions ¶
func AddReplacementHistory ¶
func AddReplacementHistory(d DBLike, event *ReplacementHistory) error
func AliasUpdater ¶
func AliasUpdater(d DBLike, input chan apitypes.TAliasData) error
func ClearAliasIndex ¶
func ClearCatsException ¶
func CommitAndYieldErrorf ¶
CommitAndYieldErrorf produces an unwrappable error (see fmt.Errorf) which implements CommitAndYield.
func DBInit ¶
initialize the DAL. Closing it might be important at some point, but who cares right now.
func DefaultTransact ¶
A convenience specialization of Transact which automatically uses Db_pool.
func DelTagTypoByTag ¶
func DeleteBlitByName ¶
func DeleteCatByTagNames ¶
func DeleteReplacement ¶
func EnumerateAllTags ¶
func EnumerateAllTags(d DBLike, orderByCount bool) (apitypes.TTagInfoArray, error)
func EnumerateCatsExceptions ¶
func EraseDialogPost ¶
func FindCachedMp4ForWebm ¶
func GetAliasedTags ¶
func GetAliasedTags(d DBLike) (apitypes.TTagInfoArray, error)
func GetAliasesFor ¶
func GetAliasesFor(d DBLike, tag string) (apitypes.TTagInfoArray, error)
func GetHighestPostID ¶
func GetReplacementHistorySince ¶
func GetReplacementHistorySince(d DBLike, post_ids []int, since time.Time) (map[ReplacementHistoryKey]ReplacementHistory, error)
func GetTagByName ¶
Looks up a tag by its name. Has a special option `createPhantom`, which when set, will create a "phantom tag" in the database. the type will be inferred from the tag name (a prefix can be used to specify its type, see PrefixedTagToTypedTag. It is created with a negative tag_id (all such tags with negative IDs are phantoms). Phantom tags have all of the hallmarks of real tags but don't exist server-side. When the bot fetches an update that includes the phantom tag, its `tag_id` will be updated to reflect the true id (thus promoting it from a phantom tag to a real one) and will chain this update to all tables that use foreign keys to refer to tag_ids.
func GetTagsWithCountEqual ¶
func GetTagsWithCountGreater ¶
func GetTagsWithCountLess ¶
func GetUserTagRules ¶
func MarkPostDeleted ¶
func NewCommitAndYield ¶
NewCommitAndYield produces an error which implements CommitAndYield.
func NewRollbackAndMask ¶
NewRollbackAndMask produces an error which implements RollbackAndMask.
func NewTxRequired ¶
TxRequiredError produces an error which implements RequiresTransaction.
func PaginatedGetAllReplacements ¶
func PaginatedGetAllReplacements(d DBLike, page_size int) chan ReplacersPage
func PostDeleter ¶
func PostsWithTag ¶
func PrefixedTagToTypedTag ¶
func RollbackAndMaskErrorf ¶
RollbackAndMaskErrorf produces an unwrappable error (see fmt.Errorf) which implements RollbackAndMask.
func SaveCachedMp4ForWebm ¶
func SavePromptPost ¶
func SavePromptPost(d DBLike, id int, x *PromptPostInfo) error
func SetCatsException ¶
func Transact ¶
Transact wraps the provided callback in a transaction. See the package documentation for usage examples.
func UpdateReplacement ¶
func WriteDialogPost ¶
func WriteUserCreds ¶
func WriteUserSettings ¶
func WriteUserSettings(d DBLike, s *UserSettings) error
Types ¶
type CatData ¶
type CommitAndYield ¶
type CommitAndYield interface{ Yielded() }
Returning a CommitAndYield from within a function called by Transact produces special behavior, described by Transact's docs.
type CorrectionMode ¶
type CorrectionMode int
const AutoFix CorrectionMode = 3
const Ignore CorrectionMode = 1
const Prompt CorrectionMode = 2
const Untracked CorrectionMode = 0
func (CorrectionMode) Display ¶
func (this CorrectionMode) Display() string
type DBLike ¶
type DBLike interface { InTransaction() bool EnsureTransaction(*error) func() Enter(func(Queryable) error) error }
DBLike is a generic interface that encapsulates a database, and optionally also a transaction.
func DefaultNoTx ¶
func DefaultNoTx() DBLike
DefaultNoTx, like DefaultTransact, is a convenience wrapper for NoTx using the default database Db_pool.
type DialogPost ¶
type DialogPost struct { MsgId tgtypes.MsgID MsgTs time.Time ChatId tgtypes.ChatID DialogId tgtypes.DialogID DialogData []byte }
func FetchDialogPost ¶
type PostSuggestedEdit ¶
type PostSuggestedEdit struct { Prompt tags.TagDiffArray `json:"prompt"` AutoFix tags.TagDiffArray `json:"autofix"` SelectedEdits map[string]bool `json:"selected_edits"` AppliedEdits map[string]bool `json:"applied_edits"` Represents []int64 `json:"represents"` }
func (PostSuggestedEdit) Append ¶
func (this PostSuggestedEdit) Append(other PostSuggestedEdit) PostSuggestedEdit
merge two edit lists, with certain requirements. the edit list of `this` must remain index-stable, that is to say, items in its prompt and autofix lists should keep the same indices in the output. this allows us to merge multiple edit lists onto one, while not breaking the user experience by making buttons move around if we edit a post while they're pushing them.
func (*PostSuggestedEdit) Apply ¶
func (this *PostSuggestedEdit) Apply()
func (*PostSuggestedEdit) Deselect ¶
func (this *PostSuggestedEdit) Deselect(from string, index int)
do nothing if an invalid selector is specified
func (*PostSuggestedEdit) DeselectAll ¶
func (this *PostSuggestedEdit) DeselectAll()
func (*PostSuggestedEdit) DeselectDirect ¶
func (this *PostSuggestedEdit) DeselectDirect(api_string string)
func (PostSuggestedEdit) Flatten ¶
func (this PostSuggestedEdit) Flatten() tags.TagDiff
func (PostSuggestedEdit) GetChangeToApply ¶
func (this PostSuggestedEdit) GetChangeToApply() tags.TagDiff
func (*PostSuggestedEdit) Scan ¶
func (this *PostSuggestedEdit) Scan(value interface{}) error
func (*PostSuggestedEdit) Select ¶
func (this *PostSuggestedEdit) Select(from string, index int)
do nothing if an invalid selector is specified
func (*PostSuggestedEdit) SelectAll ¶
func (this *PostSuggestedEdit) SelectAll()
func (*PostSuggestedEdit) SelectAutofix ¶
func (this *PostSuggestedEdit) SelectAutofix()
func (*PostSuggestedEdit) SelectDirect ¶
func (this *PostSuggestedEdit) SelectDirect(api_string string)
type PromptPostInfo ¶
type PromptPostInfo struct { PostId int PostType string PostURL string SampleURL string PostMd5 string PostWidth int PostHeight int MsgId tgtypes.MsgID ChatId tgtypes.ChatID Timestamp time.Time Captioned bool Edit *PostSuggestedEdit }
func FindPromptPost ¶
func FindPromptPost(d DBLike, id int) (*PromptPostInfo, error)
func FindPromptPostByMessage ¶
func FindPromptPostsOlderThan ¶
func FindPromptPostsOlderThan(d DBLike, time_ago time.Duration) ([]PromptPostInfo, error)
type Queryable ¶
type Queryable interface { Exec(string, ...interface{}) (sql.Result, error) ExecContext(context.Context, string, ...interface{}) (sql.Result, error) Query(string, ...interface{}) (*sql.Rows, error) QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error) QueryRow(string, ...interface{}) *sql.Row QueryRowContext(context.Context, string, ...interface{}) *sql.Row }
Queryable is compatible with query/exec methods of both *sql.DB and *sql.Tx.
type ReplacementHistory ¶
type ReplacementHistoryKey ¶
type Replacer ¶
type Replacer struct { Id int64 `dml:"replace_id"` MatchSpec string `dml:"match_spec"` ReplaceSpec string `dml:"replace_spec"` Autofix bool `dml:"autofix"` }
func GetReplacements ¶
func (*Replacer) Matcher ¶
func (this *Replacer) Matcher() ReplacerMatcher
type ReplacerMatcher ¶
type ReplacersPage ¶
type RequiresTransaction ¶
type RequiresTransaction interface{ RequiresTx() }
Used to flag to callers of functions which are called without transactions that they failed due to the absence of a transaction but could succeed if properly transacted.
type RollbackAndMask ¶
type RollbackAndMask interface{ Masked() }
Returning a RollbackAndMask from within a function called by Transact produces special behavior, described by Transact's docs.
type UserCreds ¶
type UserSettings ¶
type UserSettings struct { TelegramId tgtypes.UserID AgeStatus types.AgeStatus RatingMode types.RatingMode BlacklistMode types.BlacklistMode }
func GetUserSettings ¶
func GetUserSettings(d DBLike, telegram_id tgtypes.UserID) (*UserSettings, error)