Documentation ¶
Index ¶
- Variables
- func AnnounceLibera(c *girc.Client)
- func BanUser(c *girc.Client, channel string, user string)
- func BanUsers(c *girc.Client, channel string, users []string)
- func DeduplicateList(list []string) []string
- func GetNowAsISO8601() (now string)
- func GetRandomString(list []string) (item string)
- func Ghost(c *girc.Client)
- func IsAdmin(issuer, fullIssuer, host string) (userIsAdmin bool)
- func IsInStringArr(list []string, item string) bool
- func KickUser(c *girc.Client, e girc.Event, m NarwhalMessage, user string)
- func KickUsers(c *girc.Client, e girc.Event, m NarwhalMessage)
- func Matches(requirement string, checking string) bool
- func NewTusk()
- func OnConnected(c *girc.Client, e girc.Event)
- func OnInvite(c *girc.Client, e girc.Event)
- func OnJoin(c *girc.Client, e girc.Event)
- func OnKick(c *girc.Client, e girc.Event)
- func OnLeave(c *girc.Client, e girc.Event)
- func Parser(c *girc.Client, e girc.Event)
- func PrintPrettyMessage(m NarwhalMessage)
- func RemoveFromStringArr(list []string, items []string) []string
- func SaveConfig()
- func Shutdown(c *girc.Client)
- func UnbanUser(c *girc.Client, channel string, user string)
- func UnbanUsers(c *girc.Client, channel string, users []string)
- type NarwhalAdminConfig
- type NarwhalAdminPlugin
- func (adminmanager *NarwhalAdminPlugin) AddAdmin(c *girc.Client, user string)
- func (adminmanager *NarwhalAdminPlugin) Blacklist(users []string)
- func (adminmanager *NarwhalAdminPlugin) CommandIssuer(c *girc.Client, e girc.Event, m NarwhalMessage)
- func (adminmanager *NarwhalAdminPlugin) Parse(c *girc.Client, e girc.Event, m NarwhalMessage)
- func (adminmanager *NarwhalAdminPlugin) RemoveAdmin(c *girc.Client, user string)
- func (adminmanager *NarwhalAdminPlugin) RemoveFromBlacklist(users []string)
- type NarwhalAutoKickerConfig
- type NarwhalAutoKickerPlugin
- func (autokicker *NarwhalAutoKickerPlugin) AddHost(host string)
- func (autokicker *NarwhalAutoKickerPlugin) AddMessage(message string)
- func (autokicker *NarwhalAutoKickerPlugin) AddUsers(users []string)
- func (autokicker *NarwhalAutoKickerPlugin) Parse(c *girc.Client, e girc.Event, m NarwhalMessage)
- func (autokicker *NarwhalAutoKickerPlugin) RemoveHost(host string)
- func (autokicker *NarwhalAutoKickerPlugin) RemoveMessage(message string)
- func (autokicker *NarwhalAutoKickerPlugin) RemoveUsers(users []string)
- type NarwhalConfig
- type NarwhalMessage
- type NarwhalPlugin
- type NarwhalPluginManager
- type NarwhalPluginsConfig
- type NarwhalReplacerConfig
- type NarwhalReplacerPlugin
- type NarwhalSlapConfig
- type NarwhalSlapPlugin
- type NarwhalSongPlugin
- type NarwhalThankMePlugin
- type NarwhalUrlParserPlugin
- type NarwhalUsersConfig
Constants ¶
This section is empty.
Variables ¶
var ConfigFoundPath string
ConfigFoundPath is the directory we found the config in
var (
MessageBreaker = strings.Repeat("-", 80)
)
var Paths []string
Consistent paths
Functions ¶
func AnnounceLibera ¶
func DeduplicateList ¶
DeduplicateList will eliminate duplicates from a list
func GetNowAsISO8601 ¶
func GetNowAsISO8601() (now string)
GetNowAsISO8601 will return the current date / time as ISO 8601
func GetRandomString ¶
GetRandomString will get a random string from our array
func IsAdmin ¶
IsAdmin will check our issuer, fullIssuer (includes ident), and host if they match our admin list
func IsInStringArr ¶
IsInStringArr will check if this item is in the specified string array
func KickUsers ¶
func KickUsers(c *girc.Client, e girc.Event, m NarwhalMessage)
KickUsers will kick multiple users from a channel
func Matches ¶
Matches is our string match function that checks our provided string against a requirement Such requirement can be basic globbing, regex, or exact match.
func NewTusk ¶
func NewTusk()
NewTusk will create a new tusk for our Narwhal, but only one tusk is allowed at a time.
func OnConnected ¶
OnConnected will handle connection to an IRC network
func PrintPrettyMessage ¶
func PrintPrettyMessage(m NarwhalMessage)
PrintPrettyMessage will print to out output a slightly prettier version of this Message
func RemoveFromStringArr ¶
RemoveFromStringArr will remove items from the string array
func SaveConfig ¶
func SaveConfig()
SaveConfig will save the config in our previously recognized location
Types ¶
type NarwhalAdminConfig ¶
type NarwhalAdminConfig struct { // DisabledCommands is a list of admin commands to disable DisabledCommands []string }
NarwhalAdminConfig is our configuration for the Narwhal admin plugin
type NarwhalAdminPlugin ¶
type NarwhalAdminPlugin struct{}
NarwhalAdminPlugin is our Admin plugin
var NarwhalAdminManager NarwhalAdminPlugin
NarwhalAdminManager is our admin management plugin
func (*NarwhalAdminPlugin) AddAdmin ¶
func (adminmanager *NarwhalAdminPlugin) AddAdmin(c *girc.Client, user string)
AddAdmin will add a user to the admin list This will add them based on the provided nick. If they are currently on the network, we will add them based on their ident as well.
func (*NarwhalAdminPlugin) Blacklist ¶
func (adminmanager *NarwhalAdminPlugin) Blacklist(users []string)
Blacklist will add users to the blacklist
func (*NarwhalAdminPlugin) CommandIssuer ¶
func (adminmanager *NarwhalAdminPlugin) CommandIssuer(c *girc.Client, e girc.Event, m NarwhalMessage)
CommandIssuer is our primary function for command and param handling
func (*NarwhalAdminPlugin) Parse ¶
func (adminmanager *NarwhalAdminPlugin) Parse(c *girc.Client, e girc.Event, m NarwhalMessage)
func (*NarwhalAdminPlugin) RemoveAdmin ¶
func (adminmanager *NarwhalAdminPlugin) RemoveAdmin(c *girc.Client, user string)
RemoveAdmin will remove a user from the admin list This will remove them based on the provided nick. If they are currently on the network, we will remove them based on their ident as well.
func (*NarwhalAdminPlugin) RemoveFromBlacklist ¶
func (adminmanager *NarwhalAdminPlugin) RemoveFromBlacklist(users []string)
RemoveFromBlacklist will remove users from the blacklist
type NarwhalAutoKickerConfig ¶
type NarwhalAutoKickerConfig struct { // EnabledAutoban determines whether to enable the automatic banning of users which exceed our MinimumKickToBanCount EnabledAutoban bool `json:",omitempty"` // Hosts to kick. Matches from end. Hosts []string // MessageMatches is a list of messages that will result in kicks MessageMatches []string // MinimumKickToBanCount is a minimum amount of times a user should be kicked before being automatically banned. Only enforced when EnabledAutoban is set MinimumKickToBanCount int `json:",omitempty"` // Users to kick. Matches from beginning. Users []string }
NarwhallAutoKickerConfig is our configuration for the Narwhal autokicker
type NarwhalAutoKickerPlugin ¶
type NarwhalAutoKickerPlugin struct { // Tracker is a map of usernames to the amount of times they've been kicked Tracker map[string]int }
NarwhalAutoKickerPlugin is our Autokick plugin
var NarwhalAutoKicker NarwhalAutoKickerPlugin
NarwhalAutoKicker is our autokicker plugin
func (*NarwhalAutoKickerPlugin) AddHost ¶
func (autokicker *NarwhalAutoKickerPlugin) AddHost(host string)
AddHost will add the specified host to the AutoKick Hosts list, if they aren't already added
func (*NarwhalAutoKickerPlugin) AddMessage ¶
func (autokicker *NarwhalAutoKickerPlugin) AddMessage(message string)
AddMessage will add the specified message to the AutoKick MessageMatches list, if they aren't already added
func (*NarwhalAutoKickerPlugin) AddUsers ¶
func (autokicker *NarwhalAutoKickerPlugin) AddUsers(users []string)
AddUsers will add the specified users to the AutoKick Users list, if they aren't already added
func (*NarwhalAutoKickerPlugin) Parse ¶
func (autokicker *NarwhalAutoKickerPlugin) Parse(c *girc.Client, e girc.Event, m NarwhalMessage)
func (*NarwhalAutoKickerPlugin) RemoveHost ¶
func (autokicker *NarwhalAutoKickerPlugin) RemoveHost(host string)
RemoveHost will remove the specified host from the AutoKick Hosts list, if they are added
func (*NarwhalAutoKickerPlugin) RemoveMessage ¶
func (autokicker *NarwhalAutoKickerPlugin) RemoveMessage(message string)
RemoveMessage will remove the specified message from the AutoKick MessageMatches list, if they are added
func (*NarwhalAutoKickerPlugin) RemoveUsers ¶
func (autokicker *NarwhalAutoKickerPlugin) RemoveUsers(users []string)
RemoveUsers will remove the specified users from the AutoKick Users list, if they are added
type NarwhalConfig ¶
type NarwhalConfig struct { // Network is the IRC network to connection to. Network string `toml:"Network"` // Port is the port on the network we're connecting to. Likely 6667. Port int `toml:"Port,omitempty"` // LiberaAnnounceMigration enables the option to passively announce a move from a different IRC network to Libera LiberaAnnounceMigration bool // User is the IRC Bot username User string // Name is the IRC Bot name Name string // FallbackNick is the IRC bot fallback nickname if first nick is registered to someone else FallbackNick string `toml:"FallbackNick,omitempty"` // Password is the IRC bot password for authentication Password string // Plugins is a list of plugin configurations Plugins NarwhalPluginsConfig `toml:"Plugins,omitempty"` // Channels is a list of channels to join Channels []string // Users is our users configuration Users NarwhalUsersConfig `toml:"Users,omitempty"` }
NarwhalConfig is our primary Narwhal configuration
var Config NarwhalConfig
Config is our Narwhal Config
func ReadConfig ¶
func ReadConfig() (NarwhalConfig, error)
ReadConfig will read our narwhal configuration, if it exists, and return it
func SetDefaults ¶
func SetDefaults(config NarwhalConfig) NarwhalConfig
SetDefaults will set the defaults for the provided NarwhalConfig
type NarwhalMessage ¶
type NarwhalMessage struct { Admin bool Authenticated bool Channel string Command string Host string FullIssuer string Issuer string Message string MessageNoCmd string Params []string }
NarwhalMessage is a custom message
func ParseMessage ¶
func ParseMessage(c *girc.Client, e girc.Event) NarwhalMessage
ParseMessage will parse an event and return a NarwhalMessage
type NarwhalPlugin ¶
type NarwhalPlugin interface {
Parse(c *girc.Client, e girc.Event, m NarwhalMessage)
}
NarwhalPlugin is a plugin interface
type NarwhalPluginManager ¶
NarwhalPluginManager is our plugin manager
var PluginManager NarwhalPluginManager
PluginManager is our Plugin Manager
func (*NarwhalPluginManager) IsEnabled ¶
func (pm *NarwhalPluginManager) IsEnabled(pluginName string) bool
IsEnabled will return if the plugin specified is enabled
func (*NarwhalPluginManager) LoadPlugins ¶
func (pm *NarwhalPluginManager) LoadPlugins() error
LoadPlugins is responsible for loading any plugins from our modules directory
type NarwhalPluginsConfig ¶
type NarwhalPluginsConfig struct { Enabled []string Admin NarwhalAdminConfig `toml:"Admin,omitempty"` AutoKick NarwhalAutoKickerConfig `toml:"AutoKick,omitempty"` Replacer NarwhalReplacerConfig `toml:"Replacer,omitempty"` Slap NarwhalSlapConfig `toml:"Slap,omitempty"` }
NarwhalPluginsConfig is a list of command configurations
type NarwhalReplacerConfig ¶
type NarwhalReplacerConfig struct { // CachedMessageLimit is our limit of how many messages to cache CachedMessageLimit int }
NarwhalReplacerConfig is our configuration for the Narwhal replacer plugin
type NarwhalReplacerPlugin ¶
type NarwhalReplacerPlugin struct{}
NarwhalReplacerPlugin is our Replacer plugin
var NarwhalReplacer NarwhalReplacerPlugin
NarwhalReplacer is our string replacer plugin
func (*NarwhalReplacerPlugin) AddToCache ¶
func (replacer *NarwhalReplacerPlugin) AddToCache(m NarwhalMessage)
AddToCache will add the provided messaged to our cached list and remove the first entry if we get above our limit
func (*NarwhalReplacerPlugin) Parse ¶
func (replacer *NarwhalReplacerPlugin) Parse(c *girc.Client, e girc.Event, m NarwhalMessage)
type NarwhalSlapConfig ¶
type NarwhalSlapConfig struct { // CustomActions is a list of custom actions on how to slap a user CustomActions []string }
NarwhalSlapConfig is our configuration for the Narwhal autokicker
type NarwhalSlapPlugin ¶
type NarwhalSlapPlugin struct {
Messages []string
}
NarwhalSlapPlugin is our slap plugin
var NarwhalSlap NarwhalSlapPlugin
NarwhalSlap is our slap plugin
func (*NarwhalSlapPlugin) Parse ¶
func (slap *NarwhalSlapPlugin) Parse(c *girc.Client, e girc.Event, m NarwhalMessage)
type NarwhalSongPlugin ¶
type NarwhalSongPlugin struct{}
NarwhalSong is our Song plugin
var NarwhalSong NarwhalSongPlugin
NarwhalSong is our song plugin
func (*NarwhalSongPlugin) Parse ¶
func (song *NarwhalSongPlugin) Parse(c *girc.Client, e girc.Event, m NarwhalMessage)
type NarwhalThankMePlugin ¶
type NarwhalThankMePlugin struct {
Messages []string
}
NarwhalThankMePlugin is our Thank Me plugin The goal is just to reply with something random like "No problem" when thanked
var NarwhalThank NarwhalThankMePlugin
NarwhalThank is our thank me plugin
func (*NarwhalThankMePlugin) Parse ¶
func (thank *NarwhalThankMePlugin) Parse(c *girc.Client, e girc.Event, m NarwhalMessage)
type NarwhalUrlParserPlugin ¶
type NarwhalUrlParserPlugin struct{}
NarwhalUrlParserPlugin is our URL plugin
var NarwhalUrlParser NarwhalUrlParserPlugin
NarwhalUrlParser is our url parser
func (*NarwhalUrlParserPlugin) Parse ¶
func (parser *NarwhalUrlParserPlugin) Parse(c *girc.Client, e girc.Event, m NarwhalMessage)
type NarwhalUsersConfig ¶
type NarwhalUsersConfig struct { // Admins is an array of users authorized to perform admin actions Admins []string // Blacklist is an array of users blacklisted from performing Plugins Blacklist []string }
NarwhalUsersConfig is our configuration for blacklisting users, administrative users, and autokicking