1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- package plugins
- import (
- "log"
- "notabug.org/mouz/bot/irc"
- )
- type Plugin interface {
-
-
- Load(irc.Profile) error
-
- Unload(irc.Profile) error
-
-
- Dispatch(irc.ResponseWriter, *irc.Request)
- }
- var plugins []Plugin
- func Register(p Plugin) { plugins = append(plugins, p) }
- func Load(prof irc.Profile) {
- for _, p := range plugins {
- log.Printf("[plugins] Loading: %T", p)
- err := p.Load(prof)
- if err != nil {
- log.Printf("[%T] %v", p, err)
- }
- }
- }
- func Unload(prof irc.Profile) {
- for _, p := range plugins {
- log.Printf("[plugins] Unloading: %T", p)
- err := p.Unload(prof)
- if err != nil {
- log.Printf("[%T] %v", p, err)
- }
- }
- }
- func Dispatch(w irc.ResponseWriter, r *irc.Request) {
- for _, p := range plugins {
- go p.Dispatch(w, r)
- }
- }
|