{"id":17948832,"url":"https://github.com/eko/slackbot","last_synced_at":"2025-09-05T19:43:56.435Z","repository":{"id":57509254,"uuid":"78569712","full_name":"eko/slackbot","owner":"eko","description":"This is a Slack Robot written in Go.","archived":false,"fork":false,"pushed_at":"2018-03-11T16:15:10.000Z","size":15,"stargazers_count":15,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-19T05:07:08.338Z","etag":null,"topics":["bot","go","golang","robot","slack"],"latest_commit_sha":null,"homepage":null,"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/eko.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}},"created_at":"2017-01-10T20:10:18.000Z","updated_at":"2019-12-09T04:45:02.000Z","dependencies_parsed_at":"2022-08-30T05:42:00.100Z","dependency_job_id":null,"html_url":"https://github.com/eko/slackbot","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eko%2Fslackbot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eko%2Fslackbot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eko%2Fslackbot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eko%2Fslackbot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eko","download_url":"https://codeload.github.com/eko/slackbot/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245366205,"owners_count":20603438,"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":["bot","go","golang","robot","slack"],"created_at":"2024-10-29T09:10:15.166Z","updated_at":"2025-03-24T22:35:35.380Z","avatar_url":"https://github.com/eko.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Slackbot\n\nThis is a Slack Robot written in Go.\n\n[![GoDoc](https://godoc.org/github.com/eko/slackbot?status.png)](https://godoc.org/github.com/eko/slackbot)\n[![Build Status](https://travis-ci.org/eko/slackbot.png?branch=master)](https://travis-ci.org/eko/slackbot)\n\n\n## Robot creation\n\n1. Go on the following uri to declare your new bot: https://{team}.slack.com/services/new/bot\n\n2. Retrieve the given token.\n\n## Installation\n\n```bash\n$ go get -u github.com/eko/slackbot\n```\n\n## Run the robot\n\n```bash\n$ go run app.go\nBot is ready, hit ^C to exit.\n-\u003e Command: hello dude\n```\n\n## A robot example application\n\nThis example application answers to the following command:\n\n* @yourbotname hello \u003cname\u003e: Renders \"hello \u003cname\u003e!\",\n\n```go\npackage main\n\nimport (\n    \"github.com/eko/slackbot\"\n    \"fmt\"\n)\n\nfunc main() {\n\tslackbot.Token = \"\u003cyour-bot-token\u003e\"\n\tslackbot.Init()\n\n    slackbot.AddCommand(\"^hello (.*)\", \"hello\", \"Responds hello {string}\", \n        func(command slackbot.Command, message slackbot.Message) {\n\t\tname := command.Pattern.FindStringSubmatch(message.Text)[1]\n\t\tmessage.Text = string(fmt.Sprintf(\"hello, %s!\", name))\n\t\t\n\t\tslackbot.Respond(message)\n\t})\n\t\n    slackbot.Stream()\n}\n```\n\n## A periodic (using robfig/cron) tasks for your bot\n\nFor this demo, we are using `github.com/robfig/cron` library to run a task every minute.\n\n```go\npackage main\n\nimport (\n\t\"github.com/eko/slackbot\"\n\t\"github.com/robfig/cron\"\n\n\t\"./task\"\n)\n\nconst (\n\tchannel = \"general\"\n)\n\nvar (\n\tchannelIdentifier string\n)\n\nfunc main() {\n\tslackbot.Token = \"your-amazing-token\"\n\n\tchannelsResponse, _ := slackbot.ListChannels()\n\n\tfor i := 0; i \u003c len(channelsResponse.Channels); i++ {\n\t\tif channel == channelsResponse.Channels[i].Name {\n\t\t\tchannelIdentifier = channelsResponse.Channels[i].ID\n\t\t}\n\t}\n\n\tc := cron.New()\n\tc.AddFunc(\"1 * * * * *\", func() {\n    message := slackbot.Message{\n  \t\tAsUser:  true,\n  \t\tChannel: channelIdentifier,\n  \t\tText:    \"Hello you!\",\n  \t}\n\n  \tslackbot.PostMessage(message)\n\t})\n\tc.Start()\n\n\tselect {}\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feko%2Fslackbot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feko%2Fslackbot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feko%2Fslackbot/lists"}