Documentation ¶
Overview ¶
Package gosdbot acts as an extension of the discord api by implementing some helper methods and additional functions potentially useful for a go discord bot.
Index ¶
- Constants
- func Check(err error)
- func CheckWebHooks(session *discordgo.Session, message *discordgo.MessageCreate, target string) bool
- func Cleanup(session *discordgo.Session, message *discordgo.MessageCreate, ...)
- func CleverResponse(session *discordgo.Session, message *discordgo.MessageCreate, ...)
- func Compliment(session *discordgo.Session, message *discordgo.MessageCreate, ...)
- func Delete(session *discordgo.Session, message *discordgo.MessageCreate, ...)
- func DiceRoller(session *discordgo.Session, message *discordgo.MessageCreate, ...)
- func GetEmoji(session *discordgo.Session, msg *discordgo.MessageCreate, name string) *discordgo.Emoji
- func GetGuild(session *discordgo.Session, msg *discordgo.MessageCreate) *discordgo.Guild
- func GetJSON(url string, target interface{}) error
- func GetRoles(session *discordgo.Session, msg *discordgo.MessageCreate) []string
- func GetServer(session *discordgo.Session, msg *discordgo.MessageCreate) string
- func In(s string, list []string) bool
- func NotJustTheMen(session *discordgo.Session, message *discordgo.MessageCreate, ...)
- func RunIt(chance int) bool
- type AutoResponse
- type Config
- func (c *Config) Botstatus(session *discordgo.Session, message *discordgo.MessageCreate, ...)
- func (c *Config) LeaveServer(session *discordgo.Session, message *discordgo.MessageCreate, ...)
- func (c *Config) Mute(session *discordgo.Session, message *discordgo.MessageCreate, ...)
- func (c *Config) Mutestatus(session *discordgo.Session, message *discordgo.MessageCreate, ...)
- func (c *Config) Unmute(session *discordgo.Session, message *discordgo.MessageCreate, ...)
- type ConfigJSON
- type Embed
- func (e *Embed) AddField(name, value string) *Embed
- func (e *Embed) InlineAllFields() *Embed
- func (e *Embed) SetAuthor(args ...string) *Embed
- func (e *Embed) SetColor(clr int) *Embed
- func (e *Embed) SetDescription(description string) *Embed
- func (e *Embed) SetFooter(args ...string) *Embed
- func (e *Embed) SetImage(args ...string) *Embed
- func (e *Embed) SetThumbnail(args ...string) *Embed
- func (e *Embed) SetTitle(name string) *Embed
- func (e *Embed) SetURL(URL string) *Embed
- func (e *Embed) Truncate() *Embed
- func (e *Embed) TruncateDescription() *Embed
- func (e *Embed) TruncateFields() *Embed
- func (e *Embed) TruncateFooter() *Embed
- func (e *Embed) TruncateTitle() *Embed
- type EmbedResponse
- type ReactionResponse
- type TextResponse
Constants ¶
const ( Textresponse = 0 Embedresponse = 1 Reactionresponse = 2 )
help improve readability of the 'general' response checker method.
const ( EmbedLimitTitle = 256 EmbedLimitDescription = 2048 EmbedLimitFieldValue = 1024 EmbedLimitFieldName = 256 EmbedLimitField = 25 EmbedLimit = 4000 )
Constants for message embed character limits
Variables ¶
This section is empty.
Functions ¶
func CheckWebHooks ¶
func CheckWebHooks(session *discordgo.Session, message *discordgo.MessageCreate, target string) bool
CheckWebHooks parses through a list of webhooks given the channel to see if the target is present
func Cleanup ¶
func Cleanup(session *discordgo.Session, message *discordgo.MessageCreate, responded chan bool)
Cleanup removes messages from bots within a range. defaults to 100 messages back to clean
func CleverResponse ¶
func CleverResponse(session *discordgo.Session, message *discordgo.MessageCreate, responded chan bool, clvrbot *cleverbot.Session)
CleverResponse parses requests from channels tagged with the cleverbot webhook and mentioning this bot, and then asks them to cleverbot.
func Compliment ¶
func Compliment(session *discordgo.Session, message *discordgo.MessageCreate, responded chan bool)
Compliment pulls a 'compliment' from a json list found online from emergencycompliment.com and displays it
func Delete ¶
func Delete(session *discordgo.Session, message *discordgo.MessageCreate, responded chan bool)
Delete a number of messages. same basically as cleanup
func DiceRoller ¶
func DiceRoller(session *discordgo.Session, message *discordgo.MessageCreate, responded chan bool)
DiceRoller rolls a variable number and type of dice. same format of parameters as other responders.
func GetEmoji ¶
func GetEmoji(session *discordgo.Session, msg *discordgo.MessageCreate, name string) *discordgo.Emoji
GetEmoji retrieves server emoji by name if it exists.
func GetRoles ¶
func GetRoles(session *discordgo.Session, msg *discordgo.MessageCreate) []string
GetRoles retrieves the roles of a user based on the message the sent+the current session
func GetServer ¶
func GetServer(session *discordgo.Session, msg *discordgo.MessageCreate) string
GetServer retrieve the guild/server by name from the current message and session
func NotJustTheMen ¶
func NotJustTheMen(session *discordgo.Session, message *discordgo.MessageCreate, responded chan bool)
NotJustTheMen is a prequel meme
Types ¶
type AutoResponse ¶
type AutoResponse struct { Trigger string //regex needed to invoke the response as a string Regex *regexp.Regexp //the regex compiled. handled by NewAutoResponse Responses []*TextResponse //list of textresposne objects possible to reply with Embeds []*EmbedResponse //list of embeds possible to reply with Reactions []*ReactionResponse //list of reactions possible to reply with Mentions []string //list of mentions. currently only works with self-mentions Cleanup bool //whether the bot should delete the message that invoked the responses UserSpecific []string //list of users the autoresponse should run for ServerSpecific []string //list of servers the autoresponse can run on }
AutoResponse stores all elements needed for an Autoresponse
func NewAutoResponse ¶
func NewAutoResponse(Trigger string, Responses []*TextResponse, Embeds []*EmbedResponse, Reactions []*ReactionResponse, Mentions []string, Cleanup bool, UserSpecific []string, ServerSpecific []string) *AutoResponse
NewAutoResponse build an AutoResponse object, takes arguments for everything and then creates a compiled regex from the Trigger
func ReadFromJSON ¶
func ReadFromJSON() []*AutoResponse
ReadFromJSON builds a list of autoresponses based on a json file
func (*AutoResponse) CheckResponses ¶
func (a *AutoResponse) CheckResponses(session *discordgo.Session, message *discordgo.MessageCreate, checkType int, responded chan bool)
CheckResponses acts as a generic checker and applier of responses possible from the autoresponse it is called upon. takes: pointer to the current session pointer to the message created by messagecreate event an integer telling the check whether it's checking through text responses, embedded resposnes, or (emoji) reaction responses (0, 1, 2 respectively) a bool channel to note when a goroutine has made an answer.
type Config ¶
type Config struct { Ars []*AutoResponse MutedServers []string Token string Status string OwnerID string CleverUser string CleverID string }
Config is a wrapper for the autoresposnses and mutedServers objects needed by the bot
func ConfigFromJSON ¶
func ConfigFromJSON() *Config
ConfigFromJSON builds a list of autoresponses based on a json file
func NewConfigByToken ¶
NewConfigByToken is a server cstor
func (*Config) Botstatus ¶
func (c *Config) Botstatus(session *discordgo.Session, message *discordgo.MessageCreate, responded chan bool)
Botstatus updates the bot's "playing" status notifier
func (*Config) LeaveServer ¶
func (c *Config) LeaveServer(session *discordgo.Session, message *discordgo.MessageCreate, responded chan bool)
LeaveServer removes the bot from the guildID given to it if the user making the request is an admin
func (*Config) Mute ¶
func (c *Config) Mute(session *discordgo.Session, message *discordgo.MessageCreate, responded chan bool)
Mute adds current sever to the muted list, which allows only mute commands to be received or sent.
func (*Config) Mutestatus ¶
func (c *Config) Mutestatus(session *discordgo.Session, message *discordgo.MessageCreate, responded chan bool)
Mutestatus as it says, returns the current message channel's server mute state
type ConfigJSON ¶
type ConfigJSON struct { Token string Status string OwnerID string CleverUser string CleverID string }
ConfigJSON is a JSON serializeable struct to use to set Config via json parsing
type Embed ¶
type Embed struct {
*discordgo.MessageEmbed
}
Embed ...
func (*Embed) InlineAllFields ¶
InlineAllFields sets all fields in the embed to be inline
func (*Embed) SetDescription ¶
SetDescription [desc]
func (*Embed) TruncateDescription ¶
TruncateDescription ...
func (*Embed) TruncateFields ¶
TruncateFields truncates fields that are too long
type EmbedResponse ¶
EmbedResponse ...
func NewEmbedResponse ¶
func NewEmbedResponse(setChance int, setURL string) *EmbedResponse
NewEmbedResponse cstor
type ReactionResponse ¶
ReactionResponse stores the chance a text response will be made and the text itself
func NewReactionResponse ¶
func NewReactionResponse(setChance int, setText []string) *ReactionResponse
NewReactionResponse ...
type TextResponse ¶
TextResponse stores the chance a text response will be made and the text itself
func NewTextResponse ¶
func NewTextResponse(setChance int, setText string) *TextResponse
NewTextResponse ...