handlers

package
v0.0.0-...-a75bd19 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2021 License: MIT Imports: 24 Imported by: 0

Documentation

Overview

Package handlers contains concrete implementations of the Command interface

Index

Constants

View Source
const (
	// HelpAlias is the default alias for help command
	HelpAlias = "hg"
)

Variables

View Source
var (
	ErrNoInput        = errors.New("No Course code entered")
	ErrInvalidFormat  = errors.New("Invalid Course Code Format")
	ErrNotFound       = errors.New("Course Not Found")
	ErrScrapingFailed = errors.New("Web scraping failed, please contact an Exec")
)
View Source
var (
	ErrLoggingOn  = errors.New("logging is already on")
	ErrLoggingOff = errors.New("logging is already off")
)
View Source
var (
	// ErrQuoteIndex means quote index is not valid
	ErrQuoteIndex = errors.New("index not valid")
	// ErrQuoteEmpty means quote list is not there
	ErrQuoteEmpty = errors.New("quote list not initialised")
	// ErrQuoteNone means user entered no quote
	ErrQuoteNone = errors.New("no quote entered, please enter a quote")
	// ErrQueryNone means user entered no quote
	ErrQueryNone = errors.New("no search terms entered")
)
View Source
var (
	// ErrPlatTooLong means the user tried to create a platform that was too damn long
	ErrPlatTooLong = errors.New("your platform is too long, keep it under " + strconv.Itoa(platLimit) + " characters")
	// ErrTagTooLong means the user tried to create a tag that was too damn long
	ErrTagTooLong = errors.New("your tag is too long, keep it under " + strconv.Itoa(tagLimit) + " characters")
	// ErrNoTags means there is no tag list
	ErrNoTags = errors.New("no tags found in database, add a tag to start it")
	// ErrNoUserTags means there are no tags for the queried user
	ErrNoUserTags = errors.New("no tags found for that user")
	// ErrNoPlatform means the user queried a platform that doesn't exist
	ErrNoPlatform = errors.New("no platform of that name")
	// ErrNoUser means the user queried a platform they did not have a tag on
	ErrNoUser = errors.New("you don't have a tag on this platform")
	// ErrUserNotFound means the user queried a username that doesn't exist on the server
	ErrUserNotFound = errors.New("user not found")
	// ErrAddSpam means the user tried to add while a new platform was being waited on
	ErrAddSpam = errors.New("please do not try add anything while I'm waiting")
	// ErrCleanSpam means the user tried to clean while a clean is in progress
	ErrCleanSpam = errors.New("already cleaning, please be patient")
)
View Source
var (
	ErrEmojiNotInit = errors.New("emoji counter not initialised")
)
View Source
var (
	// ErrdecimalSpiralRange means user gave invalid input outside of range
	ErrdecimalSpiralRange = errors.New("size is not an odd integer between " + strconv.Itoa(lowerLimit) + " and " + strconv.Itoa(upperLimit))
)

Functions

func InitDaemons

func InitDaemons(ses *discordgo.Session) (Close func())

InitDaemons inits all daemons, returns a function to close all channels when done

func InitLogs

func InitLogs(ses *discordgo.Session)

InitLogs inits all logging commands. Needs to be maually updated when adding new loggers

func InitPaginated

func InitPaginated(ses *discordgo.Session, msg *discordgo.Message, title string, lines []string, lineLimit int) (unregister func(), needUnregister bool)

InitPaginated inits a reaction handler for a message to allow pagination

func RouterRoute

func RouterRoute(argv []string) (commands.Command, int)

RouterRoute is a wrapper around the handler package's internal router's Route method

func RouterToSlice

func RouterToSlice() []commands.Command

RouterToSlice is a wrapper around the blah blah blah's ToSlice method

func RouterToStringSlice

func RouterToStringSlice() []string

RouterToStringSlice is a wrapper around the blah blah blah's ToStringSlice method

Types

type Birthday

type Birthday struct {
	Birthday string `arg:"birthday"`
	// contains filtered or unexported fields
}

func (*Birthday) Aliases

func (b *Birthday) Aliases() []string

func (*Birthday) Chans

func (n *Birthday) Chans() []string

func (*Birthday) Desc

func (b *Birthday) Desc() string

func (*Birthday) MsgHandle

func (b *Birthday) MsgHandle(ses *discordgo.Session, msg *discordgo.Message) (*commands.CommandSend, error)

func (*Birthday) Roles

func (n *Birthday) Roles() []string

func (*Birthday) Subcommands

func (b *Birthday) Subcommands() []commands.Command

type BirthdayModCheck

type BirthdayModCheck struct {
	// contains filtered or unexported fields
}

func (*BirthdayModCheck) Aliases

func (b *BirthdayModCheck) Aliases() []string

func (*BirthdayModCheck) Chans

func (n *BirthdayModCheck) Chans() []string

func (*BirthdayModCheck) Desc

func (b *BirthdayModCheck) Desc() string

func (*BirthdayModCheck) MsgHandle

func (*BirthdayModCheck) Roles

func (b *BirthdayModCheck) Roles() []string

func (*BirthdayModCheck) Subcommands

func (n *BirthdayModCheck) Subcommands() []commands.Command

type BirthdayRemove

type BirthdayRemove struct {
	// contains filtered or unexported fields
}

func (*BirthdayRemove) Aliases

func (b *BirthdayRemove) Aliases() []string

func (*BirthdayRemove) Chans

func (n *BirthdayRemove) Chans() []string

func (*BirthdayRemove) Desc

func (b *BirthdayRemove) Desc() string

func (*BirthdayRemove) MsgHandle

func (*BirthdayRemove) Roles

func (n *BirthdayRemove) Roles() []string

func (*BirthdayRemove) Subcommands

func (n *BirthdayRemove) Subcommands() []commands.Command

type Body

type Body struct {
	Contentlets []Contentlets
}

type Contentlets

type Contentlets struct {
	Data   string
	Urlmap string
}

type Data

type Data struct {
	Title           string
	Description     string
	Enrolment_Rules []Enrolment_Rules
	Offering_Detail Offering_Detail
}

type Enrolment_Rules

type Enrolment_Rules struct {
	Description string
}

type MapCache

type MapCache struct {
	// contains filtered or unexported fields
}

MapCache is a data structure that performs FIFOs insertions to stay under the limit, with indexing support

This implementation uses discordgo messages but can be made generic with interface{}. I just picked a concrete type to avoid typing out a lot of type assertions.

Also need to cache images as well since deleted messages remove all attachments

func NewMapCache

func NewMapCache(lim int) *MapCache

NewMapCache returns a new map cache

func (*MapCache) Insert

func (m *MapCache) Insert(ky string, vl *discordgo.Message)

Insert puts a key-value pair

func (*MapCache) Pop

func (m *MapCache) Pop(ky string) (*discordgo.Message, *discordgo.File, bool)

Pop gets a value given a key and removes it from the map

type Offering_Detail

type Offering_Detail struct {
	Offering_Terms string
}

Jump to

Keyboard shortcuts

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