// Init initializes the plugin. it loads configuration data and binds // commands and protocol handlers. func (p *Plugin) Load(c *proto.Client) (err error) { err = p.Base.Load(c) if err != nil { return } c.Bind(proto.CmdPrivMsg, func(c *proto.Client, m *proto.Message) { p.parseSexpr(c, m) }) ini := p.LoadConfig() if ini == nil { return } s := ini.Section("exclude") list := s.List("url") p.exclude = make([]*regexp.Regexp, len(list)) for i := range list { p.exclude[i], err = regexp.Compile(list[i]) if err != nil { return } } return }
// bind binds protocol message handlers. func bind(c *proto.Client) { c.Bind(proto.Unknown, onAny) c.Bind(proto.CmdPing, onPing) c.Bind(proto.EndOfMOTD, onJoinChannels) c.Bind(proto.ErrNoMOTD, onJoinChannels) c.Bind(proto.ErrNicknameInUse, onNickInUse) c.Bind(proto.CmdPrivMsg, onPrivMsg) }