stats

package
v1.19.0 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2026 License: MIT Imports: 10 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddAudioRequest

func AddAudioRequest(userID int64, username string)

func AddDownloadError

func AddDownloadError(userID int64, username string)

func AddUnrecognizedCommand

func AddUnrecognizedCommand(userID int64, username string)

func AddVideoRequest

func AddVideoRequest(userID int64, username string)

func GetAllUserChatIDs added in v1.6.0

func GetAllUserChatIDs() ([]int64, error)

GetAllUserChatIDs returns all user chat IDs from the database

func GetUserCount added in v1.6.0

func GetUserCount() (int, error)

GetUserCount returns the total number of users

func Init

func Init(dir string)

Init opens and migrates the stats database in the given base directory.

func RegisterUser added in v1.6.0

func RegisterUser(chatID, userID int64, username, firstName, lastName string)

RegisterUser updates the sender's profile separately from the broadcast chat. In a group, chatID is the group's ID and userID is the sender's personal ID.

Types

type BroadcastResult added in v1.6.0

type BroadcastResult struct {
	Sent          int
	Failed        int
	BlockedByUser int
	Errors        []string
}

BroadcastResult contains the results of a broadcast operation

func BroadcastMessage added in v1.6.0

func BroadcastMessage(ctx context.Context, message string, sendFunc SendMessageFunc) *BroadcastResult

BroadcastMessage sends a message to all users

type Counts added in v1.19.0

type Counts struct {
	VideoRequests        int `json:"video_requests"`
	AudioRequests        int `json:"audio_requests"`
	DownloadErrors       int `json:"download_errors"`
	UnrecognizedCommands int `json:"unrecognized_commands"`
}

func (Counts) Total added in v1.19.0

func (c Counts) Total() int

type SendMessageFunc added in v1.6.0

type SendMessageFunc func(ctx context.Context, chatID int64, message string) error

SendMessageFunc is a function type for sending messages

type Stats

type Stats struct {
	Users []UserStats `json:"users"`
}

func GetStats

func GetStats(period string) *Stats

func (*Stats) Totals added in v1.19.0

func (s *Stats) Totals() Counts

type UserStats added in v1.19.0

type UserStats struct {
	UserID    int64  `json:"user_id"`
	Username  string `json:"username"`
	FirstName string `json:"first_name"`
	LastName  string `json:"last_name"`
	Legacy    bool   `json:"legacy"`
	Counts
}

func (UserStats) DisplayName added in v1.19.0

func (u UserStats) DisplayName() string

DisplayName is a label only; aggregation always uses UserID for new events.

Jump to

Keyboard shortcuts

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