{"id":23478274,"url":"https://github.com/willis7/slack","last_synced_at":"2026-05-01T04:41:51.068Z","repository":{"id":71222782,"uuid":"89534826","full_name":"willis7/slack","owner":"willis7","description":"A Slack client for the Go programming language","archived":false,"fork":false,"pushed_at":"2017-05-03T20:07:33.000Z","size":5,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-04-20T18:38:58.104Z","etag":null,"topics":["api","golang","slack"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/willis7.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2017-04-26T23:15:30.000Z","updated_at":"2017-05-03T20:08:20.000Z","dependencies_parsed_at":null,"dependency_job_id":"1392512f-d872-4f43-8b67-1081e236f9cb","html_url":"https://github.com/willis7/slack","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/willis7/slack","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willis7%2Fslack","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willis7%2Fslack/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willis7%2Fslack/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willis7%2Fslack/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/willis7","download_url":"https://codeload.github.com/willis7/slack/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willis7%2Fslack/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32485297,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-30T13:12:12.517Z","status":"online","status_checked_at":"2026-05-01T02:00:05.856Z","response_time":64,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["api","golang","slack"],"created_at":"2024-12-24T19:18:30.787Z","updated_at":"2026-05-01T04:41:51.051Z","avatar_url":"https://github.com/willis7.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Slack\n\nThis project started as an embedded package in my Golossary project. After a positive code review from Brian Ketelsen I decided to open source this code as a standalone package.\n\n## Design\n\nThis package was heavily influenced by the `net/http` package which allows users to define a `Handler` for a given pattern. The same principle is used here for events:\n\n``` go\n    mux := slack.NewEventMux()\n    mux.Handle(\"message\", slack.HandlerFunc(RTMMessage))\n```\n\nIn the example above we use the user defined `RTMMessage` function, which satisfies the `Handler` interface with the `message` event. Similarly, we could apply our  `RTMHello` function to the `hello` event. This might look like:\n\n``` go\n    ...\n    mux.Handle(\"hello\", slack.HandlerFunc(RTMHello))\n```\n\n## Client Lifecycle\n\n### Connecting to Slack\n\nTo create a new client we first need to run:\n\n`client := slack.NewClient(token, mux)`\n\nYou're required to provide an `EventMux` here because it would be a useless client if it didn't know how to handle events. No default Event mux is provided.\n\nTo open a connection with Slack you will need to call:\n``` go\nclient.Connect()\ndefer client.Close()\n```\n\nRemeber to close the connection! \n\nNext we need to tell the client to start dispatching messages with:\n\n`go client.Dispatch()`\n\nAt this point its really up to the user to shutdown the connection gracefully. Here's an example of how I do it:\n\n```go\n\tsigterm := make(chan os.Signal)\n\tsignal.Notify(sigterm, os.Interrupt)\n\tfor {\n\t\tselect {\n\t\tcase \u003c-sigterm:\n\t\t\tlog.Println(\"terminate signal recvd\")\n\t\t\terr := client.Shutdown()\n\t\t\tif err != nil {\n\t\t\t\tlog.Println(\"write close:\", err)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tselect {\n\t\t\tcase \u003c-time.After(time.Second):\n\t\t\t}\n\t\t\tclient.Close()\n\t\t\treturn\n\t\t}\n\t}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwillis7%2Fslack","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwillis7%2Fslack","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwillis7%2Fslack/lists"}