{"id":16526121,"url":"https://github.com/markusressel/cli2telegram","last_synced_at":"2025-07-24T12:36:47.019Z","repository":{"id":36461346,"uuid":"225175649","full_name":"markusressel/cli2telegram","owner":"markusressel","description":"Small utility to send Telegram messages from the CLI.","archived":false,"fork":false,"pushed_at":"2025-01-16T15:51:54.000Z","size":229,"stargazers_count":16,"open_issues_count":2,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-10T08:28:36.974Z","etag":null,"topics":["cli","event","notification","notification-backend","notifications","notifier","telegram","telegram-bot","zed","zfs","zfsonlinux"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/markusressel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":["markusressel"]}},"created_at":"2019-12-01T14:32:55.000Z","updated_at":"2025-04-09T10:15:06.000Z","dependencies_parsed_at":"2022-07-29T21:18:47.209Z","dependency_job_id":"77d45587-664e-4e84-8525-03fe894d7e58","html_url":"https://github.com/markusressel/cli2telegram","commit_stats":{"total_commits":65,"total_committers":7,"mean_commits":9.285714285714286,"dds":"0.24615384615384617","last_synced_commit":"2a1fcd0d86a3568d06a2a8c566d2cf24303f2b18"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/markusressel/cli2telegram","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markusressel%2Fcli2telegram","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markusressel%2Fcli2telegram/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markusressel%2Fcli2telegram/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markusressel%2Fcli2telegram/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/markusressel","download_url":"https://codeload.github.com/markusressel/cli2telegram/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markusressel%2Fcli2telegram/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263061021,"owners_count":23407597,"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":["cli","event","notification","notification-backend","notifications","notifier","telegram","telegram-bot","zed","zfs","zfsonlinux"],"created_at":"2024-10-11T17:26:10.918Z","updated_at":"2025-07-02T01:36:16.802Z","avatar_url":"https://github.com/markusressel.png","language":"Python","funding_links":["https://github.com/sponsors/markusressel"],"categories":[],"sub_categories":[],"readme":"# cli2telegram\nSmall utility to send Telegram messages from the CLI.\n\nThis can f.ex. be used to\n* quickly send arbitrary messages to a Telegram chat of your choice\n* use it as a replacement for the \"mail\" program on linux\n* use Telegram as a notification backend for the ZFS Event Daemon (zed)\n\n## Features\n* [x] Read messages from argument or STDIN\n* [x] (Optional) Configuration file\n* [x] Retry sending messages for a specified amount of time\n* [x] Handling of long messages\n* [x] Run as a daemon and echo messages into a linux pipe\n\n## Examples\n\n```shell\ncli2telegram -h\n\n# From arguments\ncli2telegram \"This is a message\"\n\ncli2telegram \"Header\" \"This is a multiline message.\"\n\n# From STDIN\necho My Message | cli2telegram\n\nprintf \"Header\\nThis is a multiline message.\" | cli2telegram\n\n# Config via parameters\nprintf \"Message\" | cli2telegram -b \"123456789:ABCDEFG\" -c \"123456789\"\n\n# Config via parameters and send message in a code block\nprintf \"Message\" | cli2telegram -b \"123456789:ABCDEFG\" -c \"123456789\" -C\n\n# as a Daemon\ncli2telegram -d -p \"/tmp/cli2telegram\"\necho \"hello world!\" \u003e /tmp/cli2telegram\n``` \n\n# Install\n\nTo use this utility install it either using:\n```\npip install cli2telegram\n```\n\nor - if you don't want to install it globally - using f.ex. [venv-install](https://github.com/markusressel/venv-install):\n```\nvenv-install cli2telegram cli2telegram\n```\n\nor your custom `venv` manager of choice.\n\n# Configuration\n\nTo be able to send you messages you have to provide a **bot token** and a **chat id**.\nYou can configure cli2telegram using cli parameters, a configuration file,\nenvironment variables, or a combination of them.\n\n## Parameters\n\n| Name                 | Type   | Description                               |\n|----------------------|--------|-------------------------------------------|\n| `-b`, `--bot-token`  | String | Telegram Bot Token                        |\n| `-c`, `--chat-id`    | String | Telegram Chat ID                          |\n| `-C`, `--code-block` | String | Send message inside a code block          |\n| `-d`, `--daemon`     | Flag   | Run as a daemon                           |\n| `-p`, `--pipe`       | String | File path to the pipe used in daemon mode |\n\n## File\ncli2telegram uses [container-app-conf](https://github.com/markusressel/container-app-conf) so you can use YAML, TOML, or ENV to set those.\n\nHave a look at the [cli2telegram.toml_example](cli2telegram.toml_example) file to get an idea.\n\n# Daemon\n\nWhen running cli2telegram as a daemon, the pipe will close for a brief amount of time between receiving input messages.\nIf you are sending multiple messages to the pipe using f.ex. a script, make sure to wait a bit (f.ex. 0.5 seconds)\nbetween sending messages, otherwise:\n* multiple messages may be received as one\n* messages may get lost\n* you may receive a `Broken pipe` error\n\n# Use Cases\n\n## ZFS Event Daemon (ZED)\nTo make `zed` call cli2telegram we will trick it and make it use cli2telegram as an E-Mail client.\n\nEdit `/etc/zfs/zed.d/zed.rc` as root:\n```bash\nsudo nano -w /etc/zfs/zed.d/zed.rc\n```\n\nand\n* uncomment `ZED_EMAIL_ADDR`, the value does not matter since we use our own email script, but **it is necessary to set a value to make ZED send 'emails'**\n* set `ZED_EMAIL_PROG` to the path of the script, f.ex. `/usr/bin/cli2telegram`\n  * it is important to note that zed does not seem to work if your command needs arguments to run\n```\n# this must not be empty!\nZED_EMAIL_ADDR=\"root\"\n\n[...]\n\nZED_EMAIL_PROG=\"/usr/bin/cli2telegram\"\n\n[...]\n\n# this must not be empty!\nZED_EMAIL_OPTS=\"#zfs #$(hostname)\"\n\n[...]\n\n# If you want to receive email no matter the state of your pool, you’ll want to set:\nZED_NOTIFY_VERBOSE=1\n\n[...]\n```\n\nSince `zed` will run your scripts as root, if you want to use a config file \nyou have to put it in f.ex. `/root/.config/cli2telegram.toml`.\n\n# Contributing\n\nGitHub is for social coding: if you want to write code, I encourage contributions through pull requests from forks\nof this repository. Create GitHub tickets for bugs and new features and comment on the ones that you are interested in.\n\n# License\n\n```text\ncli2telegram by Markus Ressel\nCopyright (C) 2018  Markus Ressel\n\nThis program is free software: you can redistribute it and/or modify\nit under the terms of the GNU Affero General Public License as\npublished by the Free Software Foundation, either version 3 of the\nLicense, or (at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU Affero General Public License for more details.\n\nYou should have received a copy of the GNU Affero General Public License\nalong with this program.  If not, see \u003chttps://www.gnu.org/licenses/\u003e.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarkusressel%2Fcli2telegram","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarkusressel%2Fcli2telegram","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarkusressel%2Fcli2telegram/lists"}