Creating Event Handlers
Learn about event handlers and how to incorporate them in a ChatOps bot.
We'll cover the following
Creation
The HandleFunc
type defines our functionality. This is also where we decide how we want to turn a bunch of text into a command to run.
There are a few ways to interpret raw text:
Regexes via the
regexp
packageString manipulation via the
strings
packageDesigning or using a lexer and parser
Regexes and string manipulation are the fastest ways for an application of this type where we have single lines of text.
Lexers and parsers are great when dealing with complex inputs or multi-line text and cannot afford mistakes. This is the method that compilers use to read our textual code into instructions that eventually lead to a compiled binary. The downside is that they are tedious to build and hard to train new people on.
Get hands-on with 1400+ tech skills courses.