Fawkes v0.4.1 Fawkes.Listener View Source

Link to this section Summary

Functions

Defines a listener that will "hear" any matching regex and call the provided callback function.

Defines a generic listener. This listener receives all events and passes them to the matcher function. If the matcher function returns a truthy value then the second callback will be executed with the value passed as the first argument and the event as the second. If the matcher returns false then the callback will be skipped. If you need to return a falsey value from your matcher you will need to wrap it in another value such as a tuple or a map.

Defines a listener that will only trigger if the bot was mentioned and the regex pattern is matched. Respond assumes that the message mentions the bot as the first part of text.

Link to this section Functions

Link to this macro

hear(regex, f)

View Source (macro)

Defines a listener that will "hear" any matching regex and call the provided callback function.

Link to this macro

listen(matcher, f)

View Source (macro)

Defines a generic listener. This listener receives all events and passes them to the matcher function. If the matcher function returns a truthy value then the second callback will be executed with the value passed as the first argument and the event as the second. If the matcher returns false then the callback will be skipped. If you need to return a falsey value from your matcher you will need to wrap it in another value such as a tuple or a map.

The callback can either be a 2 arity or 3 arity function with the optional 3rd argument being the current state for the handler.

Link to this macro

respond(regex, f)

View Source (macro)

Defines a listener that will only trigger if the bot was mentioned and the regex pattern is matched. Respond assumes that the message mentions the bot as the first part of text.