Documentation ¶
Index ¶
- Constants
- Variables
- func SetLogDir(logdir string)
- type Console
- type Event
- type Logger
- func (me *Logger) ClearLogs()
- func (me *Logger) Debug(v ...interface{})
- func (me *Logger) Debugf(format string, v ...interface{})
- func (me *Logger) Debugln(v ...interface{})
- func (me *Logger) Error(v ...interface{})
- func (me *Logger) Errorf(format string, v ...interface{})
- func (me *Logger) Errorln(v ...interface{})
- func (me *Logger) Fatal(v ...interface{})
- func (me *Logger) Fatalf(format string, v ...interface{})
- func (me *Logger) Fatalln(v ...interface{})
- func (me *Logger) Flags() int
- func (me *Logger) Info(v ...interface{})
- func (me *Logger) Infof(format string, v ...interface{})
- func (me *Logger) Infoln(v ...interface{})
- func (me *Logger) LenLogs() int
- func (me *Logger) Logs(n int) []string
- func (me *Logger) Panic(v ...interface{})
- func (me *Logger) Panicf(format string, v ...interface{})
- func (me *Logger) Panicln(v ...interface{})
- func (me *Logger) Prefix() string
- func (me *Logger) Priority() int32
- func (me *Logger) SetFlags(layouts int)
- func (me *Logger) SetPrefix(prefix string)
- func (me *Logger) SetPriority(priority int32)
- func (me *Logger) SetPriorityString(s string) error
- func (me *Logger) TailLogs(n int) []string
- func (me *Logger) Trace(v ...interface{})
- func (me *Logger) Tracef(format string, v ...interface{})
- func (me *Logger) Traceln(v ...interface{})
- func (me *Logger) Warn(v ...interface{})
- func (me *Logger) Warnf(format string, v ...interface{})
- func (me *Logger) Warnln(v ...interface{})
- type Module
- func (self *Module) Allow(target string) error
- func (self *Module) ClearAllowed(u userChan)
- func (self *Module) ClearDenyed(u userChan)
- func (self *Module) Deny(target string) error
- func (self *Module) Description() string
- func (self *Module) Disable()
- func (self *Module) Enable()
- func (self *Module) Enabled() bool
- func (self *Module) Exit() error
- func (self *Module) ForceExit() []error
- func (self *Module) GetAllowed(u userChan) []string
- func (self *Module) GetDenyed(u userChan) []string
- func (self *Module) GetROAllowed(u userChan) ([]string, chan<- bool)
- func (self *Module) GetRODenyed(u userChan) ([]string, chan<- bool)
- func (self *Module) Handle(eventMode Event, trigger string, line *irc.Line)
- func (self *Module) InAllowed(target string) bool
- func (self *Module) InDenyed(target string) bool
- func (self *Module) LenAllowed(u userChan) int
- func (self *Module) LenDenyed(u userChan) int
- func (self *Module) LogDir() string
- func (self *Module) Name() string
- func (self *Module) PreStart() error
- func (self *Module) Register(eventMode Event, trigger interface{}, fn func(*irc.Line))
- func (self *Module) RemAllowed(target string) error
- func (self *Module) RemDenyed(target string) error
- func (self *Module) SetDescription(desc string)
- func (self *Module) SetEnabled(en bool)
- func (self *Module) SetLogDir(logDir string)
- func (self *Module) Start() error
- func (self *Module) StringCommands() []string
- type ModuleInfo
Constants ¶
const ( UC_User userChan = true UC_Chan = false )
const ( Poff = iota Pfatal Perror Pwarn Pinfo Pdebug Ptrace Pall )
Priority used for identifying the severity of an event for Logger
const ( Ldate = log.Ldate // the date: 2012/01/23 Ltime = log.Ltime // the time: 01:23:23 Lmicroseconds = log.Lmicroseconds // microsecond resolution: 01:23:23.123123. assumes Ltime. Llongfile = log.Llongfile // full file name and line number: /a/b/c/d.go:23 Lshortfile = log.Lshortfile // final file name element and line number: d.go:23. overrides Llongfile LstdFlags = log.LstdFlags // initial values for the standard logger Lpriority = 1 << 5 // the priority: Debug )
Logger flags used for identifying the format of an event. They are or'ed together to control what's printed. There is no control over the order they appear (the order listed here) or the format they present (as described in the comments). A colon appears after these items:
2009/01/23 01:23:23.123123 /a/b/c/d.go:23: message
Variables ¶
var (
Events = make([]Event, 0, 5)
)
Events is a slice of Events which are registered when irclibrary.Connect() is called. This is export primarily for the use of irclibrary and should not need to be modified by the user
Functions ¶
Types ¶
type Console ¶
type Console struct {
// contains filtered or unexported fields
}
Console struct to manage and parse commands
func (*Console) Parse ¶
Parse cmd and run associated functions. 'cmd' is lowered before parsing string triggers. String and regexp functions spawn goroutines
func (*Console) Register ¶
Register a `string` or `regexp.Regexp` returning an error if `trigger` is already registered
func (*Console) Unregister ¶
Unregister a `string` or `regexp.Regexp` returning an error if `trigger` was not registered
type Event ¶
type Event string
const ( E_REGISTER Event = "REGISTER" E_CONNECTED Event = "CONNECTED" E_DISCONNECTED Event = "DISCONNECTED" E_ACTION Event = "ACTION" E_AWAY Event = "AWAY" E_CTCP Event = "CTCP" E_CTCPREPLY Event = "CTCPREPLY" E_INVITE Event = "INVITE" E_JOIN Event = "JOIN" E_KICK Event = "KICK" E_MODE Event = "MODE" E_NICK Event = "NICK" E_NOTICE Event = "NOTICE" E_OPER Event = "OPER" E_PART Event = "PART" E_PASS Event = "PASS" E_PING Event = "PING" E_PONG Event = "PONG" E_PRIVMSG Event = "PRIVMSG" E_QUIT Event = "QUIT" E_TOPIC Event = "TOPIC" E_USER Event = "USER" E_VERSION Event = "VERSION" E_VHOST Event = "VHOST" E_WHO Event = "WHO" E_WHOIS Event = "WHOIS" )
IRC events to trigger on
func RegisteredEvents ¶
func RegisteredEvents() []Event
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger defines our wrapper around the system logger
func (*Logger) ClearLogs ¶
func (me *Logger) ClearLogs()
Clears saved logs slice, not those stored to disk
func (*Logger) Debug ¶
func (me *Logger) Debug(v ...interface{})
Debug prints to the standard logger with the Debug level.
func (*Logger) Debugln ¶
func (me *Logger) Debugln(v ...interface{})
Debugln prints to the standard logger with the Debug level.
func (*Logger) Error ¶
func (me *Logger) Error(v ...interface{})
Error prints to the standard logger with the Error level.
func (*Logger) Errorln ¶
func (me *Logger) Errorln(v ...interface{})
Errorln prints to the standard logger with the Error level.
func (*Logger) Fatal ¶
func (me *Logger) Fatal(v ...interface{})
Fatal prints the message it's given and quits the program
func (*Logger) Fatalln ¶
func (me *Logger) Fatalln(v ...interface{})
Fatalln prints the message it's given and quits the program
func (*Logger) Info ¶
func (me *Logger) Info(v ...interface{})
Info prints to the standard logger with the Info level.
func (*Logger) Infoln ¶
func (me *Logger) Infoln(v ...interface{})
Infoln prints to the standard logger with the Info level.
func (*Logger) Logs ¶
Return a copy of logs[:min(n, len(logs))]. If n is 0 a copy of logs is returned. Calling Logs() with n < 0 is the same as calling TailLogs(-n)
func (*Logger) Panic ¶
func (me *Logger) Panic(v ...interface{})
Panic prints the message it's given and panic()s the program
func (*Logger) Panicln ¶
func (me *Logger) Panicln(v ...interface{})
Panicln prints the message it's given and panic()s the program
func (*Logger) SetPriority ¶
SetPriority sets the output priority for the logger.
func (*Logger) SetPriorityString ¶
SetPriorityString sets the output priority by the name of a debug level
func (*Logger) TailLogs ¶
Returns a copy of logs[len(logs) - min(n, len(logs):]. Calling TailLogs(n) where n < 0 is equivalent to calling Logs(-n)
func (*Logger) Trace ¶
func (me *Logger) Trace(v ...interface{})
Trace prints to the standard logger with the Trace level.
func (*Logger) Traceln ¶
func (me *Logger) Traceln(v ...interface{})
Traceln prints to the standard logger with the Trace level.
func (*Logger) Warn ¶
func (me *Logger) Warn(v ...interface{})
Warn prints to the standard logger with the Warn level.
type Module ¶
type Module struct { // IRC Connection. Conn is not assigned until it is registered Conn *irc.Conn // Connect functions to call before or after IRC connection // Disconnect is called after disconnected from IRC // Errors are logged to to the module Logger Preconnect, Connected, Disconnect func() error Console *Console // Console handler; commands are triggered with ":moduleName <command>" Logger *Logger // contains filtered or unexported fields }
Module repersents the state of the module
func New ¶
Read a TOML file and return a configured Module. Errors indicate a failure to parse the file or an incomplete configuration
func (*Module) Allow ¶
Allow user or channels; channels should begin with '#'. Returns an error if 'target' is already in the slice. Does not remove user or channel from allow(User|Chan) slices
func (*Module) ClearAllowed ¶
func (self *Module) ClearAllowed(u userChan)
Clears allow(User|Chan) slices
func (*Module) ClearDenyed ¶
func (self *Module) ClearDenyed(u userChan)
Clears deny(User|Chan) slices
func (*Module) Deny ¶
Deny user or channels; channels should begin with '#'. Returns an error if 'target' is already in the slice. Does not remove user or channel from deny(User|Chan) slices
func (*Module) Description ¶
func (self *Module) Description() string
Returns the module description
func (*Module) Disable ¶
func (self *Module) Disable()
Helper function to disable the module. Calls `moduleConfig.SetEnabled(false)`
func (*Module) Enable ¶
func (self *Module) Enable()
Helper function to enable the module. Calls `moduleConfig.SetEnabled(true)`
func (*Module) Exit ¶
Calls Disconnect(), cleans up, and exits. Errors returned by Disconnect() are logged and Exit() continues. If there is an error at any other point the error is returned and should be assumed that cleanup did not complete.
func (*Module) ForceExit ¶
Calls Disconnect(), cleans up, and exits. ForceExit() continues on errors, which are aggregated and returned in a slice. If there are no errors `nil` is returned
func (*Module) GetAllowed ¶
func (self *Module) GetAllowed(u userChan) []string
Returns a copy (not slice header) of allow(User|Chan) slices. If copies are too expensive look at GetROAllowed()
func (*Module) GetDenyed ¶
func (self *Module) GetDenyed(u userChan) []string
Returns a copy (not slice header) of deny(User|Chan) slices. If copies are too expensive look at GetRODenyed()
func (*Module) GetROAllowed ¶
Returns a copy of the appropriate slice header to avoid copies. This is a promise by the user to not modify the slice and enforced by a RLock() on the slice. The lock is released by closing the chan or sending a boolean value
func (*Module) GetRODenyed ¶
Returns a copy of the appropriate slice header to avoid copies. This is a promise by the user to not modify the slice and enforced by a RLock() on the slice. The lock is released by closing the chan or sending a boolean value
func (*Module) Handle ¶
Handles triggers if module is enabled and user/chan is allowed. This is mainly exported for use by library and should not have to be called by the user
func (*Module) InAllowed ¶
Returns true if 'target' is in allow(User|Chan); chans should begin with '#'
func (*Module) InDenyed ¶
Returns true if 'target' is in deny(User|Chan); chans should begin with '#'
func (*Module) LenAllowed ¶
func (self *Module) LenAllowed(u userChan) int
Returns the length of allow(User|Chan)
func (*Module) LenDenyed ¶
func (self *Module) LenDenyed(u userChan) int
Returns the length of allow(User|Chan)
func (*Module) LogDir ¶
func (self *Module) LogDir() string
Returns the directory logs are saved to. Full log path is "moduleConfig.logDir/moduleConfig.name"
func (*Module) PreStart ¶
Creates a Logger if necessay and calls Preconnect() if applicable. This is exported for use by library and most likely doesn't need to be called by the user. Error is non-nil if a logger could not be created or Preconnect() returned an error; errors returned by Preconnect() are logged
func (*Module) RemAllowed ¶
Removes user or channel from respective allowed slices; channels should begin with '#'. Returns an error if 'target' is not in the slice
func (*Module) RemDenyed ¶
Removes user or channel from respective denyed slices; channels should begin with '#'. Returns an error if 'target' is not in the slice
func (*Module) SetDescription ¶
func (self *Module) SetDescription(desc string)
Set module description
func (*Module) SetLogDir ¶
func (self *Module) SetLogDir(logDir string)
Sets the directory logs are saved to. This does not take effect until the module is restarted
func (*Module) Start ¶
Creates a Logger if necessay and calls Connet() if applicable. This is exported for use by library and most likely does not need to be called by the user. Error is non-nil if a logger could not be created, module is already running or Connect() returned an error; errors returned by Connect() are logged
func (*Module) StringCommands ¶
Returns a list of IRC commands registered
type ModuleInfo ¶
type ModuleInfo struct { Name string // Unique name or registering and triggering console commands Description string // Description of module LogDir string // Directory to keep logs, defaults to ./logs/ Enabled bool // Flag to see if module is enabled // Filtered by: denyUser, allowUser, denyChan, allowChan // ToLower is called on slices when creating a Module AllowUser, DenyUser []string // Slice of allowed or denyed users AllowChan, DenyChan []string // Slice of allowed or denyed chans }
ModuleInfo repersents configuration fields that can be loaded from TOML files
func (*ModuleInfo) NewModule ¶
func (self *ModuleInfo) NewModule() (*Module, error)
Returns a configured Module from ModuleInfo. ModuleInfo.Name and ModuleInfo.Description can not be an empty string