{"id":20610754,"url":"https://github.com/anjasfedo/go-slack-age-bot","last_synced_at":"2026-05-15T13:34:23.865Z","repository":{"id":217300184,"uuid":"743509209","full_name":"Anjasfedo/go-slack-age-bot","owner":"Anjasfedo","description":"Golang program utilizing the slacker library to create a Slack bot that calculates user age.","archived":false,"fork":false,"pushed_at":"2024-01-15T12:44:49.000Z","size":6,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-02T13:05:45.689Z","etag":null,"topics":["golang","learning-by-doing","slack","slack-bot","slacker"],"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/Anjasfedo.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":"2024-01-15T11:46:22.000Z","updated_at":"2024-01-15T12:44:33.000Z","dependencies_parsed_at":null,"dependency_job_id":"1793dc80-bbd8-4704-ad3a-1ea6c61efa9f","html_url":"https://github.com/Anjasfedo/go-slack-age-bot","commit_stats":null,"previous_names":["anjasfedo/go-slack-age-bot"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Anjasfedo/go-slack-age-bot","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Anjasfedo%2Fgo-slack-age-bot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Anjasfedo%2Fgo-slack-age-bot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Anjasfedo%2Fgo-slack-age-bot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Anjasfedo%2Fgo-slack-age-bot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Anjasfedo","download_url":"https://codeload.github.com/Anjasfedo/go-slack-age-bot/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Anjasfedo%2Fgo-slack-age-bot/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273287680,"owners_count":25078575,"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-09-02T02:00:09.530Z","response_time":77,"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":["golang","learning-by-doing","slack","slack-bot","slacker"],"created_at":"2024-11-16T10:17:46.285Z","updated_at":"2026-05-15T13:34:18.815Z","avatar_url":"https://github.com/Anjasfedo.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Slack Age Calculator 🎂\n\nThis Go program calculates a user's age based on the year of birth (yob) provided in a Slack command. The program utilizes the slacker library for Slack bot development and reads environment variables from a .env file.\n\n## Usage 🚀\n\n1. Create a `.env` file in the project root with the following format:\n\n   ```env\n    SLACK_BOT_TOKEN=your_slack_bot_token\n    SLACK_APP_TOKEN=your_slack_app_token\n   ```\n\n2. run the program:\n\n   ```\n    go run main.go\n   ```\n\nThe bot will listen for commands in Slack and respond with the calculated age.\n\n## Code Explanation 📜\n\n### main Function 🚀\n\n#### Load Environment Variables:\n\n- Calls the `loadEnv` function to read environment variables from the `.env` file.\n\n#### Create Slack API Client:\n\n- Uses the Slack API token from the environment variables to create a new Slack API client.\n\n#### Define Slack Bot Command:\n\n- Defines a Slack bot command that calculates age based on the provided year of birth.\n\n#### Listen for Slack Events:\n\n- Sets up context for the bot and starts listening for Slack events.\n\n### loadEnv Function 🌐\n\n#### Open and Read .env File:\n\n- Opens the `.env` file and reads it line by line.\n\n#### Set Environment Variables:\n\n- Parses key-value pairs from each line and sets them as environment variables.\n\n### Handler Function 📊\n\n#### Extract Year of Birth (yob):\n\n- Extracts the \"year\" parameter from the command request.\n\n#### Calculate Age:\n\n- Converts the year parameter to an integer and calculates the age based on the current year.\n\n#### Prepare Response:\n\n- Prepares a response message with the calculated age.\n\n#### Reply to Slack Channel:\n\n- Replies to the Slack channel with the calculated age.\n\n## Closing Notes 📝\n\nFeel free to adjust the configuration, and if you encounter any issues or have suggestions for improvement, please open an issue or submit a pull request.\n\nHappy coding! 🚀👨‍💻\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanjasfedo%2Fgo-slack-age-bot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanjasfedo%2Fgo-slack-age-bot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanjasfedo%2Fgo-slack-age-bot/lists"}