Documentation ¶
Index ¶
Constants ¶
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
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 ¶
CustomData is the custom ?learn-specific data
type Snowflake ¶
type Snowflake uint64
Snowflake is a discord data type representing a globally unique ID
func ParseSnowflake ¶
ParseSnowflake parses the input snowflake 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 UTCTimer ¶
UTCTimer is an interface that allows a closure to be executed after a certain amount of time. This is non-blocking.
type UnlearnData ¶
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 ¶
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 ¶
HasEnoughVotes returns whether there are enough votes to claim confidence.