Documentation ¶
Index ¶
- Constants
- Variables
- func ArrayContains(arr []string, element string) bool
- func CreateFileIfNotExists(path string) error
- func GetUserFromName(s *discordgo.Session, g *discordgo.Guild, t string) *discordgo.User
- func MemberHasPermission(s *discordgo.Session, guildID string, userID string, perm int) bool
- func NewBeluga(cliFlags Flags)
- func OnGuildCreate(s *discordgo.Session, e *discordgo.GuildCreate)
- func OnMessageCreate(s *discordgo.Session, m *discordgo.MessageCreate)
- func OnReady(s *discordgo.Session, e *discordgo.Ready)
- func RemoveFromStringArray(arr []string, item string) []string
- func RemoveMultipleFromArray(arr, toRemove []string) []string
- func SaveConfigToFile(name string, data interface{}) error
- func SetGuildDefaults(guildID string)
- type AdminPlugin
- type Command
- type CommandPlugin
- type CustomCommandsPlugin
- type Flags
- type GuildConfig
- type HunterPlugin
- type PluginManager
- type RootConfig
- type SlapPlugin
- type SlapPluginConfig
- type UserBlacklist
Constants ¶
const ( // PluginsPath is the path where Beluga plugins should // be placed PluginsPath = "/usr/share/beluga/plugins" )
Variables ¶
var ConfigDir string
ConfigDir is the path to all Beluga-related configs
var Help helpPlugin
Help is our help responder
var Log *waterlog.WaterLog
Log is our WaterLog instance
var Session *discordgo.Session
Session is our Discord session
Functions ¶
func ArrayContains ¶
ArrayContains checks if a given element is in a string array
func CreateFileIfNotExists ¶
CreateFileIfNotExists creates a new empty file at the given path it the file does not yet exist
func GetUserFromName ¶
GetUserFromName gets the Discord user from a mention or username. The username can be only a partial username
func MemberHasPermission ¶
MemberHasPermission checks if a member of a guild has the desired permission
func NewBeluga ¶
func NewBeluga(cliFlags Flags)
NewBeluga creates a new Beluga instance, and connects to Discord
func OnGuildCreate ¶
func OnGuildCreate(s *discordgo.Session, e *discordgo.GuildCreate)
OnGuildCreate handles when we join a Discord guild
func OnMessageCreate ¶
func OnMessageCreate(s *discordgo.Session, m *discordgo.MessageCreate)
OnMessageCreate handles when a regular message is sent in a channel that we have access to
func RemoveFromStringArray ¶
RemoveFromStringArray removes a single item from a string array
func RemoveMultipleFromArray ¶
RemoveMultipleFromArray removes anything that's in the second array from the first array
func SaveConfigToFile ¶
SaveConfigToFile saves the given data to the given file name in the local config directory
func SetGuildDefaults ¶
func SetGuildDefaults(guildID string)
SetGuildDefaults creates a new guild configuration with defaults, adds it to the existing configuration, and saves it to the disk
Types ¶
type AdminPlugin ¶
type AdminPlugin struct {
// contains filtered or unexported fields
}
AdminPlugin is our admin plugin struct
var BelugaAdmin AdminPlugin
BelugaAdmin is our admin plugin instance
type Command ¶
type Command struct { ChannelID string Command string GuildID string Message string MessageNoCmd string Sender *discordgo.User }
Command represents a chat command for a Beluga plugin to handle
type CommandPlugin ¶
CommandPlugin is the interface that plugins can implement to handle commands from a Discord channel
type CustomCommandsPlugin ¶
type CustomCommandsPlugin struct{}
CustomCommandsPlugin is our custom command creater and responder plugin
var Commands CustomCommandsPlugin
Commands is our ResponderPlugin instance
type Flags ¶
type Flags struct {
ConfigDir string `short:"c" long:"configDir" description:"Specify the directory to use for configuration files"`
}
Flags holds the global command-line flags
type GuildConfig ¶
type GuildConfig struct { EnabledPlugins []string CustomResponses map[string]string SlapConfig SlapPluginConfig }
GuildConfig is a guild-specific configuration
type HunterPlugin ¶
type HunterPlugin struct{}
HunterPlugin is our hunter2 plugin
var Hunter HunterPlugin
Hunter is our hunter2 plugin instance
type PluginManager ¶
PluginManager is the Beluga plugin manager
var Manager *PluginManager
Manager is our plugin manager for third-party plugins
func (*PluginManager) IsEnabled ¶
func (pm *PluginManager) IsEnabled(guild string, name string) bool
IsEnabled will check if the given plugin is enabled in the Beluga config
func (*PluginManager) IsLoaded ¶
func (pm *PluginManager) IsLoaded(name string) bool
IsLoaded will check if the given plugin name has an entry in our plugins map.
func (*PluginManager) LoadPlugins ¶
func (pm *PluginManager) LoadPlugins() error
LoadPlugins attempts to load all found plugins
func (*PluginManager) SendCommand ¶
func (pm *PluginManager) SendCommand(cmd Command)
SendCommand sends a chat command to all registered handlers
type RootConfig ¶
type RootConfig struct { // Token is the Discord bot token to use to connect to Discord Token string `toml:"discord_bot_token"` // Guilds contains the guild-specific configurations for each guild Guilds map[string]*GuildConfig }
RootConfig is our root configuration structure
var Config RootConfig
Config is our global Config object
func LoadConfig ¶
func LoadConfig() (conf RootConfig, err error)
LoadConfig will load the config and return it
func SetDefaults ¶
func SetDefaults() RootConfig
SetDefaults sets any sane default configuration options
type SlapPlugin ¶
type SlapPlugin struct{}
SlapPlugin is our slapping plugin
var Slapper SlapPlugin
Slapper is our slap plugin instance
type SlapPluginConfig ¶
type SlapPluginConfig struct { SelfSlap string `toml:"self-slap"` SlapMessages []string `toml:"slap-messages,omitempty"` }
SlapPluginConfig holds the configuration options for the slap plugin. These options are guild-specific
type UserBlacklist ¶
UserBlacklist contains the user ID's that are blacklisted from using commands
var Blacklist UserBlacklist
Blacklist is the list of users who are blacklisted from using commands
func LoadBlacklist ¶
func LoadBlacklist() (blacklist UserBlacklist, err error)
LoadBlacklist reads the blacklist file