{"id":13409361,"url":"https://github.com/sbstjn/hanu","last_synced_at":"2025-05-08T16:59:31.633Z","repository":{"id":49514459,"uuid":"68359729","full_name":"sbstjn/hanu","owner":"sbstjn","description":"Golang Framework for writing Slack bots","archived":false,"fork":false,"pushed_at":"2023-04-21T05:57:29.000Z","size":76,"stargazers_count":159,"open_issues_count":3,"forks_count":25,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-05-08T16:59:10.130Z","etag":null,"topics":["chat","chatops","communication","framework","go","golang","slack","slackbot"],"latest_commit_sha":null,"homepage":"https://sbstjn.com/host-golang-slackbot-on-heroku-with-hanu.html","language":"Go","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/sbstjn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2016-09-16T07:10:42.000Z","updated_at":"2025-05-04T14:48:41.000Z","dependencies_parsed_at":"2024-01-08T14:46:55.493Z","dependency_job_id":null,"html_url":"https://github.com/sbstjn/hanu","commit_stats":{"total_commits":38,"total_committers":2,"mean_commits":19.0,"dds":0.02631578947368418,"last_synced_commit":"0ed9132ce4437563a9eb3ea0454ae94a7a5ac39c"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sbstjn%2Fhanu","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sbstjn%2Fhanu/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sbstjn%2Fhanu/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sbstjn%2Fhanu/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sbstjn","download_url":"https://codeload.github.com/sbstjn/hanu/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253112071,"owners_count":21856070,"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":["chat","chatops","communication","framework","go","golang","slack","slackbot"],"created_at":"2024-07-30T20:01:00.172Z","updated_at":"2025-05-08T16:59:31.609Z","avatar_url":"https://github.com/sbstjn.png","language":"Go","funding_links":[],"categories":["Bot Building","Bot建设","Go","Miscellaneous","机器人相关` 构建和使用机器人的库`","杂项","其他","雜項","机器人相关","\u003cspan id=\"其他-miscellaneous\"\u003e其他 Miscellaneous\u003c/span\u003e","Uncategorized"],"sub_categories":["Contents","Advanced Console UIs","高级控制台界面","交流","Free e-books","高級控制台界面","\u003cspan id=\"高级控制台用户界面-advanced-console-uis\"\u003e高级控制台用户界面 Advanced Console UIs\u003c/span\u003e"],"readme":"# hanu - Go for Slack Bots!\n\n[![Current Release](https://badgen.now.sh/github/release/sbstjn/hanu)](https://github.com/sbstjn/hanu/releases)\n[![MIT License](https://badgen.now.sh/badge/License/MIT/blue)](https://github.com/sbstjn/hanu/blob/master/LICENSE.md)\n[![Read Tutorial](https://badgen.now.sh/badge/Read/Tutorial/orange)](https://sbstjn.com/host-golang-slackbot-on-heroku-with-hanu.html)\n[![Code Example](https://badgen.now.sh/badge/Code/Example/cyan)](https://github.com/sbstjn/hanu-example)\n\nThe `Go` framework **hanu** is your best friend to create [Slack](https://slackhq.com) bots! **hanu** uses [allot](https://github.com/sbstjn/allot) for easy command and request parsing (e.g. `whisper \u003cword\u003e`) and runs fine as a [Heroku worker](https://devcenter.heroku.com/articles/background-jobs-queueing). All you need is a [Slack API token](https://api.slack.com/bot-users) and you can create your first bot within seconds! Just have a look at the [hanu-example](https://github.com/sbstjn/hanu-example) bot or [read my tutorial](https://sbstjn.com/host-golang-slackbot-on-heroku-with-hanu.html) …\n\n### Features\n\n- Respond to **mentions**\n- Respond to **direct messages**\n- Auto-Generated command list for `help`\n- Works fine as a **worker** on Heroku\n\n## Usage\n\nUse the following example code or the [hanu-example](https://github.com/sbstjn/hanu-example) bot to get started.\n\n```go\npackage main\n\nimport (\n\t\"log\"\n\t\"strings\"\n\n\t\"github.com/sbstjn/hanu\"\n)\n\nfunc main() {\n\tslack, err := hanu.New(\"SLACK_BOT_API_TOKEN\")\n\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tVersion := \"0.0.1\"\n\n\tslack.Command(\"shout \u003cword\u003e\", func(conv hanu.ConversationInterface) {\n\t\tstr, _ := conv.String(\"word\")\n\t\tconv.Reply(strings.ToUpper(str))\n\t})\n\n\tslack.Command(\"whisper \u003cword\u003e\", func(conv hanu.ConversationInterface) {\n\t\tstr, _ := conv.String(\"word\")\n\t\tconv.Reply(strings.ToLower(str))\n\t})\n\n\tslack.Command(\"version\", func(conv hanu.ConversationInterface) {\n\t\tconv.Reply(\"Thanks for asking! I'm running `%s`\", Version)\n\t})\n\n\tslack.Listen()\n}\n```\n\nThe example code above connects to Slack using `SLACK_BOT_API_TOKEN` as the bot's token and can respond to direct messages and mentions for the commands `shout \u003cword\u003e` , `whisper \u003cword\u003e` and `version`.\n\nYou don't have to care about `help` requests, **hanu** has it built in and will respond with a list of all defined commands on direct messages like this:\n\n```\n/msg @hanu help\n```\n\nOf course this works fine with mentioning you bot's username as well:\n\n```\n@hanu help\n```\n\n### Slack\n\nUse direct messages for communication:\n\n```\n/msg @hanu version\n```\n\nOr use the bot in a public channel:\n\n```\n@hanu version\n```\n\n## Dependencies\n\n- [github.com/sbstjn/allot](https://github.com/sbstjn/allot) for parsing `cmd \u003cparam1:string\u003e \u003cparam2:integer\u003e` strings\n- [golang.org/x/net/websocket](http://golang.org/x/net/websocket) for websocket communication with Slack\n\n## Credits\n\n- [Host Go Slackbot on Heroku](https://sbstjn.com/host-golang-slackbot-on-heroku-with-hanu.html)\n- [OpsDash article about Slack Bot](https://www.opsdash.com/blog/slack-bot-in-golang.html)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsbstjn%2Fhanu","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsbstjn%2Fhanu","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsbstjn%2Fhanu/lists"}