Created
April 13, 2013 19:08
-
-
Save blinsay/5379652 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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