data

package
v0.0.14 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2020 License: GPL-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const UTCFormat = "Jan 2 15:04:05 UTC"

Variables

This section is empty.

Functions

func TimeStamp

func TimeStamp() string

func TimeStampFmt

func TimeStampFmt(format string) string

Types

type ChannelData

type ChannelData struct {
	ControlChannel    bool
	Name              string             `json:"name"`
	AdminKey          string             `json:"value,omitempty"`
	Commands          []CommandStruct    `json:"commands,omitempty"`
	ExtraStrings      string             `json:"extrastrings,omitempty"`
	JoinTime          time.Time          `json:"jointime"`
	HasLeft           bool               `json:"hasleft"`
	VideoCache        []SingsVideoStruct `json:"videoCache"`
	VideoCacheUpdated time.Time          `json:"videoCacheUpdated"`
	Bearer            string             `json:"bearer"`
	TwitchUserID      string             `json:"twitchUserID"`
}

ChannelData is what we store in the BitRaft (Redis) database

type CommandStruct

type CommandStruct struct {
	CommandName CommandType `json:"commandName"`
	KeyWord     string      `json:"keyword"`
}

CommandStruct keypair for irc command -> actual thing to do

type CommandType

type CommandType string

CommandType Kinda an enum

const (
	RandomSinger CommandType = "RandomSinger"
	RandomPrompt CommandType = "RandomPrompt"
	RandomSong   CommandType = "RandomSong"
	AgingSinger  CommandType = "AgingSinger"
	AgingSong    CommandType = "AgingSong"
)

CommandType literals

func (CommandType) IsValid

func (ct CommandType) IsValid() error

IsValid Is CommandType a valid enum?

type ConfigStruct

type ConfigStruct struct {
	InitialChannels []string `json:"channels"`
	IrcOAuthPath    string   `json:"ircoauthpath,omitempty"`
	StringPath      string   `json:"authpath,omitempty"`
	DataPath        string   `json:"datapath,omitempty"`
	ExternalURL     string   `json:"externalurl,omitempty"`
	AppOAuthPath    string   `json:"appoauthpath,omitempty"`
	DatabaseSVC     string   `json:"databasesvc,omitempty"`
}

ConfigStruct is the base for the config file

type GlobalData

type GlobalData struct {
	ChannelData    map[string]ChannelData
	Config         ConfigStruct
	Database       redis.Conn
	ControlChannel string
}

GlobalData Some kind of architect would kill me for this

func (*GlobalData) ConnectDatabase

func (gd *GlobalData) ConnectDatabase()

ConnectDatabase Connects to the database set in the config struct

func (*GlobalData) ReadChannelData

func (gd *GlobalData) ReadChannelData() error

func (*GlobalData) ReadOrCreateChannelKey

func (gd *GlobalData) ReadOrCreateChannelKey(channel string) string

func (*GlobalData) UpdateBearerToken

func (gd *GlobalData) UpdateBearerToken(user string, token string)

func (*GlobalData) UpdateChannelKey

func (gd *GlobalData) UpdateChannelKey(user string, channelKey string)

func (*GlobalData) UpdateChannelName

func (gd *GlobalData) UpdateChannelName(user string, newName string)

func (*GlobalData) UpdateJoined

func (gd *GlobalData) UpdateJoined(user string, invert bool)

func (*GlobalData) UpdateTwitchUserID

func (gd *GlobalData) UpdateTwitchUserID(user string, userid string)

func (*GlobalData) UpdateVideoCache

func (gd *GlobalData) UpdateVideoCache(user string, videos []SingsVideoStruct)

UpdateVideoCache Updates the in-memory data and updates redis

type SingsVideoStruct

type SingsVideoStruct struct {
	Date           time.Time `json:"date"`           // Golang date of creation
	FullTitle      string    `json:"fullTitle"`      // Full Title
	Duet           bool      `json:"duet"`           // Is it a duet?
	OtherSinger    string    `json:"otherSinger"`    // Twitch NAME of the other singer, extracted from the title
	SongTitle      string    `json:"songTitle"`      // extracted from title
	LastSungSong   time.Time `json:"LastSungSong"`   // Last time this SONG was sung
	LastSungSinger time.Time `json:"LastSungSinger"` // Last time a duet was sung with this SINGER, regardless of song, only Duets have this date initialised
	VideoURL       string    `json:"VideoURL"`       // RIP Twitch Sings
}

SingsVideoStruct The data we pull from Twitch

Jump to

Keyboard shortcuts

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