| Crates.io | telegram-cli |
| lib.rs | telegram-cli |
| version | 0.1.1 |
| created_at | 2025-08-22 06:16:56.523068+00 |
| updated_at | 2025-08-22 06:16:56.523068+00 |
| description | A simple and powerful CLI tool to interact with the Telegram Bot API. |
| homepage | |
| repository | https://github.com/1ffycat/telegram-cli |
| max_upload_size | |
| id | 1805961 |
| size | 91,697 |
A simple, fast, and powerful command-line tool written in Rust to interact with the Telegram Bot API. This tool allows you to send messages, files, photos, videos, and audio directly from your terminal.
~/.config/telegram-cli/.home-manager module for declarative configuration.For users of the Nix package manager, you can install telegram-cli declaratively.
Via Flakes:
Add the flake to your flake.nix inputs:
{
description = "My NixOS configuration";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
telegram-cli = {
url = "github:1ffycat/telegram-cli";
inputs.nixpkgs.follows = "nixpkgs";
};
};
# ...
}
Add it to your environment.systemPackages in your configuration.nix:
environment.systemPackages = [
inputs.telegram-cli.packages.${system}.telegram-cli
];
home-manager Module:
The flake also exposes a home-manager module for more granular, user-level configuration.
Import the module in your home.nix:
{ inputs, ... }: {
imports = [
inputs.telegram-cli.homeManagerModules.default
];
}
Configure the program:
programs.telegram-cli = {
enable = true;
botToken = "<your-telegram-bot-token>"; # Optional: Default bot token
defaultChatId = "<your-telegram-chat-id>"; # Optional: Default chat ID
prefix = "NixOS Alert:\n"; # Optional: Prefix for text messages
postfix = "\n-- Sent from my NixOS machine"; # Optional: Postfix for text messages
defaultFormat = "MarkdownV2"; # Optional: "Html", "MarkdownV2", or "No". Defaults to "MarkdownV2".
};
telegram-cli [OPTIONS] [MESSAGE]
[MESSAGE] The message to send. This can also be piped from stdin when using the -s flag.| Flag | Long Flag | Description |
|---|---|---|
--chat-id <CHAT_ID> |
Override the default chat ID from the config file. | |
--bot-token <BOT_TOKEN> |
Override the default bot token from the config file. | |
--format <FORMAT> |
Select message format. Possible values: html, md, no. |
|
-c |
--code <CODE> |
Wrap the message in a code block for a given language (e.g., rust). |
-f |
--file <FILE> |
Send file(s) as documents. Can be used multiple times. Supports glob patterns. |
-p |
--photo <PHOTO> |
Send image(s) as photos. Can be used multiple times. Supports glob patterns. |
-v |
--video <VIDEO> |
Send video(s). Can be used multiple times. Supports glob patterns. |
-a |
--audio <AUDIO> |
Send audio file(s). Can be used multiple times. Supports glob patterns. |
-s |
--stdin |
Take the message text from stdin. |
-h |
--help |
Print help information. |
-V |
--version |
Print version information. |
Sending a simple text message:
telegram-cli "Hello, world!"
Sending a message with Markdown formatting:
telegram-cli --format md "This is a *bold* and _italic_ message."
Piping a message from another command:
echo "This message comes from stdin" | telegram-cli -s
Sending a file:
telegram-cli -f ./my-document.pdf "Here is the document you requested."
Sending multiple photos using a glob pattern:
telegram-cli -p "images/*.jpg" "A collection of beautiful photos."
Sending a code snippet:
telegram-cli -c rust 'fn main() { println!("Hello from Rust!"); }'
Using a different bot token and chat ID:
telegram-cli --bot-token "YOUR_OTHER_BOT_TOKEN" --chat-id "ANOTHER_CHAT_ID" "Message to a different chat."
This project is licensed under the Mozilla Public License 2.0 (MPL-2.0).
This license is a "weak copyleft" license. It requires that any modifications to MPL-licensed source code files must also be licensed under the MPL-2.0. However, it allows you to combine the MPL-licensed code with code under other licenses (including proprietary ones) in a larger work.
A full copy of the license is available in the ./LICENSE file in this repository.
Contributions are welcome! Please feel free to open an issue or submit a pull request.