models

package
v0.0.0-...-70c62f1 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2022 License: AGPL-3.0 Imports: 10 Imported by: 1

Documentation

Index

Constants

View Source
const (
	SessionIdKey = "sid"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Alert

type Alert struct {
	Enabled bool   `bson:"enabled" json:"enabled"`
	Message string `bson:"message" json:"message"`
}

type Alerts

type Alerts struct {
	dataful.BaseModel `bson:",inline"`
	Channel           primitive.ObjectID `bson:"channel" json:"channel"`

	Sub           Alert `bson:"sub" json:"sub"`
	Resub         Alert `bson:"resub" json:"resub"`
	SubGift       Alert `bson:"subGift" json:"subGift"`
	CommunityGift Alert `bson:"communityGift" json:"communityGift"`
	Follow        Alert `bson:"follow" json:"follow"`
	Raid          Alert `bson:"raid" json:"raid"`
	Bits          Alert `bson:"bits" json:"bits"`
}

func NewAlerts

func NewAlerts(r dataful.Repository) *Alerts

type CapsFilter

type CapsFilter struct {
	FilterCommon  `bson:",inline"`
	MinChars      int     `bson:"minChars" json:"minChars"`
	MaxCount      int     `bson:"maxCount" json:"maxCount"`
	MaxPercentage float64 `bson:"maxPercentage" json:"maxPercentage"`
}

func NewCapsFilter

func NewCapsFilter() CapsFilter

type Channel

type Channel struct {
	dataful.BaseModel `bson:",inline"`

	ChannelId       string    `bson:"channelId" json:"channelId"`
	BroadcasterName string    `bson:"broadcasterName" json:"broadcasterName"`
	Language        string    `bson:"language" json:"language"`
	GameId          string    `bson:"gameId" json:"gameId"`
	GameName        string    `bson:"gameName" json:"gameName"`
	Title           string    `bson:"title" json:"title"`
	Joined          bool      `bson:"joined" json:"joined"`
	Silenced        bool      `bson:"silenced" json:"silenced"`
	AccessToken     string    `bson:"accessToken,omitempty" json:"-"`
	RefreshToken    string    `bson:"refreshToken,omitempty" json:"-"`
	Prefix          string    `bson:"prefix" json:"prefix"`
	Live            bool      `bson:"live" json:"live"`
	Shard           int       `bson:"shard" json:"shard"`
	Authenticated   bool      `bson:"authenticated" json:"authenticated"`
	StartedAt       time.Time `bson:"startedAt,omitempty" json:"startedAt,omitempty"`
	EndedAt         time.Time `bson:"endedAt,omitempty" json:"endedAt,omitempty"`
	Moderator       bool      `bson:"moderator" json:"moderator"`
}

func NewChannel

func NewChannel(r dataful.Repository) *Channel

func (*Channel) Create

func (c *Channel) Create(ctx context.Context) error

func (*Channel) Delete

func (c *Channel) Delete(ctx context.Context) error

func (*Channel) LoadByChannelId

func (c *Channel) LoadByChannelId(ctx context.Context, channelId string) error

func (*Channel) LoadByChannelName

func (c *Channel) LoadByChannelName(ctx context.Context, name string) error

func (*Channel) LoadBylId

func (c *Channel) LoadBylId(ctx context.Context, id primitive.ObjectID) error

func (*Channel) Update

func (c *Channel) Update(ctx context.Context) error

type Command

type Command struct {
	dataful.BaseModel `bson:",inline"`
	Channel           primitive.ObjectID `bson:"channel" json:"channel"`

	Name       string                        `bson:"name" json:"name"`
	Enabled    bool                          `bson:"enabled" json:"enabled"`
	Cooldowns  embeddables.Cooldown          `bson:"cooldowns" json:"cooldowns"`
	Role       embeddables.UserRole          `bson:"role" json:"role"`
	Stream     embeddables.StreamStatus      `bson:"stream" json:"stream"`
	Response   string                        `bson:"response" json:"response"`
	Aliases    []string                      `bson:"aliases" json:"aliases"`
	HasVar     bool                          `bson:"hasVar" json:"-"`
	Attributes embeddables.CommandAttributes `bson:"attributes" json:"attributes"`
	Timer      embeddables.Timer             `bson:"timer" json:"timer"`
}

func NewCommand

func NewCommand(r dataful.Repository) *Command

func (*Command) Create

func (c *Command) Create(ctx context.Context) error

func (*Command) Delete

func (c *Command) Delete(ctx context.Context) error

func (*Command) LoadBylId

func (c *Command) LoadBylId(ctx context.Context, id primitive.ObjectID) error

func (*Command) Update

func (c *Command) Update(ctx context.Context) error

type CommandList

type CommandList struct {
	List []*Command `json:"list"`
	// contains filtered or unexported fields
}

func NewCommandList

func NewCommandList(r dataful.Repository) *CommandList

func (*CommandList) GetList

func (cl *CommandList) GetList() interface{}

func (*CommandList) LoadAllByChannel

func (cl *CommandList) LoadAllByChannel(ctx context.Context, channel primitive.ObjectID) error

LoadAllByChannel gets all commands for given channel.

func (*CommandList) Loaded

func (cl *CommandList) Loaded() bool

func (*CommandList) SetLoaded

func (cl *CommandList) SetLoaded()

type EmojisFilter

type EmojisFilter struct {
	FilterCommon `bson:",inline"`
	MaxCount     int `bson:"maxCount" json:"maxCount"`
}

func NewEmojisFilter

func NewEmojisFilter() EmojisFilter

type EmotesFilter

type EmotesFilter struct {
	FilterCommon `bson:",inline"`
	MaxCount     int `bson:"maxCount" json:"maxCount"`
}

func NewEmotesFilter

func NewEmotesFilter() EmotesFilter

type EnglishFilter

type EnglishFilter struct {
	FilterCommon  `bson:",inline"`
	MinChars      int     `bson:"minChars" json:"minChars"`
	MaxCount      int     `bson:"maxCount" json:"maxCount"`
	MaxPercentage float64 `bson:"maxPercentage" json:"maxPercentage"`
}

func NewEnglishFilter

func NewEnglishFilter() EnglishFilter

type FilterCommon

type FilterCommon struct {
	Enabled          bool                     `bson:"enabled" json:"enabled"`
	Description      string                   `bson:"description" json:"description"`
	Stream           embeddables.StreamStatus `bson:"stream" json:"stream"`
	DisableOnRaid    bool                     `bson:"disableOnRaid" json:"disableOnRaid"`
	Announce         bool                     `bson:"announce" json:"announce"`
	AnnounceCooldown int                      `bson:"announceCooldown" json:"announceCooldown"`
	Message          string                   `bson:"message" json:"message"`
	TimeoutDuration  int                      `bson:"timeoutDuration" json:"timeoutDuration"`
	ExponentialBase  int                      `bson:"exponentialBase" json:"exponentialBase"`
	OffenseTimeout   int                      `bson:"offenseTimeout" json:"offenseTimeout"`
	MaxRole          embeddables.UserRole     `bson:"maxRole" json:"maxRole"`
}

func NewFilterCommon

func NewFilterCommon(description, message string) FilterCommon

type Filters

type Filters struct {
	dataful.BaseModel `bson:",inline"`
	Channel           primitive.ObjectID `bson:"channel" json:"channel"`

	Caps       CapsFilter       `bson:"caps" json:"caps"`
	Symbols    SymbolsFilter    `bson:"symbols" json:"symbols"`
	Zalgo      ZalgoFilter      `bson:"zalgo" json:"zalgo"`
	English    EnglishFilter    `bson:"english" json:"english"`
	Length     LengthFilter     `bson:"length" json:"length"`
	Emotes     EmotesFilter     `bson:"emotes" json:"emotes"`
	Emojis     EmojisFilter     `bson:"emojis" json:"emojis"`
	SoloSpam   SoloSpamFilter   `bson:"soloSpam" json:"soloSpam"`
	Repetition RepetitionFilter `bson:"repetition" json:"repetition"`
	Link       LinkFilter       `bson:"link" json:"link"`
}

func NewFilters

func NewFilters(r dataful.Repository) *Filters

func (*Filters) Create

func (f *Filters) Create(ctx context.Context) error

func (*Filters) LoadByChannel

func (f *Filters) LoadByChannel(ctx context.Context, channel primitive.ObjectID) error

func (*Filters) Update

func (f *Filters) Update(ctx context.Context) error

type JWT

type JWT struct {
	SessionId string
	// contains filtered or unexported fields
}

func NewJWT

func NewJWT(signKey []byte, algorithm jwa.SignatureAlgorithm) *JWT

func (*JWT) Decode

func (j *JWT) Decode(tokenString string) (jwt.Token, error)

Decode parses a token using provided jwt sign key and algorithm. It also validates the claims of the token.

func (*JWT) Encode

func (j *JWT) Encode(sessionId string, expiry time.Time) (string, error)

Encode creates a new JWT, adds in the claims, and signs the token. It returns signed token string.

type LengthFilter

type LengthFilter struct {
	FilterCommon `bson:",inline"`
	MaxCount     int `bson:"maxCount" json:"maxCount"`
}

func NewLengthFilter

func NewLengthFilter() LengthFilter

type LinkFilter

type LinkFilter struct {
	FilterCommon `bson:",inline"`
	Whitelist    []string `bson:"whitelist" json:"whitelist"`
}

func NewLinkFilter

func NewLinkFilter() LinkFilter

type Purge

type Purge struct {
	dataful.BaseModel `bson:",inline"`
	Channel           primitive.ObjectID `bson:"channel" json:"channel"`

	Enabled        bool                 `bson:"enabled" json:"enabled"`
	MaxRole        embeddables.UserRole `bson:"maxRole" json:"maxRole"`
	Lookback       int                  `bson:"lookback" json:"lookback"`
	Continuous     bool                 `bson:"continuous" json:"continuous"`
	ContinuousTime int                  `bson:"continuousTime" json:"continuousTime"`
}

func NewPurge

func NewPurge(r dataful.Repository) *Purge

type RepetitionFilter

type RepetitionFilter struct {
	FilterCommon   `bson:",inline"`
	MinChars       int `bson:"minChars" json:"minChars"`
	MaxRepetitions int `bson:"maxRepetitions" json:"maxRepetitions"`
	MinUnique      int `bson:"minUnique" json:"minUnique"`
}

func NewRepetitionFilter

func NewRepetitionFilter() RepetitionFilter

type Session

type Session struct {
	SessionId       string             `json:"sessionId"`
	User            primitive.ObjectID `json:"user"`
	SelectedChannel primitive.ObjectID `json:"channel"`
	// contains filtered or unexported fields
}

func NewSession

func NewSession(c dataful.Cache) *Session

func (*Session) GenerateSessionId

func (s *Session) GenerateSessionId()

GenerateSessionId generates a new session uid

func (*Session) GetSession

func (s *Session) GetSession(ctx context.Context) error

GetSession gets the session from db

func (*Session) SetSession

func (s *Session) SetSession(ctx context.Context, expiry time.Duration) error

SetSession adds session to db

type SoloSpamFilter

type SoloSpamFilter struct {
	FilterCommon `bson:",inline"`
	MinChars     int     `bson:"minChars" json:"minChars"`
	Similarity   float64 `bson:"similarity" json:"similarity"`
	MaxCount     int     `bson:"maxCount" json:"maxCount"`
	Lookback     int     `bson:"lookback" json:"lookback"`
}

func NewSoloSpamFilter

func NewSoloSpamFilter() SoloSpamFilter

type SymbolsFilter

type SymbolsFilter struct {
	FilterCommon  `bson:",inline"`
	MinChars      int     `bson:"minChars" json:"minChars"`
	MaxCount      int     `bson:"maxCount" json:"maxCount"`
	MaxPercentage float64 `bson:"maxPercentage" json:"maxPercentage"`
}

func NewSymbolsFilter

func NewSymbolsFilter() SymbolsFilter

type User

type User struct {
	dataful.BaseModel `bson:",inline"`

	UserID          string             `bson:"userId" json:"userId"`
	Login           string             `bson:"login" json:"login"`
	DisplayName     string             `bson:"displayName" json:"displayName"`
	AccessToken     string             `bson:"accessToken" json:"-"`
	RefreshToken    string             `bson:"refreshToken" json:"-"`
	Type            string             `bson:"type" json:"type"`
	BroadcasterType string             `bson:"broadcasterType" json:"broadcasterType"`
	Description     string             `bson:"description" json:"description"`
	ProfileImageURL string             `bson:"profileImageURL" json:"profileImageURL"`
	OfflineImageURL string             `bson:"offlineImageURL" json:"offlineImageURL"`
	ViewCount       int                `bson:"viewCount" json:"viewCount"`
	Suspended       bool               `bson:"suspended" json:"suspended"`
	Admin           bool               `bson:"admin" json:"admin"`
	Channel         primitive.ObjectID `bson:"channel" json:"channel"`
}

func NewUser

func NewUser(r dataful.Repository) *User

func (*User) Create

func (u *User) Create(ctx context.Context) error

func (*User) LoadByUserId

func (u *User) LoadByUserId(ctx context.Context, userId string) error

func (*User) LoadBylId

func (u *User) LoadBylId(ctx context.Context, id primitive.ObjectID) error

func (*User) Update

func (u *User) Update(ctx context.Context) error

type ZalgoFilter

type ZalgoFilter struct {
	FilterCommon  `bson:",inline"`
	MinChars      int     `bson:"minChars" json:"minChars"`
	MaxCount      int     `bson:"maxCount" json:"maxCount"`
	MaxPercentage float64 `bson:"maxPercentage" json:"maxPercentage"`
}

func NewZalgoFilter

func NewZalgoFilter() ZalgoFilter

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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