# vysheng/tg

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/vysheng-tg).**

7,084 stars · 1,743 forks · C · GPL-2.0

## Links

- GitHub: https://github.com/vysheng/tg
- awesome-repositories: https://awesome-repositories.com/repository/vysheng-tg.md

## Description

This project is a Telegram command line interface and MTProto client. It functions as a userbot framework, providing a terminal-based environment to interact with Telegram accounts without a graphical user interface.

The system differentiates itself through extensibility, offering Python bindings and a Lua scripting engine to automate account tasks and respond to messages. It also serves as a JSON-based chat exporter, capable of extracting user metadata and conversation histories into structured files.

The client covers core messaging capabilities, including text exchange, group chat management, and the establishment of encrypted secret chats. It supports multimedia exchange, message pattern searching, and the management of multiple account configurations through isolated session persistence.

The implementation provides a terminal command interface featuring tab-completion and command history.

## Tags

### Development Tools & Productivity

- [Command Line Interfaces](https://awesome-repositories.com/f/development-tools-productivity/command-line-interfaces.md) — Provides a complete terminal-based interface for interacting with Telegram accounts without a graphical user interface.
- [Automation Scripts](https://awesome-repositories.com/f/development-tools-productivity/automation-scripts.md) — Runs custom scripts to automate responses and forward content based on text patterns. ([source](https://github.com/vysheng/tg/blob/master/test.lua))

### User Interface & Experience

- [Terminal Command Interfaces](https://awesome-repositories.com/f/user-interface-experience/terminal-command-interfaces.md) — Implements a terminal-based interactive shell with tab-completion and command history for client control.

### Networking & Communication

- [MTProto Implementations](https://awesome-repositories.com/f/networking-communication/custom-protocol-implementations/mtproto-implementations.md) — Implements the MTProto protocol to enable low-level communication with Telegram servers.
- [Messaging Event Callbacks](https://awesome-repositories.com/f/networking-communication/discord-integrations/messaging-event-callbacks.md) — Triggers custom callbacks when messages are received or chat states are updated. ([source](https://github.com/vysheng/tg/blob/master/tg-test.py))
- [Telegram Clients](https://awesome-repositories.com/f/networking-communication/messaging-api-integrations/telegram-clients.md) — Functions as a headless MTProto client for running background sessions and programmed tasks.
- [Telegram Bot Frameworks](https://awesome-repositories.com/f/networking-communication/telegram-bot-frameworks.md) — Provides a framework for building interactive agents and automating responses on the Telegram platform.
- [Userbot Frameworks](https://awesome-repositories.com/f/networking-communication/telegram-bot-frameworks/userbot-frameworks.md) — Functions as a framework for automating personal user accounts through custom scripts and Python bindings.
- [Text and Binary Message Exchanges](https://awesome-repositories.com/f/networking-communication/text-and-binary-message-exchanges.md) — Supports the bidirectional exchange of text messages and the forwarding of content to peers. ([source](https://github.com/vysheng/tg#readme))
- [Contact Management](https://awesome-repositories.com/f/networking-communication/contact-management.md) — Enables adding users by phone number and managing contact lists through imports and exports. ([source](https://github.com/vysheng/tg#readme))
- [Group Chat Administration](https://awesome-repositories.com/f/networking-communication/group-chat-administration.md) — Provides tools for creating group chats, managing participants, and updating group settings. ([source](https://github.com/vysheng/tg#readme))
- [Multimedia Transmission](https://awesome-repositories.com/f/networking-communication/multimedia-transmission.md) — Transmits and retrieves photos, videos, audio, and documents with local download support. ([source](https://github.com/vysheng/tg/blob/master/README.md))

### Operating Systems & Systems Programming

- [Terminal Interfaces](https://awesome-repositories.com/f/operating-systems-systems-programming/terminal-command-line-environments/terminal-interface-systems/terminal-interfaces.md) — Provides a full terminal interface for interacting with Telegram accounts without a GUI. ([source](https://github.com/vysheng/tg/blob/master/README.es))

### Programming Languages & Runtimes

- [Embedded Lua Scripting](https://awesome-repositories.com/f/programming-languages-runtimes/embedded-lua-scripting.md) — Executes custom Lua scripts to automate messaging and react to real-time events. ([source](https://github.com/vysheng/tg/blob/master/README-LUA))
- [Language Bindings](https://awesome-repositories.com/f/programming-languages-runtimes/language-bindings.md) — Exposes core messaging and chat functions as Python bindings for custom scripting. ([source](https://github.com/vysheng/tg/blob/master/python-tg.h))
- [Python-C++ Bindings](https://awesome-repositories.com/f/programming-languages-runtimes/python-c-bindings.md) — Exposes core C++ messaging logic to Python via bindings for automation and scripting.

### Software Engineering & Architecture

- [Event-Driven Callbacks](https://awesome-repositories.com/f/software-engineering-architecture/event-driven-callbacks.md) — Triggers custom functions in response to server-pushed updates for messages and user states.
- [File-Based Persistence](https://awesome-repositories.com/f/software-engineering-architecture/workflow-persistence/state-persistence/file-based-persistence.md) — Saves authentication tokens and session state to local files to maintain logins across restarts.

### Artificial Intelligence & ML

- [Chat History Exporters](https://awesome-repositories.com/f/artificial-intelligence-ml/chat-history-apis/chat-history-exporters.md) — Extracts conversation logs and user metadata into structured JSON files.

### Business & Productivity Software

- [Metadata Exports](https://awesome-repositories.com/f/business-productivity-software/json-data-exports/metadata-exports.md) — Converts user and channel metadata into JSON files for sharing identity and membership statistics. ([source](https://github.com/vysheng/tg/blob/master/json-tg.c))

### Data & Databases

- [Chat Data Extraction](https://awesome-repositories.com/f/data-databases/chat-data-extraction.md) — Exports user metadata, chat histories, and membership statistics into JSON files.
- [JSON Message Serializers](https://awesome-repositories.com/f/data-databases/data-serialization-formats/json-serialization/json-message-serializers.md) — Maps internal messaging objects and peer metadata to structured JSON representations for export.
- [Message Search](https://awesome-repositories.com/f/data-databases/message-search.md) — Locates specific text patterns within individual conversations or across all messages globally. ([source](https://github.com/vysheng/tg#readme))
- [Account Profile Retrievers](https://awesome-repositories.com/f/data-databases/profile-information-retrieval/account-profile-retrievers.md) — Retrieves and displays detailed user profiles, contact lists, and comprehensive conversation histories. ([source](https://github.com/vysheng/tg#readme))

### Security & Cryptography

- [Multi-Account Profiles](https://awesome-repositories.com/f/security-cryptography/file-based-configuration/local-configuration-files/email-account-configurations/multi-account-profiles.md) — Supports isolated configuration directories for different user accounts to enable identity switching. ([source](https://github.com/vysheng/tg/blob/master/config.sample))
- [Secret Chat Managers](https://awesome-repositories.com/f/security-cryptography/message-encryption/secret-chat-message-senders/secret-chat-managers.md) — Establishes and maintains encrypted secret chats through a command-line interface.
- [Persistent Session Managers](https://awesome-repositories.com/f/security-cryptography/user-account-management/persistent-session-managers.md) — Saves authentication tokens and application state to local files to maintain logins between sessions. ([source](https://github.com/vysheng/tg/blob/master/loop.h))

### System Administration & Monitoring

- [Chat Message Retrieval](https://awesome-repositories.com/f/system-administration-monitoring/chat-message-retrieval.md) — Fetches sequences of previous messages from a chat to reconstruct past conversations. ([source](https://github.com/vysheng/tg/blob/master/tg-test.py))
