stats

package
v1.15.1 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2016 License: BSD-1-Clause Imports: 14 Imported by: 0

Documentation

Overview

Package stats retains a listing of user host names, mapped to nicknames they have ever been seen using, along with some other, rudimentary user statistics.

This is intended to make it easier to pick out trolls, trying to present themselves as new users. While this is by no means fool-proof, it keeps the majority out.

Index

Constants

View Source
const (
	// ref: https://godoc.org/time#Time.Format
	TextDateFormat       = "2 January, 2006"
	TextTimeFormat       = "15:04 MST"
	TextNick             = "gebruiker"
	TextUnknownUser      = "%s, %s heb ik niet gezien."
	TextWhoisName        = "wieis"
	TextWhoisDisplay     = "%s, ik ken %s sinds %s als: %s"
	TextWhoisUnknownUser = "%s, ik herken %s niet."
	TextLastOn           = "laston"
	TextLastOnDisplay    = "%s, ik heb %s (%s) het laatst gezien op %s, om %s (± %s geleden)."
	TextFirstOn          = "firston"
	TextFirstOnDisplay   = "%s, ik heb %s (%s) voor het eerst gezien op %s, om %s (± %s geleden)."
)
View Source
const SaveInterval = time.Minute * 10

SaveInterval determines the time interval after which we save stats data to disk.

Variables

This section is empty.

Functions

func FormatDuration

func FormatDuration(d time.Duration) string

FormatDuration returns a custom, string representation of the given duration. It is in the correct language and slightly more readable than Go's default time.Duration.String() output.

Types

type User

type User struct {
	Hostmask  string
	Nicknames []string
	FirstSeen time.Time
	LastSeen  time.Time
}

User defines the hostmask and all known nicknames for a single user. Additionally, it defines some timestamps.

func (*User) AddNickname

func (u *User) AddNickname(v string)

AddNickname adds the given nickname to the user's name list, provided it is not already known.

type UserList

type UserList []*User

UserList defines a set of user descriptors, sortable by hostmask.

func (UserList) Find

func (cl UserList) Find(name string, limit int) []*User

Find finds the user which exactly matches the given hostmask, or all users which have a fuzzy match with the given nickname. It returns at most limit users.

func (*UserList) Get

func (cl *UserList) Get(mask string) *User

Get returns a user entry for the given hostmask. If it doesn't exist yet, a new entry is created and added to the list implicitely.

This implicitely updates the LastSeen timestamp for the user.

func (UserList) Len

func (cl UserList) Len() int

func (UserList) Less

func (cl UserList) Less(i, j int) bool

func (UserList) Swap

func (cl UserList) Swap(i, j int)

Jump to

Keyboard shortcuts

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