{"id":19301286,"url":"https://github.com/fuglede/slackbot","last_synced_at":"2025-11-16T13:01:40.565Z","repository":{"id":90007519,"uuid":"98232409","full_name":"fuglede/slackbot","owner":"fuglede","description":"Yet another Go implementation of the Slack RTM API.","archived":false,"fork":false,"pushed_at":"2020-07-28T10:29:44.000Z","size":15,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2023-02-27T22:22:14.516Z","etag":null,"topics":["hacktoberfest","slackbot","websocket"],"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/fuglede.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}},"created_at":"2017-07-24T20:31:55.000Z","updated_at":"2024-06-19T12:40:43.454Z","dependencies_parsed_at":"2023-05-30T22:00:23.546Z","dependency_job_id":null,"html_url":"https://github.com/fuglede/slackbot","commit_stats":null,"previous_names":[],"tags_count":0,"template":null,"template_full_name":null,"purl":"pkg:github/fuglede/slackbot","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fuglede%2Fslackbot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fuglede%2Fslackbot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fuglede%2Fslackbot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fuglede%2Fslackbot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fuglede","download_url":"https://codeload.github.com/fuglede/slackbot/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fuglede%2Fslackbot/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":284711515,"owners_count":27050939,"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","status":"online","status_checked_at":"2025-11-16T02:00:05.974Z","response_time":65,"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":["hacktoberfest","slackbot","websocket"],"created_at":"2024-11-09T23:17:25.556Z","updated_at":"2025-11-16T13:01:40.510Z","avatar_url":"https://github.com/fuglede.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"slackbot\r\n========\r\n\r\nThis library provides a very partial Go implementation of the [Slack RTM API](https://api.slack.com/rtm) with an eye towards creating chatbots for Slack.\r\n\r\nAbout 1000 similar libraries exist, and if you came here searching for a implementation of the full API, you may as well head somewhere else; [this repository](https://github.com/nlopes/slack) looks promising!\r\n\r\nInstead, in this rudimentary approach, all we do is connect to the WebSocket server and allow the user of a bot to set up simple read-and-respond scripts through callbacks, which happened to be what I needed when doing this; the repository is kept here mainly for my personal bookkeeping, and to allow others who happen to come across it to get started.\r\n\r\n\r\nInstallation\r\n------------\r\n\r\nFirst of all, to get started you'll need an API token for your bot user; you can get that at https://your-team-name.slack.com/apps/manage/custom-integrations.\r\n\r\nWith that out of the way, an example script says more than a thousand words:\r\n\r\n```go\r\npackage main\r\n\r\nimport (\r\n    \"errors\"\r\n    \"fmt\"\r\n    \"log\"\r\n    \"os\"\r\n\r\n    \"github.com/fuglede/slackbot\"\r\n)\r\n\r\nfunc main() {\r\n    token := \"xoxb-your-api-token-goes-here\"\r\n\r\n    // Create a new bot and let it log to stdout\r\n    bot := slackbot.New(log.New(os.Stdout, \"\", 3))\r\n\r\n    // Set up the bot to respond to the message \"Hi\". The callback\r\n    // returns an error which we will catch later.\r\n    bot.OnMessage = func(message slackbot.MessageIn) error {\r\n        if message.Text == \"Hi\" {\r\n            bot.SendMessage(message.Channel, \"Hi!\")\r\n        }\r\n        return errors.New(\"Error only for illustration\")\r\n    }\r\n\r\n    // Connect and start listening for messages\r\n    bot.Start(token)\r\n\r\n    for {\r\n        select {\r\n        // Exit the application when the bot signals disconnection\r\n        case \u003c-bot.Done:\r\n            return\r\n        // Use the CallbackErrors channel to catch the \"error\" from above\r\n        case err := \u003c-bot.CallbackErrors:\r\n            fmt.Println(err)\r\n        }\r\n    }\r\n}\r\n```\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffuglede%2Fslackbot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffuglede%2Fslackbot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffuglede%2Fslackbot/lists"}