explaingit

vysheng/tg

7,019CAudience · developerComplexity · 3/5LicenseSetup · hard

TLDR

A command-line Telegram client written in C that lets you send and receive messages, manage group chats, and use end-to-end encrypted secret chats entirely from a terminal, no phone app or browser needed.

Mindmap

mindmap
  root((tg))
    What it does
      Send messages
      Receive messages
      Secret chats
    Features
      Tab completion
      Command history
      Group management
    Protocol
      MTProto
      SSL via OpenSSL
    Build
      Compile from source
      configure and make
    Audience
      Linux users
      Server operators
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Send and receive Telegram messages from a terminal or SSH session on a headless Linux server.

USE CASE 2

Automate Telegram messaging from a server script using the command-line interface without a graphical app.

USE CASE 3

Use Telegram secret chats with end-to-end encryption from a Linux server environment.

Tech stack

COpenSSLreadlineLuaPython

Getting it running

Difficulty · hard Time to first run · 1h+

Must compile from source with readline and OpenSSL, no binary releases provided. Project has not had active development in several years.

GPLv2, free to use and modify, but any distributed version must also be released as open source under the same license.

In plain English

This project is a command-line client for Telegram, the messaging app. Instead of opening a phone app or a browser window, you run a program in your terminal and interact with your Telegram account by typing commands. It uses the readline interface, which means it supports tab completion (to fill in contact names) and command history (to scroll back through previous commands). The client lets you send and receive messages, forward messages, create and manage group chats, send photos and videos, search through message history, and use Telegram's secret chat feature (which provides end-to-end encryption with a visual key comparison for verification). It connects to Telegram's servers using the MTProto protocol, which is Telegram's own encrypted transport layer. To get it running, you clone the repository and compile it from source. The build process uses a standard configure-and-make approach and requires a few system libraries: readline for the terminal interface, OpenSSL for encryption, and optionally libconfig, Lua, Python, and libjansson for additional features. Installation instructions are provided for Ubuntu, Debian, Fedora, Arch Linux, Gentoo, FreeBSD, OpenBSD, openSUSE, and macOS via Homebrew or MacPorts. Once running, you pass a public server key file and then type commands at the prompt. Commands follow a consistent pattern: the command name, then the target peer (a contact or chat), then any additional arguments. For example, sending a message is msg ContactName Hello there. File transfers, group management, and secret chats all follow the same structure. This client predates Telegram's official desktop and terminal clients and appears to be an early independent implementation. The repository has not had active development in several years. The code is written in C and released under the GPLv2 license.

Copy-paste prompts

Prompt 1
Help me compile the tg Telegram CLI client from source on Ubuntu, install the required libraries, and connect it to my Telegram account.
Prompt 2
Show me the tg command syntax for sending a message, forwarding content, and searching through message history.
Prompt 3
I want to send automated Telegram notifications from a shell script using tg, show me how to call commands non-interactively.
Prompt 4
How do I start a secret chat with end-to-end encryption using the tg command-line Telegram client?
Open on GitHub → Explain another repo

← vysheng on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.