miner

package
v0.0.0-...-8e24713 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2025 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Chat

type Chat struct {
	// contains filtered or unexported fields
}

func NewChat

func NewChat(u *User) *Chat

func (*Chat) RevalidateChannelSubscriptions

func (c *Chat) RevalidateChannelSubscriptions()

func (*Chat) RunForever

func (c *Chat) RunForever()

func (*Chat) Stop

func (c *Chat) Stop()

type GraphQL

type GraphQL struct {
	User          *User
	ClientSession string
	ClientVersion string
	DeviceID      string
	Client        *http.Client
}

func NewGraphQL

func NewGraphQL(user *User) *GraphQL

func (*GraphQL) ClaimBonus

func (gql *GraphQL) ClaimBonus(streamer *Streamer, claimID string) error

func (*GraphQL) ClaimMoment

func (gql *GraphQL) ClaimMoment(momentID string) error

func (*GraphQL) GetFollows

func (gql *GraphQL) GetFollows() ([]string, error)

func (*GraphQL) GetSteamerID

func (gql *GraphQL) GetSteamerID(name string) (string, error)

func (*GraphQL) GetStreamBroadcastID

func (gql *GraphQL) GetStreamBroadcastID(streamer *Streamer) error

func (*GraphQL) JoinRaid

func (gql *GraphQL) JoinRaid(raidID string) error

func (*GraphQL) LoadChannelPoints

func (gql *GraphQL) LoadChannelPoints(streamer *Streamer) error

func (*GraphQL) MakePrediction

func (gql *GraphQL) MakePrediction(eventID string, outcomeID string, points int) error

func (*GraphQL) PlaybackAccessToken

func (gql *GraphQL) PlaybackAccessToken(streamer *Streamer) (string, string, error)

func (*GraphQL) SendRequest

func (gql *GraphQL) SendRequest(payload GraphQLRequest, ptr any) error

type GraphQLRequest

type GraphQLRequest struct {
	OperationName string                   `json:"operationName"`
	Variables     map[string]any           `json:"variables"`
	Extensions    GraphQLRequestExtensions `json:"extensions"`
}

type GraphQLRequestExtensions

type GraphQLRequestExtensions struct {
	PersistedQuery GraphQLRequestExtensionsPersistedQuery `json:"persistedQuery"`
}

type GraphQLRequestExtensionsPersistedQuery

type GraphQLRequestExtensionsPersistedQuery struct {
	Version    int    `json:"version"`
	Sha256Hash string `json:"sha256Hash"`
}

type LoginSession

type LoginSession struct {
	// contains filtered or unexported fields
}

func NewLoginSession

func NewLoginSession(clientID ...string) *LoginSession

TV

func (*LoginSession) CheckCode

func (l *LoginSession) CheckCode() (string, error)

func (*LoginSession) GetCode

func (l *LoginSession) GetCode() (string, error)

func (*LoginSession) WaitForToken

func (l *LoginSession) WaitForToken() (string, error)

type Miner

type Miner struct {
	Options       Options
	WebsocketPool *WebsocketPool

	DefaultUser *User
	Users       map[string]*User
	Streamers   map[string]*Streamer
	Predictions map[string]*Prediction
	Persistent  *PersistentState

	SpadeUrl string

	Lock sync.Mutex
}

func NewMiner

func NewMiner(options Options) *Miner

func (*Miner) AddStreamer

func (miner *Miner) AddStreamer(username string, user *User) *Streamer

func (*Miner) AddStreamersFromFollows

func (miner *Miner) AddStreamersFromFollows(user *User) error

func (*Miner) AddUser

func (miner *Miner) AddUser(user *User)

func (*Miner) Alert

func (miner *Miner) Alert(data ...any)

func (*Miner) BulkAddStreamers

func (miner *Miner) BulkAddStreamers(user *User, streamers []string)

func (*Miner) GetStreamerByID

func (miner *Miner) GetStreamerByID(streamerID string) *Streamer

func (*Miner) GetUsersForStreamer

func (miner *Miner) GetUsersForStreamer(id string) []*User

func (*Miner) MinePoints

func (miner *Miner) MinePoints(user *User) error

func (*Miner) OnClaimAvailable

func (miner *Miner) OnClaimAvailable(message WebsocketMessage)

func (*Miner) OnMessage

func (miner *Miner) OnMessage(message WebsocketMessage)

func (*Miner) OnMoment

func (miner *Miner) OnMoment(message WebsocketMessage)

func (*Miner) OnPointsUpdate

func (miner *Miner) OnPointsUpdate(message WebsocketMessage)

func (*Miner) OnPredictionUpdate

func (miner *Miner) OnPredictionUpdate(message WebsocketMessage)

func (*Miner) OnRaidUpdate

func (miner *Miner) OnRaidUpdate(message WebsocketMessage)

func (*Miner) OnStreamDown

func (miner *Miner) OnStreamDown(message WebsocketMessage)

func (*Miner) OnStreamUp

func (miner *Miner) OnStreamUp(message WebsocketMessage)

func (*Miner) OnViewcount

func (miner *Miner) OnViewcount(message WebsocketMessage)

func (*Miner) Run

func (miner *Miner) Run() error

func (*Miner) SubscribeToTopics

func (miner *Miner) SubscribeToTopics()

func (*Miner) UpdateStreamerTopicSubscriptions

func (miner *Miner) UpdateStreamerTopicSubscriptions() error

func (*Miner) UpdateVersions

func (miner *Miner) UpdateVersions() error

type MiningStrategy

type MiningStrategy = string
const (
	MiningStrategyLeastPoints MiningStrategy = "LEAST_POINTS"
	MiningStrategyMostPoints  MiningStrategy = "MOST_POINTS"
	MiningStrategyMostViewers MiningStrategy = "MOST_VIEWERS"
)

