{"id":13507558,"url":"https://github.com/koudelka/slacker","last_synced_at":"2025-08-20T22:32:23.061Z","repository":{"id":31741308,"uuid":"35307342","full_name":"koudelka/slacker","owner":"koudelka","description":"An Elixir Slack bot! (work in progress)","archived":false,"fork":false,"pushed_at":"2016-06-27T19:05:58.000Z","size":17,"stargazers_count":83,"open_issues_count":1,"forks_count":16,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-12-10T04:10:24.289Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/koudelka.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-05-08T23:49:11.000Z","updated_at":"2024-09-04T13:37:15.000Z","dependencies_parsed_at":"2022-08-29T16:00:44.836Z","dependency_job_id":null,"html_url":"https://github.com/koudelka/slacker","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koudelka%2Fslacker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koudelka%2Fslacker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koudelka%2Fslacker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koudelka%2Fslacker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/koudelka","download_url":"https://codeload.github.com/koudelka/slacker/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230462907,"owners_count":18229864,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T02:00:36.113Z","updated_at":"2024-12-19T16:12:29.998Z","avatar_url":"https://github.com/koudelka.png","language":"Elixir","funding_links":[],"categories":["Chatting","Frameworks and libraries"],"sub_categories":["Slack"],"readme":"Slacker\n=======\n\nSlacker's an Elixir bot library for [Slack](https://slack.com).\n\nIt has chat matching functionality built-in, but you can extend it to handle all kinds of [events](https://api.slack.com/events).\n\n### Chat\n\nSlacker can match regex or literal strings, then execute a given function (module optional).\n\n```elixir\ndefmodule TARS do\n  use Slacker\n  use Slacker.Matcher\n  \n  match ~r/Sense of humor\\. New level setting: ([0-9]+)%/, :set_humor\n  match \"Great idea. A massive, sarcastic robot.\", [CueLight, :turn_on]\n\n  def set_humor(tars, msg, level) do\n    reply = \"Sense of humor set to #{level}\"\n    say tars, msg[\"channel\"], reply\n  end\nend\n```\n\nSlacker will call your function with the matching [message hash](https://api.slack.com/events/message). You can use `say/3` to respond, be sure to include the channel you want to talk to.\n\n### Extending Slacker\nYour robot is really just a `GenServer`, you can catch [RTM events](https://api.slack.com/events) from Slack and do whatever you like with them.\n\n```elixir\ndefmodule CASE do\n  use Slacker\n\n  def handle_cast({:handle_incoming, \"presence_change\", msg}, state) do\n    say self, msg[\"channel\"], \"You're the man who brought us the probe?\"\n    {:noreply, state}\n  end\n\nend\n```\n\nYou can also use Slack's [\"Web API\"](https://api.slack.com/methods) via the `Slacker.Web` module. All of the available RPC methods are downcased and underscored.\n\n`users.getPresence` -\u003e `Slacker.Web.users_get_presence(\"your_api_key\", user: \"U1234567890\")`\n\n### Bootin' it up\nAdd this to your deps:\n\n```elixir\ndef deps do\n  [{:websocket_client, github: \"jeremyong/websocket_client\"},\n  {:slacker,  \"~\u003e 0.0.3\"}]\nend\n```\n\nCreate a [bot user](https://api.slack.com/bot-users) in the Slack GUI, and then pass your api token to your bot's `start_link/1`:\n\n`{:ok, tars} = TARS.start_link(\"your_api_token\")`\n\nIt's up to you to supervise your brand new baby bot.\n\nYou're going to need to invite your bot to a channel by `@`-mentioning them.\n\n### Contributing\nGimme dem PR's.\n\nSome of this stuff is a real pain in the ass to test, just do your best. :rocket:\n\nTODO:\n- Keep a map of usernames to ids.\n- Keep a map of channel names to ids.\n- Private messaging support.\n- RTM tests.\n\n## License\n\nSee the LICENSE file. (MIT)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkoudelka%2Fslacker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkoudelka%2Fslacker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkoudelka%2Fslacker/lists"}