You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It has chat matching functionality built-in, but you can extend it to handle all kinds of events.
Chat
Slacker can match regex or literal strings, then execute a given function (module optional).
defmoduleTARSdouseSlackeruseSlacker.Matchermatch~r/Sense of humor\. New level setting: ([0-9]+)%/,:set_humormatch"Great idea. A massive, sarcastic robot.",[CueLight,:turn_on]defset_humor(tars,msg,level)doreply="Sense of humor set to #{level}"saytars,msg["channel"],replyendend
Slacker will call your function with the matching message hash. You can use say/3 to respond, be sure to include the channel you want to talk to.
Extending Slacker
Your robot is really just a GenServer, you can catch RTM events from Slack and do whatever you like with them.
defmoduleCASEdouseSlackerdefhandle_cast({:handle_incoming,"presence_change",msg},state)dosayself,msg["channel"],"You're the man who brought us the probe?"{:noreply,state}endend
You can also use Slack's "Web API" via the Slacker.Web module. All of the available RPC methods are downcased and underscored.