type MomentActiveEvent

type MomentActiveEvent struct {
	Data struct {
		MomentID string `json:"moment_id"`
	} `json:"data"`
}

type Options

type Options struct {
	MinePoints           bool
	PrioritizeStreaks    bool
	ConcurrentPointLimit int
	ConcurrentWatchLimit int
	MiningStrategy       MiningStrategy
	StreamerPriority     map[string]int

	MineRaids   bool
	MineMoments bool

	MineWatchtime     bool
	WatchTimeOnlyLive bool
	FollowChatSpam    bool

	MinePredictions       bool
	PredictionsDataPoints int
	PredictionsMinPoints  int
	PredictionsMaxBet     int
	PredictionsMaxRatio   int
	PredictionsStealth    bool
	PredictionsStrategy   PredictionStrategy

	PersistentFile string
	DebugWebhook   string
}

func (Options) RequiresStreamActivity

func (o Options) RequiresStreamActivity() bool

type PersistentState

type PersistentState struct {
	PredictionResults map[string]map[string]int `json:"prediction_results"`
}

func LoadPersistentState

func LoadPersistentState(opt Options) *PersistentState

func (*PersistentState) Save

func (p *PersistentState) Save(opt Options) error

type Prediction

type Prediction struct {
	Event      *predictionModel
	Miner      *Miner
	Bet        bool
	BetPending bool
}

func (*Prediction) DelayedBet

func (p *Prediction) DelayedBet()

func (*Prediction) SmartBet

func (p *Prediction) SmartBet()

type PredictionStatus

type PredictionStatus = string
const (
	PredictionStatusActive         PredictionStatus = "ACTIVE"
	PredictionStatusLocked         PredictionStatus = "LOCKED"
	PredictionStatusResolvePending PredictionStatus = "RESOLVE_PENDING"
	PredictionStatusResolved       PredictionStatus = "RESOLVED"
)

type PredictionStrategy

type PredictionStrategy = string
const (
	PredictionStrategyRandom               PredictionStrategy = "RANDOM"
	PredictionStrategyMostPoints           PredictionStrategy = "MOST_POINTS"
	PredictionStrategyMostIndividuals      PredictionStrategy = "MOST_INDIVIDUALS"
	PredictionStrategyMostIndividualPoints PredictionStrategy = "MOST_INDIVIDUAL_POINTS"
	PredictionStrategyCautious             PredictionStrategy = "CAUTIOUS"
)

type RawWebsocketMessage

type RawWebsocketMessage struct {
	Type  string                   `json:"type"`
	Data  *RawWebsocketMessageData `json:"data"`
	Error *string                  `json:"error"`
}

type RawWebsocketMessageData

type RawWebsocketMessageData struct {
	Topic   string `json:"topic"`
	Message string `json:"message"`
}

type Streamer

type Streamer struct {
	Username string
	ID       string

	Points        map[*User]int
	GotPointsOnce map[*User]bool
	BroadcastID   string

	Viewers      int
	LastLivePing time.Time
	WasLive      bool

	LiveTopics []*WebsocketTopic
}

func (Streamer) ChannelName

func (s Streamer) ChannelName() string

func (*Streamer) IsLive

func (s *Streamer) IsLive() bool

type User

type User struct {
	Username  string
	ID        string
	AuthToken string
	Chat      *Chat
	GraphQL   *GraphQL

	Streamers map[string]*Streamer
	Miner     *Miner
}

func NewUser

func NewUser(username string, authToken string) *User

func (*User) ConnectToChat

func (u *User) ConnectToChat()

type WebsocketConnection

type WebsocketConnection struct {
	ID int
	// contains filtered or unexported fields
}

func NewWebsocketConnection

func NewWebsocketConnection(pool *WebsocketPool) *WebsocketConnection

func (*WebsocketConnection) Connect

func (ws *WebsocketConnection) Connect() error

func (*WebsocketConnection) Disconnect

func (ws *WebsocketConnection) Disconnect()

func (*WebsocketConnection) HandleKeepalive

func (ws *WebsocketConnection) HandleKeepalive()

func (*WebsocketConnection) HandleMessages

func (ws *WebsocketConnection) HandleMessages()

func (*WebsocketConnection) ListenTopics

func (ws *WebsocketConnection) ListenTopics(topics ...*WebsocketTopic) error

type WebsocketMessage

type WebsocketMessage struct {
	Topics []string
	Type   string
	Data   json.RawMessage
}

type WebsocketMessageContent

type WebsocketMessageContent struct {
	Type string `json:"type"`
}

type WebsocketPool

type WebsocketPool struct {
	OnMessage *func(WebsocketMessage)
	// contains filtered or unexported fields
}

func NewWebsocketPool

func NewWebsocketPool() *WebsocketPool

func (*WebsocketPool) ListenTopic

func (pool *WebsocketPool) ListenTopic(topic *WebsocketTopic) error

func (*WebsocketPool) OnDisconnect

func (pool *WebsocketPool) OnDisconnect(conn *WebsocketConnection)

func (*WebsocketPool) RevalidateTopics

func (pool *WebsocketPool) RevalidateTopics() error

func (*WebsocketPool) SubmitTopic

func (pool *WebsocketPool) SubmitTopic(topic *WebsocketTopic) error

func (*WebsocketPool) UnlistenTopic

func (pool *WebsocketPool) UnlistenTopic(topic *WebsocketTopic) error

type WebsocketTopic

type WebsocketTopic struct {
	Topic      string
	User       *User
	Streamer   *Streamer
	AssignedTo *WebsocketConnection
}

func (*WebsocketTopic) GetTopicName

func (topic *WebsocketTopic) GetTopicName() string

Jump to

Keyboard shortcuts

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