/tg

Primary LanguageRustApache License 2.0Apache-2.0

tg

Minimum Supported Rust Version crates.io docs.rs build status Lines Of Code

Installation

README is out of date and I can't be bothered

To install the tg crate, ensure you have the nightly version of Rust (1.82+). You can install the crate via cargo with the following command:

cargo install tg

Usage

The tg tool allows you to interact with a Telegram bot to send messages, get bot information, and list channels configured in your configuration file.

Configuration

Create a configuration file at ~/.config/tg.toml (or specify a different path with the --config option) with the following structure:

[channels]
channel1 = "1234305221"
channel2 = "-1001234305221"
group_and_topic = "1234305221/7"

Each entry under [channels] represents a Telegram channel or group. Channels are specified by their ID, and groups are specified by their ID followed by a thread ID separated by a /.

Environment Variable

Ensure you have set the TELEGRAM_BOT_KEY environment variable with your Telegram bot API key:

export TELEGRAM_BOT_KEY="your_bot_api_key"

Commands

Send a Message

Send a message to a specified channel:

tg send -c channel2 "Today I'm feeling blue" "//this is still a part of the message"

Get Bot Information

Retrieve information about the bot:

tg bot-info

List Channels

List all the channels defined in the configuration file:

tg list-channels

Gen Aliases

An example of aliases to use with it. I myself gen them through this, then remove ones I don't intend to use often.

tg gen-aliases

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.


This repository follows my best practices.