model

package
v0.0.0-...-bf34452 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CommandTypeCustom = iota
	CommandTypeFactSphere
	CommandTypeHelp
	CommandTypeKarma
	CommandTypeKarmaList
	CommandTypeLearn
	CommandTypeList
	CommandTypeNone
	CommandTypeRickList
	CommandTypeRickListInfo
	CommandTypeUnlearn
	CommandTypeUnrecognized
	CommandTypeVote
	CommandTypeVoteBallot
	CommandTypeVoteConclude
	CommandTypeVoteStatus

	CommandNameFactSphere     = "?factsphere"
	CommandNameHelp           = "?help"
	CommandNameKarmaIncrement = "?++"
	CommandNameKarmaDecrement = "?--"
	CommandNameKarmaList      = "?karmalist"
	CommandNameLearn          = "?learn"
	CommandNameList           = "?list"
	CommandNameRickListInfo   = "?ricklist"
	CommandNameUnlearn        = "?unlearn"
	CommandNameVote           = "?vote"
	CommandNameVoteAgainstF2  = "?f2"
	CommandNameVoteAgainstNo  = "?no"
	CommandNameVoteInFavorF1  = "?f1"
	CommandNameVoteInFavorYes = "?yes"
	CommandNameVoteStatus     = "?votestatus"
)

Consts use throughout the application

View Source
const (
	// These are serialized and stored, so they cannot change.
	VoteOutcomeNotDone   = 1
	VoteOutcomePassed    = 2
	VoteOutcomeFailed    = 3
	VoteOutcomeNotEnough = 4
)

Vote outcomes used for storage.

Variables

This section is empty.

Functions

This section is empty.

Types

type BallotData

type BallotData struct {
	InFavor bool
}

BallotData represents whether the user is for or against the vote

type Command

type Command struct {
	// Metadata
	Author       *discordgo.User
	ChannelID    Snowflake
	Type         int
	OriginalName string

	// Message data
	Ballot  *BallotData
	Custom  *CustomData
	Help    *HelpData
	Karma   *KarmaData
	Learn   *LearnData
	Unlearn *UnlearnData
	Vote    *VoteData
}

Command is the generic command interface TODO(jake): Make this an interface that has only getType(), cast in features.

type CustomData

type CustomData struct {
	Call string
	Args string
}

CustomData is the custom ?learn-specific data

type HelpData

type HelpData struct {
	Command string
}

HelpData holds data for Help commands.

type KarmaData

type KarmaData struct {
	Increment bool
	Target    string
}

KarmaData holds the target and whether karma is to be incremented or decremented

type LearnData

type LearnData struct {
	CallOpen bool
	Call     string
	Response string
}

LearnData is the learn-specific data

type Snowflake

type Snowflake uint64

Snowflake is a discord data type representing a globally unique ID

func ParseSnowflake

func ParseSnowflake(input string) (Snowflake, error)

ParseSnowflake parses the input snowflake string

func (Snowflake) Format

func (s Snowflake) Format() string

Format stringifies a string.

type SystemUTCClock

type SystemUTCClock struct{}

SystemUTCClock is a UTCClock that returns UTC based on the current system's time.

func NewSystemUTCClock

func NewSystemUTCClock() *SystemUTCClock

NewSystemUTCClock works as advertised.

func (*SystemUTCClock) Now

func (c *SystemUTCClock) Now() time.Time

Now returns the UTC time for the current system.

type SystemUTCTimer

type SystemUTCTimer struct{}

SystemUTCTimer is a real implementation of UTCTimer.

func NewSystemUTCTimer

func NewSystemUTCTimer() *SystemUTCTimer

NewSystemUTCTimer works as advertised.

func (*SystemUTCTimer) ExecuteAfter

func (c *SystemUTCTimer) ExecuteAfter(howLong time.Duration, cb func())

ExecuteAfter executes the given closure after the given duration has elapsed. This is non-blocking.

type UTCClock

type UTCClock interface {
	Now() time.Time
}

UTCClock is an interface that returns a UTC time.

type UTCTimer

type UTCTimer interface {
	ExecuteAfter(time.Duration, func())
}

UTCTimer is an interface that allows a closure to be executed after a certain amount of time. This is non-blocking.

type UnlearnData

type UnlearnData struct {
	CallOpen bool
	Call     string
}

UnlearnData is the unlearn-specific data

type Vote

type Vote struct {
	VoteID         int
	ChannelID      Snowflake
	UserID         Snowflake
	Message        string
	TimestampStart time.Time
	TimestampEnd   time.Time
	VotesFor       []Snowflake
	VotesAgainst   []Snowflake
	VoteOutcome    int
}

Vote is the JSON-serialized and -deserialized implementation of a single vote. TODO(jake): When there is a testrunner with vote-specific functionality, move this back into the vote package

func NewVote

func NewVote(voteID int, channelID, userID Snowflake, message string, timestampStart, timestampEnd time.Time, votesFor, votesAgainst []Snowflake, voteOutcome int) *Vote

NewVote works as advertised.

func (*Vote) CalculateActiveStatus

func (v *Vote) CalculateActiveStatus() int

CalculateActiveStatus compares the vote totals and returns what the outcome would be. This ignores the recorded outcome, and the number of votes.

func (*Vote) HasEnoughVotes

func (v *Vote) HasEnoughVotes() bool

HasEnoughVotes returns whether there are enough votes to claim confidence.

type VoteData

type VoteData struct {
	Message string
}

VoteData contains the information about the proposed vote

Jump to

Keyboard shortcuts

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