{"id":25689154,"url":"https://github.com/nskondratev/tg-bot-template","last_synced_at":"2025-08-15T15:08:38.853Z","repository":{"id":102126848,"uuid":"325557509","full_name":"nskondratev/tg-bot-template","owner":"nskondratev","description":"Template repo with boilerplate code to write Telegram bots in Go","archived":false,"fork":false,"pushed_at":"2021-01-10T08:39:55.000Z","size":3180,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2023-03-03T15:23:28.116Z","etag":null,"topics":["go","golang","google-cloud","google-cloud-functions","telegram-bot","template-project"],"latest_commit_sha":null,"homepage":"","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/nskondratev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2020-12-30T13:27:02.000Z","updated_at":"2024-06-19T12:22:36.233Z","dependencies_parsed_at":null,"dependency_job_id":"63e3cc9d-9607-4b98-b63d-7b8840676279","html_url":"https://github.com/nskondratev/tg-bot-template","commit_stats":null,"previous_names":[],"tags_count":0,"template":null,"template_full_name":null,"purl":"pkg:github/nskondratev/tg-bot-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nskondratev%2Ftg-bot-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nskondratev%2Ftg-bot-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nskondratev%2Ftg-bot-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nskondratev%2Ftg-bot-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nskondratev","download_url":"https://codeload.github.com/nskondratev/tg-bot-template/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nskondratev%2Ftg-bot-template/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267441187,"owners_count":24087771,"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-07-27T02:00:11.917Z","response_time":82,"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":["go","golang","google-cloud","google-cloud-functions","telegram-bot","template-project"],"created_at":"2025-02-24T22:00:23.966Z","updated_at":"2025-07-27T23:33:16.529Z","avatar_url":"https://github.com/nskondratev.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# tg-bot-template\n\nTemplate repo with boilerplate code to write [Telegram bots in](https://core.telegram.org/bots/api) Go.\n\n## What is this repo for?\n\nI implemented several bots for Telegram and each time I started by writing/copying boilerplate code. This repository is\na template for a quick start of a new bot. It solves the following problems:\n\n- App structure: follows the [Standard Go Project Layout](https://github.com/golang-standards/project-layout).\n- Handy middlewares for HTTP-like processing updates from Telegram.\n- Deploying bot as a [Google Cloud Function](https://cloud.google.com/functions) and convenient local debugging with\n  polling updates.\n- Structured logging with [zerolog](https://github.com/rs/zerolog) lib.\n- Sending custom metrics with [OpenCensus](https://opencensus.io/) to Google Cloud. See more\n  in [docs](https://cloud.google.com/monitoring/custom-metrics/open-census?hl=en).\n\nIn short, this template will save you a couple of hours and allow you to immediately start implementing the bot's logic.\n\n## Quickstart\n\n1. Press \"Use this template\" button at the top or just\n   follow [the link](https://github.com/nskondratev/tg-bot-template/generate).\n2. Clone the generated repository to your machine.\n3. Rename module and change import paths by calling the command (replace `github.com/author/newbot` with yours repo\n   name):\n\n```bash\n./scripts/rename.sh github.com/author/newbot\n```\n\n4. Fill configuration in .env file:\n\n```bash\nmv .env.example .env \u0026\u0026 nano .env\n```\n\n5. Run your bot locally:\n\n```bash\nmake run\n```\n\nTo set up a webhook for receiving updates, fill the config in `.env` file and run the following command:\n\n```bash\n./scripts/set_webhook.sh\n```\n\nTo clear a webhook run the same script with `-c` flag provided:\n\n```bash\n./scripts/set_webhook.sh -c\n```\n\n## Next steps\n\n* Add domain-specific logic in [internal/app](./internal/app) package.\n* Add update handlers in [internal/app/bot/handlers](./internal/app/bot/handlers) package.\n* The library [telegram-bot-api](https://github.com/go-telegram-bot-api/telegram-bot-api) is used to work with Telegram\n  Bot API.\n\n## Project structure\n\n* `bin` - dir for compiled binary deps (look at the `tools` directory).\n* `cmd/bot` - entry-point for running bot locally.\n* `internal`:\n    * `internal/app` - contains business-logic layer and adapters to external world in sub-packages.\n    * `internal/bot` - wrappers to work with Telegram Bot API and middlewares implementation.\n    * `internal/bot/handlers` - handlers for different update types.\n    * `internal/bot/middleware` - middlewares for all updates.\n    * `internal/boot` - bootstrapping code for bot creation (used in local entry-point and Google Cloud Function).\n    * `internal/env` - utilities for getting env-vars values.\n    * `internal/logger` - logger creation code and custom log fields constants.\n    * `internal/metrics` - metrics client creation code and registering of custom metrics.\n* `scripts` - handy scripts for renaming module, changing import paths and setting up webhook URL.\n* `tools` - binary deps of a project.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnskondratev%2Ftg-bot-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnskondratev%2Ftg-bot-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnskondratev%2Ftg-bot-template/lists"}