modelsx

package
v0.0.0-...-fb49ba0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 7, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package modelsx provides extensions for the models package.

Index

Constants

View Source
const DefaultPrefix = "!"

DefaultPrefix is the default prefix inserted for new channels. The default prefix is not NULL, as changing it based on some config would break users who had previously been using the original prefix.

Variables

This section is empty.

Functions

func DeleteChannel

func DeleteChannel(ctx context.Context, exec boil.ContextExecutor, id int64) error

DeleteChannel deletes a channel and every row in every table which references it. Must be done in a transaction, as the steps it takes are extremely likely to voilate constraints.

Ensure other state (like repeats) are refreshed after using this function (or otherwise do not take effect if their data is not found).

Must be kept in sync with migrations to keep this effective.

func DeleteCommandInfo

func DeleteCommandInfo(ctx context.Context, exec boil.ContextExecutor, info *models.CommandInfo) (repeated *models.RepeatedCommand, scheduled *models.ScheduledCommand, err error)

DeleteCommandInfo deletes all references to a specific command from the database.

func FindCommand

func FindCommand(ctx context.Context, exec boil.Executor, id int64, name string, forUpdate bool) (info *models.CommandInfo, commandMsg null.String, found bool, err error)

FindCommand finds a command for a given channel.

func ListActiveChannels

func ListActiveChannels(ctx context.Context, exec boil.Executor, botName string) ([]string, error)

ListActiveChannels returns a list of active IRC channels (with # prefix) for the specified bot.

func ModelToToken

func ModelToToken(tt *models.TwitchToken) *oauth2.Token

ModelToToken converts a token model to an oauth2 token for use in an HTTP client.

func NewChannel

func NewChannel(twitchID int64, name, displayName string, botName string) *models.Channel

NewChannel creates a new Channel with the defaults set.

func TokenToModel

func TokenToModel(tok *oauth2.Token, id int64, botName null.String, scopes []string) *models.TwitchToken

TokenToModel converts a Twitch user's oauth2 token to a model for insertion.

func TokenToModelWithoutPreservedColumns

func TokenToModelWithoutPreservedColumns(tok *oauth2.Token, id int64) *models.TwitchToken

TokenToModelWithoutPreservedColumns converts a Twitch user's oauth2 token to a model for insertion, without BotName and Scopes.

func UpsertToken

func UpsertToken(ctx context.Context, exec boil.ContextExecutor, tt *models.TwitchToken) error

UpsertToken inserts the token into the database, or inserts all columns as written in the model.

func UpsertTokenWithoutPreservedColumns

func UpsertTokenWithoutPreservedColumns(ctx context.Context, exec boil.ContextExecutor, tt *models.TwitchToken) error

UpsertTokenWithoutPreservedColumns upserts a token without BotName and Scopes.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL