{"id":19721313,"url":"https://github.com/meinside/telegram-d2-bot","last_synced_at":"2025-04-29T21:31:16.626Z","repository":{"id":65199192,"uuid":"570075257","full_name":"meinside/telegram-d2-bot","owner":"meinside","description":"A Telegram Bot which replies to messages with D2-generated .svg files in .png format.","archived":false,"fork":false,"pushed_at":"2025-04-17T00:05:32.000Z","size":303,"stargazers_count":12,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-17T13:15:00.540Z","etag":null,"topics":["d2","telegram-bot"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/meinside.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,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-11-24T09:29:42.000Z","updated_at":"2025-04-17T00:05:27.000Z","dependencies_parsed_at":"2023-12-19T04:01:11.599Z","dependency_job_id":"f97cceb8-3760-4fd8-99e3-c2b08468f99a","html_url":"https://github.com/meinside/telegram-d2-bot","commit_stats":{"total_commits":46,"total_committers":3,"mean_commits":"15.333333333333334","dds":0.4347826086956522,"last_synced_commit":"a94d4f3556d84f486fc68749d160a22b31bf2540"},"previous_names":[],"tags_count":61,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meinside%2Ftelegram-d2-bot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meinside%2Ftelegram-d2-bot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meinside%2Ftelegram-d2-bot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meinside%2Ftelegram-d2-bot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/meinside","download_url":"https://codeload.github.com/meinside/telegram-d2-bot/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251585795,"owners_count":21613279,"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":["d2","telegram-bot"],"created_at":"2024-11-11T23:13:58.515Z","updated_at":"2025-04-29T21:31:11.616Z","avatar_url":"https://github.com/meinside.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# telegram-d2-bot\n\nA telegram bot which answers with rendered `.svg` files in `.png` format.\n\nUsing [terrastruct/d2](https://github.com/terrastruct/d2) for generating .svg files from messages.\n\n\u003cimg width=\"631\" alt=\"Screenshot 2022-12-19 at 14 31 53\" src=\"https://user-images.githubusercontent.com/185988/208354666-fe073dbc-105a-44b3-88a0-dce64a454efc.png\"\u003e\n\n## Configuration\n\n```bash\n$ cp config.json.sample config.json\n```\n\nand edit:\n\n```json\n{\n  \"allowed_ids\": [\"telegram_username_1\", \"telegram_username_2\"],\n  \"monitor_interval\": 5,\n  \"theme_id\": 0,\n  \"sketch\": false,\n  \"is_verbose\": false,\n\n  \"bot_token\": \"xxxxxxxxyyyyyyyy-1234567\"\n}\n```\n\n* `bot_token` can be obtained from [bot father](https://t.me/botfather)\n* `allowed_ids` are ids of allowed telegram users who can get responses from this bot\n* `monitor_interval` is the polling interval (in seconds) from telegram API\n* `theme_id` can be retrieved from [these files](https://github.com/terrastruct/d2/tree/master/d2themes/d2themescatalog) (= 0 for default)\n* `sketch` is whether to render results in sketched style\n* `is_verbose` is whether to print verbose messages\n\n### Using Infisical\n\nYou can use [Infisical](https://infisical.com/) for retrieving your bot token and api key:\n\n```json\n{\n  \"allowed_ids\": [\"telegram_username_1\", \"telegram_username_2\"],\n  \"monitor_interval\": 5,\n  \"theme_id\": 0,\n  \"sketch\": false,\n  \"is_verbose\": false,\n\n  \"infisical\": {\n    \"client_id\": \"012345-abcdefg-987654321\",\n    \"client_secret\": \"aAbBcCdDeEfFgG0123456789xyzwXYZW\",\n\n    \"project_id\": \"012345abcdefg\",\n    \"environment\": \"dev\",\n    \"secret_type\": \"shared\",\n\n    \"bot_token_key_path\": \"/path/to/your/KEY_TO_BOT_TOKEN\",\n  }\n}\n```\n\n## Other Dependencies\n\n[Playwright](https://github.com/playwright-community/playwright-go) is needed for exporting .png files:\n\n```bash\n$ npx playwright install-deps\n```\n\n## Build and Run\n\n```bash\n$ go build\n$ ./telegram-d2-bot config.json\n```\n\n## Run as a service\n\n### systemd\n\nCreate a file named `/etc/systemd/system/telegram-d2-bot.service`:\n\n```\n[Unit]\nDescription=Telegram D2 Bot\nAfter=syslog.target\nAfter=network.target\n\n[Service]\nType=simple\nUser=ubuntu\nGroup=ubuntu\nWorkingDirectory=/dir/to/telegram-d2-bot\nExecStart=/dir/to/telegram-d2-bot/telegram-d2-bot [CONFIG_FILEPATH]\nRestart=always\nRestartSec=5\n\n[Install]\nWantedBy=multi-user.target\n```\n\nand make it run automatically on booting:\n\n```bash\n$ sudo systemctl enable telegram-d2-bot.service\n$ sudo systemctl start telegram-d2-bot.service\n```\n\n## Todos\n\n- [ ] Add more configurable options.\n- [x] Support uploading .d2 files.\n- [x] Respond with .png files. (Playwright is needed)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmeinside%2Ftelegram-d2-bot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmeinside%2Ftelegram-d2-bot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmeinside%2Ftelegram-d2-bot/lists"}