goshleep

package
v0.0.0-...-2d4b08d Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2023 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	AllCommands []Command = []Command{

		{
			Name:        "Verb",
			Description: "Posts a GIF based on the arguments the user gives",
			Template:    "+<verbname> @<user> [-t <tags>]",
			HotStrings:  []string{""},
			Function:    VerbCommand,
			Admin:       false,
			Priority:    0,
		},
		{
			Name:        "List Verbs",
			Description: "Lists all verbs",
			Template:    "+verbs",
			HotStrings:  []string{"verbs"},
			Function:    ListVerbs,
			Admin:       false,
			Priority:    0,
		},
		{
			Name:        "Eightball",
			Description: "Ask Shleepbot your most pressing questions...",
			Template:    "+eightball Should I eat some ice cream?",
			HotStrings:  []string{"eightball"},
			Function:    Eightball,
			Admin:       false,
			Priority:    0,
		},
		{
			Name:        "F",
			Description: "Pay your respects for something/someone",
			Template:    "+f Josh",
			HotStrings:  []string{"f"},
			Function:    FCommand,
			Admin:       false,
			Priority:    0,
		},
		{
			Name:        "Choose",
			Description: "Choose between a number of options!",
			Template:    "+choose <option 1> | <option 2> | <option 3>",
			HotStrings:  []string{"choose"},
			Function:    ChooseCommand,
			Admin:       false,
			Priority:    0,
		},
		{
			Name:        "Add Gif",
			Description: "Adds a gif, and creates a verb if needed.",
			Template:    "+add <verb> <url> [-t <tags>]",
			HotStrings:  []string{"add"},
			Function:    AddGifCommand,
			Admin:       true,
			Priority:    0,
		},
		{
			Name:        "Remove Gif",
			Description: "Removes a gif from a given verb.",
			Template:    "+remove <verb> <url>",
			HotStrings:  []string{"remove"},
			Function:    RemoveGifCommand,
			Admin:       true,
			Priority:    0,
		},
		{
			Name:        "AddAdmin",
			Description: "Adds a given discord ID or mention as an admin",
			Template:    "+addAdmin @<user>",
			HotStrings:  []string{"addAdmin", "aadd", "adminAdd"},
			Function:    AddAdminCommand,
			Admin:       true,
			Priority:    0,
		},
		{
			Name:        "Add Synonym",
			Description: "Adds a verb as a synonym for another",
			Template:    "+synonym <new verb> <base verb>",
			HotStrings:  []string{"synonym", "sadd", "synonymadd"},
			Function:    AddSynonymCommand,
			Admin:       true,
			Priority:    0,
		},
	}
)

Functions

func AddAdminCommand

func AddAdminCommand(details *Request, s *discordgo.Session, allVerbs *[]Verb) discordgo.MessageSend

func AddGif

func AddGif(verbName string, tags []string, g Gif, allVerbs *[]Verb) bool

AddGif will add a given gif to goshleep's database. If the verb isn't found, creates a new one.

func AddGifCommand

func AddGifCommand(details *Request, s *discordgo.Session, allVerbs *[]Verb) discordgo.MessageSend

AddGifCommand is an admin command that allows admins to add a gif, and creates a verb if it does not exist.

func AddSynonym

func AddSynonym(verbName string, baseName string, allVerbs *[]Verb) bool

func AddSynonymCommand

func AddSynonymCommand(details *Request, s *discordgo.Session, allVerbs *[]Verb) discordgo.MessageSend

func AutoConfig

func AutoConfig()

AutoConfig automatically builds the configuration file.

func ChooseCommand

func ChooseCommand(details *Request, s *discordgo.Session, _ *[]Verb) discordgo.MessageSend

Chooses between a number of options

func Contains

func Contains(slice []string, s string) bool

func DefaultKillFunction

func DefaultKillFunction(r Response)

DefaultKillFunction is a minimalist kill function that simply flips alive to off.

func Eightball

func Eightball(details *Request, s *discordgo.Session, _ *[]Verb) discordgo.MessageSend

Randomly gives an answer to some question, like an eightball

func FCommand

func FCommand(details *Request, s *discordgo.Session, _ *[]Verb) discordgo.MessageSend

Press F to pay respects

func GetMentionNames

func GetMentionNames(m *discordgo.Message, s *discordgo.Session) string

GetMentionNames takes a message and a session, and returns a list of user nicks mentioned within.

func GetName

func GetName(u *discordgo.User, guildID string, s *discordgo.Session) string

GetName takes a user and guildID and returns their name

func HelpCommand

func HelpCommand(details *Request, s *discordgo.Session, _ *[]Verb) discordgo.MessageSend

func IfMatchHotStrings

func IfMatchHotStrings(arr []string, check string) bool

Checks

func ListVerbs

func ListVerbs(_ *Request, _ *discordgo.Session, allVerbs *[]Verb) discordgo.MessageSend

ListVerbs lists all verbs in allVerbs

func Load

func Load(out *[]Verb)

Load a collection of verbs

func ParseRequest

func ParseRequest(r *Request, s *discordgo.Session, allVerbs *[]Verb) discordgo.MessageSend

This is the function that actually runs a request, or command.

func ReadViper

func ReadViper()

func RemoveGif

func RemoveGif(verbName string, url string, allVerbs *[]Verb) bool

AddGif will add a given gif to goshleep's database. If the verb isn't found, creates a new one.

func RemoveGifCommand

func RemoveGifCommand(details *Request, s *discordgo.Session, allVerbs *[]Verb) discordgo.MessageSend

RemoveGifCommand is an admin command that allows admins to remove a gif.

func Store

func Store(toStore []Verb) string

Store a collection of verbs

func VerbCommand

func VerbCommand(myRequest *Request, s *discordgo.Session, allVerbs *[]Verb) discordgo.MessageSend

VerbCommand takes in the follow expected string template: +<verb> [recipient] [-t tags] and returns a discord message, including a gif reaction of the inputted verb, assuming one exists.

Types

type CheckFunction

type CheckFunction func(content string) bool

type Command

type Command struct {
	Name        string
	Description string
	Template    string
	HotStrings  []string
	Function    CommandFunction
	Admin       bool
	Priority    int // 0 = lowest
}

type CommandFunction

type CommandFunction func(details *Request, s *discordgo.Session, allVerbs *[]Verb) discordgo.MessageSend

type Gif

type Gif struct {
	URL  string
	Tags []string
}

Gif is a struct containing a url and tags

type KillFunction

type KillFunction func(r Response)

KillFunction is a function type used to kill Responses

type Request

type Request struct {
	Content      string
	SplitContent []string
	Type         Command
	Resp         *Response
	// contains filtered or unexported fields
}

func ConstructRequest

func ConstructRequest(m discordgo.Message) Request

type Response

type Response struct {
	// Users IDS that can respond
	UserList []string
	// Function to run the response through
	Run ResponseFunction
	// Is this response still alive?
	Alive bool
	// Verify if the given message satisfies requirements
	Check CheckFunction

	// When was this response created?
	Created time.Time
	Kill    KillFunction
	// contains filtered or unexported fields
}

Response is a struct that lets goshleep ask a user questions and get respsonses.

type ResponseFunction

type ResponseFunction func(content string, s *discordgo.Session, allVerbs *[]Verb) discordgo.MessageSend

type Verb

type Verb struct {
	Images []Gif
	Names  []string
}

Verb is a collection of gifs

Jump to

Keyboard shortcuts

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