Use Go templates for custom batch/group functions.

Templates get passed a message and can use a set of functions to build a
key, rather than having a set of tricky and relatively inflexible
options. It's a little complex, but this is a fairly advanced feature
anyway, and it's much better than having some kind of script
interpreter.

Error handling could be a lot better, but it's a good start, I think.