{"id":19124747,"url":"https://github.com/mitinarseny/telego","last_synced_at":"2025-05-05T19:28:25.549Z","repository":{"id":96163257,"uuid":"198645006","full_name":"mitinarseny/telego","owner":"mitinarseny","description":"Template for creating Telegram Bots with clean architecture.","archived":false,"fork":false,"pushed_at":"2019-09-28T22:48:36.000Z","size":624,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-19T11:48:50.677Z","etag":null,"topics":["docker","go","telegram"],"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/mitinarseny.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":"2019-07-24T13:50:53.000Z","updated_at":"2022-11-23T23:38:53.000Z","dependencies_parsed_at":null,"dependency_job_id":"9333dc34-4a23-4673-bbbe-91d67df8dc15","html_url":"https://github.com/mitinarseny/telego","commit_stats":null,"previous_names":[],"tags_count":0,"template":true,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitinarseny%2Ftelego","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitinarseny%2Ftelego/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitinarseny%2Ftelego/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitinarseny%2Ftelego/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mitinarseny","download_url":"https://codeload.github.com/mitinarseny/telego/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252562363,"owners_count":21768279,"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":["docker","go","telegram"],"created_at":"2024-11-09T05:30:22.242Z","updated_at":"2025-05-05T19:28:25.527Z","avatar_url":"https://github.com/mitinarseny.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://github.com/mitinarseny/telego\"\u003e\n    \u003cimg src=\".assets/logo.png\" alt=\"telego logo\" width=\"20%\" /\u003e\n  \u003c/a\u003e\n  \u003ch1 align=\"center\"\u003etelego\u003c/h1\u003e\n  \u003cp align=\"center\"\u003eDocker Go template for creating \u003ca href=\"https://core.telegram.org/bots\"\u003eTelegram Bots\u003c/a\u003e with clean architecture.\u003c/p\u003e\n  \u003cp align=\"center\"\u003e\n    \u003ca href=\"https://travis-ci.org/mitinarseny/telego\"\u003e\u003cimg alt=\"TravisCI\" src=\"https://img.shields.io/travis/mitinarseny/telego/master.svg?style=flat-square\u0026logo=travis-ci\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://app.codacy.com/app/mitinarseny/telego\"\u003e\u003cimg alt=\"Codacy\" src=\"https://img.shields.io/codacy/grade/0702d21a638d4fa78328d988bdcedb19/master?style=flat-square\u0026logo=codacy\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://golangci.com/r/github.com/mitinarseny/telego\"\u003e\u003cimg src=\"https://golangci.com/badges/github.com/mitinarseny/telego.svg\"\u003e\u003c/a\u003e\n    \u003ca href=\"/LICENSE.md\"\u003e\u003cimg alt=\"Software License\" src=\"https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://saythanks.io/to/mitinarseny\"\u003e\u003cimg alt=\"SayThanks.io\" src=\"https://img.shields.io/badge/say-thanks-9933ff.svg?style=flat-square\"\u003e\u003c/a\u003e\n  \u003c/p\u003e\n\u003c/p\u003e\n\n## Table of Contents\n* [Usage](#usage)\n  * [Create Bot](#create-bot)\n  * [Copy Token](#copy-token)\n      * [Notifier](#notifier)\n  * [Code](#code)\n    * [Logic](#logic)\n    * [Handlers](#handlers)\n  * [Run](#run)\n* [Debug](#debug)\n  * [Build \u0026 Run](#build--run)\n  * [Attach](#attach)\n## Usage\n### Create Bot\nCreate new bot with [@BotFather](https://t.me/BotFather).\n### Copy Token\nCreate file `./docker-compose.secret.yaml` with the following structure and paste the token from [@BotFather](https://t.me/BotFather):\n```yaml\n# ./docker-compose.secret.yaml\n\nversion: '3.7'\n\nservices:\n  bot:\n    environment:\n      TELEGO_BOT_TOKEN: \"12345689:ABCdEFgHi1JKLMNO23P45rSTU6vw78xyz-a\"\n```\n#### Notifier\nYou can enable Telegram notifications on your bot's status (`UP` or `DOWN`) by creating another bot and a group chat with this bot. Then edit `./docker-compose.secret.yaml`:\n```yaml\n# ...\nenvironment:\n  TELEGO_NOTIFIER_BOT_TOKEN: \"\u003ctoken\u003e\"\n  TELEGO_NOTIFIER_CHAT_ID: \"\u003cchat_id\u003e\"\n```\n### Code\n#### Logic\nMain logic of the bot should be implemented inside `Configure` function in [`bot/bot.go`](bot/bot.go):\n```go\nfunc Configure(b *tb.Bot) (*tb.Bot, error) {\n    h := handlers.Handler{Bot: b}\n    b.Handle(\"/hello\", withLogMsg(h.HandleHello))\n    return b, nil\n}\n\nfunc withLogMsg(handler func(*tb.Message) error) func(message *tb.Message) {\n    return func(m *tb.Message) {\n        if err := handler(m); err != nil {\n            log.WithFields(log.Fields{\n                \"context\": \"BOT\",\n                \"handler\": handler,\n            }).Error(err)\n        }\n    }\n}\n```\n#### Handlers\nAll hanlders should be placed in [`bot/handlers/`](bot/handlers). Here is an example from [`hello.go`](bot/handlers/hello.go):\n```go\nfunc (b *Handler) HandleHello(m *tb.Message) error {\n    _, err := b.Bot.Send(m.Sender, \"Hello, world!\")\n    return err\n}\n```\n### Run\n```bash\ndocker-compose \\\n  -f docker-compose.yaml \\\n  -f docker-compose.secret.yaml \\\n  up --build -d\n```\n\n## Debug\nYou can debug your code with [Delve](https://github.com/go-delve/delve) debugger. \n### Build \u0026 Run\nTo enable [dlv](https://github.com/go-delve/delve) debugger inside the container run:\n```bash\ndocker-compose \\\n  -f docker-compose.yaml \\ \n  -f docker-compose.dev.yaml \\\n  -f docker-compose.secret.yaml \\\n  up --build -d\n``` \n### Attach\n```bash\n${GOPATH}/bin/dlv connect localhost:40000\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmitinarseny%2Ftelego","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmitinarseny%2Ftelego","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmitinarseny%2Ftelego/lists"}