plugins/plugins.go (view raw)
1package plugins
2
3type Plugin interface {
4 Triggers() []string
5 Execute() error
6}
7
8var Plugins = make(map[string]Plugin)
9
10func Register(p Plugin) {
11 for _, t := range p.Triggers() {
12 Plugins[t] = p
13 }
14}
15
16func ProcessCommands(cmd string) error {
17 for trigger, plugin := range Plugins {
18 if cmd == trigger {
19 err := plugin.Execute()
20 if err != nil {
21 return err
22 }
23 }
24 }
25 return nil
26}