scores

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package scores implements a plugin to score things on channels. One can do X++ (or X--) to give (or take) points to X.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(b bot.Bot, scoresfile string)

Register registers the plugin with a bot.

Types

type ScoreEntry

type ScoreEntry struct {
	Name  string
	Value int
}

ScoreEntry represents a single entry of a ScoreList.

func (*ScoreEntry) String

func (e *ScoreEntry) String() string

type ScoreList

type ScoreList []*ScoreEntry

ScoreList is a slice of score entries and implements sort.Interface. Not directly used by the plugin but used to calculate top scores.

func (ScoreList) Len

func (l ScoreList) Len() int

func (ScoreList) Less

func (l ScoreList) Less(i, j int) bool

func (ScoreList) Swap

func (l ScoreList) Swap(i, j int)

type Scores

type Scores struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Scores is the main structure to hold scores in the plugin.

func NewScores

func NewScores() *Scores

NewScores returns a new initialized Scores.

func (*Scores) Add

func (s *Scores) Add(thing string, n int)

Add adds n score points to a given thing.

func (*Scores) List

func (s *Scores) List() *ScoreList

List sorts scores and returns an ordered ScoreList.

func (*Scores) Score

func (s *Scores) Score(thing string) int

Score returns the score of a given thing.

func (*Scores) String

func (s *Scores) String() string

String returns formatted top +/- scores and total.

Jump to

Keyboard shortcuts

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