Skip to content

Instantly share code, notes, and snippets.

@blinsay
Created April 13, 2013 19:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blinsay/5379652 to your computer and use it in GitHub Desktop.
Save blinsay/5379652 to your computer and use it in GitHub Desktop.
func Create(bot *core.Gobot) {
// matches is actually a map[string]string
matches, found := bot.Config.Plugins["matcher"]["matches"]
if !found {
log.Printf("Can't find matcher/matches plugin conf. Plugin will not run.")
return
}
switch matches := matches.(type) {
case map[string]interface{}:
for pattern, replacement := range matches {
switch replacement := replacement.(type) {
case string:
bot.ListenFor(pattern, func(msg core.Message, matches []string) error {
msg.Send(regex.WhateverSubIsActuallyCalled(pattern, replacement))
return nil
})
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment