plugins

package module
v0.0.0-...-710481b Latest Latest
Warning

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

Go to latest
Published: May 14, 2020 License: BSD-3-Clause Imports: 15 Imported by: 3

README

Akordo Plugins

Plugins for use with the general purpose bot known as Akordo. (Akordo can be found at gitlab.com/technonauts/akordo)

Documentation

Index

Constants

View Source
const AuthClearPath string = "data/authorizedToClear.json"

AuthClearPath is the path to the json that stores the authorized roles that can run `clear <username>`

View Source
const BannedWordsPath string = "data/bannedWords.json"

BannedWordsPath is the path to the banned words json file

View Source
const ChatPermissionRole string = "data/ruleRole.json"

ChatPermissionRole is the path to the banned words json file

View Source
const CommandDelay = 90

CommandDelay is the time (in seconds) to restrict command spam. Exported for unit tests.

Variables

This section is empty.

Functions

This section is empty.

Types

type Agreement

type Agreement struct {
	BaseRole string `json:"baseRole"` // ID of the role to give
	// contains filtered or unexported fields
}

Agreement contains the data needed to save and execute the base role

func NewAgreement

func NewAgreement(s *dg.Session) *Agreement

NewAgreement creates the struct to use the methods in rules.go

func (*Agreement) Handler

func (a *Agreement) Handler(req []string, msg *dg.MessageCreate) (string, error)

Handler triggers the correct method based off the user input.

func (*Agreement) LoadAgreementRole

func (a *Agreement) LoadAgreementRole(filePath string) error

LoadAgreementRole loads the saved json into the struct of banned words

type AkSession

type AkSession interface {
	Channel(channelID string) (st *dg.Channel, err error)
	GuildMemberRoleAdd(guildID, userID, roleID string) (err error)
	ChannelMessages(channelID string, limit int, beforeID, afterID, aroundID string) (st []*dg.Message, err error)
	ChannelMessagesBulkDelete(channelID string, messages []string) (err error)
	GuildMembers(guildID string, after string, limit int) (st []*dg.Member, err error)
}

AkSession allows for tests to mock the discordgo session.Channel() method call

type Blacklist

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

Blacklist contains the data needed to execute the method functionality

func NewBlacklist

func NewBlacklist(s AkSession) *Blacklist

NewBlacklist creates the needed structs for running the ban methods

func (*Blacklist) CheckBannedWords

func (b *Blacklist) CheckBannedWords(msg *dg.MessageCreate) (bool, error)

CheckBannedWords checks a message for banned words if the channel is not marked NSFW

func (*Blacklist) Handler

func (b *Blacklist) Handler(req []string, msg *dg.MessageCreate) (string, error)

Handler executes the correct method based off the users message

func (*Blacklist) LoadBannedWordList

func (b *Blacklist) LoadBannedWordList(filePath string) error

LoadBannedWordList loads the saved json into the struct of banned words

type Crypto

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

Crypto holds data that is needed to pass around the crypto game functions.

func NewCrypto

func NewCrypto() *Crypto

NewCrypto returns a new struct of type crypto

func (*Crypto) Game

func (c *Crypto) Game(req []string, msg *dg.MessageCreate) (string, error)

Game launches a new crypto game or executes the check function.

type Eraser

type Eraser interface {
	ClearHandler(request []string, msg *dg.MessageCreate) error
	LoadAuthList(file string) error
}

Eraser is the interface for interacting with the clear package.

func NewEraser

func NewEraser(s AkSession) Eraser

NewEraser creates a new clear struct for using the clear methods

type GifRequest

type GifRequest struct {
	Record  *Record
	BaseURL string
}

GifRequest contains the data to be passed when executing the Gif() method.

func NewGifRequest

func NewGifRequest(url ...string) *GifRequest

NewGifRequest creates GifRequest struct for calling the Gif method URL is optional to pass in the case the bot maintainer wants to use a different gif websites. If more than one URL is passed in the only first will be used.

func (*GifRequest) Gif

func (g *GifRequest) Gif(req []string, s *dg.Session, msg *dg.MessageCreate) (string, error)

Gif makes sure the length of the slice is greater that 1 (ie; a tag has been passed with the request) and then return a random gif from Giphy.

type MemeRequest

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

MemeRequest contains the data to be passed when executing the Gif() method.

func NewMemeRequest

func NewMemeRequest(url ...string) *MemeRequest

NewMemeRequest creates GifRequest struct for calling the Gif method URL is optional to pass in the case the bot maintainer wants to use a different gif websites. If more than one URL is passed in the only first will be used.

func (*MemeRequest) RequestMeme

func (m *MemeRequest) RequestMeme(req []string, s *dg.Session, msg *dg.MessageCreate) (string, error)

RequestMeme receives the users request for a meme with the given parameters. If the resquest is malformed (ie, only one word after --meme) the function terminates and returns a message to the sure on how to use the meme generator.

type Record

type Record struct {
	MinWaitTime time.Duration
	LastReq     map[string]time.Time
}

Record holds the users last gif request to avoid spamming.

func NewRecorder

func NewRecorder() *Record

NewRecorder creates a Recordger with a defined map

func (*Record) CheckLastAsk

func (r *Record) CheckLastAsk(msg *dg.MessageCreate) (string, bool)

CheckLastAsk checks the last time the user executed the specific command

func (*Record) Pong

func (r *Record) Pong(msg *dg.MessageCreate) string

Pong returns the string "Pong" when a user types "--Ping"

type Rule34Request

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

Rule34Request contains the data to be passed when executing the Rule34() method.

func NewRule34Request

func NewRule34Request(url ...string) *Rule34Request

NewRule34Request creates Rule34Request struct for calling the Rule34 method URL is optional to pass in the case the bot maintainer wants to use a different gif websites. If more than one URL is passed in the only first will be used.

func (*Rule34Request) Rule34

func (rr *Rule34Request) Rule34(req []string, s AkSession, msg *dg.MessageCreate) (string, error)

Rule34 checks that the channel ID is marked as NSFW, makes sure the length of the slice is greater that 1 (ie; a tag has been passed with the request) and then retrieves the data.

Directories

Path Synopsis
xp

Jump to

Keyboard shortcuts

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