Русская версия документации: README.ru.md
Public binary distribution repository for the tgs.py project.
This repository contains release artifacts only:
tgs.exe: Windows one-file executabletgs: Linux one-file executabletgs_automation.exe: Windows automation helpertgs_automation: Linux automation helpertgs_gui.exe: Windows desktop GUI frontendtgs.zip: bundled release archive
Source code lives in the main repository:
tgs is a command-line utility for working with Telegram through a user account.
Main workflows:
- create and store Telegram API configuration
- authorize a Telegram account through Telethon
- export members from groups and channels
- export messages to
txt,json,csv, andsqlite - create richer SQLite dumps with users, metadata, and optional media
- send direct messages in bulk from a template
- post one formatted message to a target group or channel
- check the local license state or generate a license request
Main CLI:
tgs.exetgs
Automation helper:
tgs_automation.exetgs_automation
Desktop GUI:
tgs_gui.exe
The GUI binary is a frontend over the main CLI runtime.
Place tgs_gui.exe next to tgs.exe in the same folder so the GUI can invoke the compiled CLI binary directly.
The GUI supports English and Russian UI text and writes editable locale files into tgs_config/gui_locales/.
The repository tgs.zip bundle remains focused on the CLI pair and automation helper; the GUI is distributed as a separate standalone binary because adding tgs_gui.exe pushes the archive above GitHub's 100 MB hard limit.
tgs.exe -h
tgs.exe <command> -h
./tgs -h
./tgs <command> -hAvailable commands:
bootstrapsetupusersadddumppostssendpostlicense
Create your Telegram application credentials at:
Then run:
tgs.exe setupor:
./tgs setupYou can also pass values directly:
tgs.exe setup -p +15551234567 -i YOUR_API_ID -k YOUR_API_HASH -o tgs_config\config.datatgs.exe bootstrap --checkIf dependencies are missing in a Python environment, use:
python tgs.py bootstrapFor the standalone binaries, dependency management is already baked into the build environment used to produce the release artifacts.
tgs.exe users -h
tgs.exe posts -h
tgs.exe dump -h
tgs.exe send -h
tgs.exe post -h
tgs_automation.exe -hCurrent releases use two default working folders:
tgs_config/: configs, sessions, license files, and license requeststgs_data/: exported CSV, JSON, SQLite, archives, and media
GUI-specific runtime files:
tgs_config/gui_state.json: remembered GUI state such as the selected languagetgs_config/gui_locales/: editable GUI locale JSON files
The main config file usually lives at:
tgs_config/config.data
Most commands accept:
-c, --config: config file path
Default:
tgs_config/config.data
The binary checks for a local license and may apply reduced limits when no valid license is installed.
User-facing behavior:
licensechecks the currently available license- if validation fails, the tool can generate a local license request file
- some high-impact workflows may run with reduced limits until a valid license is installed
- automation
run-duerequires a valid license before it executes due jobs
For normal usage, you only need:
tgs.exe licenseInstalls or verifies required third-party packages in a Python environment.
Useful commands:
python tgs.py bootstrap
python tgs.py bootstrap --checkFor packaged binaries, this is mostly relevant when you also work with the source checkout.
Creates the local Telegram config file.
Arguments:
-o, --output: output config file, defaulttgs_config\config.data-p, --phone: phone number in international format-i, --api_id: Telegram API ID-k, --api_hash: Telegram API hash
Examples:
tgs.exe setup
tgs.exe setup -o tgs_config\config-anna.data
tgs.exe setup -p +15551234567 -i 123456 -k abcdef123456Exports members from a source group or channel into CSV.
Arguments:
-s, --source: source group/channel username or numeric ID-o, --output: output CSV file-c, --config: config file
Behavior:
- if
--sourceis omitted, an interactive selector is shown - default output is a timestamped CSV in
tgs_data/users/ - CSV columns include username, user ID, access hash, display name, group title, and group ID
Examples:
tgs.exe users -s my_group
tgs.exe users -s 123456789 -o tgs_data\users\members.csvAdds users to a target group either from CSV or from another source group.
Arguments:
-i, --input: CSV file with members-s, --source: source group/channel-t, --target: target group/channel-m, --mode:user_idorusername, defaultuser_id-d, --delay: delay before starting, in seconds orHH:MM:SS-c, --config: config file
Behavior:
- if source or target is omitted, the tool can prompt interactively
- existing members are skipped
- randomized waits are used between invite attempts
Examples:
tgs.exe add -i tgs_data\users\members.csv -t my_target_group
tgs.exe add -s source_group -t target_group
tgs.exe add -i tgs_data\users\members.csv -t target_group -m username -d 01:30:00Exports messages from a source group or channel.
Arguments:
-s, --source: source group/channel username or ID-o, --output: output path-t, --type:text,json,csv,sqlite, orall-l, --limit: maximum number of messages-p, --pinned: only pinned messages-m, --media: include media handling-a, --archive: archive the result--date-from: only include messages on or after a date/datetime--date-to: only include messages on or before a date/datetime--from-user: only include messages from a given sender--contains: only include messages containing text--with-media: only include messages with media--retries: retries per message on transient export errors--resume-from-id: continue from older history before this message ID-f, --formats: extra SQLite text representations such ashtml,md,json-c, --config: config file
Notes:
textcreates plain readable message blocksjsonstores structured message objectscsvstores spreadsheet-friendly rows with proper multiline escapingsqlitestores a richer queryable datasetallcreatestext,json, andsqlite- default output goes to
tgs_data/posts/unless you pass--output
Examples:
tgs.exe posts -s my_channel
tgs.exe posts -s my_channel -t csv
tgs.exe posts -s my_channel -t sqlite -f "html,md,json"
tgs.exe posts -s my_channel -t json --contains "launch"
tgs.exe posts -s my_channel -t csv --with-media --date-from 2026-01-01
tgs.exe posts -s my_channel -t json --resume-from-id 5000 --retries 5Creates a fuller SQLite dump than posts.
Arguments:
-s, --source: source group/channel username or ID-o, --output: output SQLite path-m, --media: include media downloads and media metadata-a, --archive: archive the resulting SQLite file--date-from: only include messages on or after a date/datetime--date-to: only include messages on or before a date/datetime--from-user: only include messages from a given sender--contains: only include messages containing text--with-media: only include messages with media--retries: retries per message on transient export errors--resume-from-id: continue from older history before this message ID-f, --formats: extra formatted message columns such ashtml,md,json-c, --config: config file
Typical stored data includes:
- chat/channel metadata
- participant information
- messages
- optional media records
- default output goes to
tgs_data/dump/unless you pass--output
Examples:
tgs.exe dump -s my_channel
tgs.exe dump -s my_channel -m -a -f "html,md,json"
tgs.exe dump -s my_channel --contains "announcement" --date-from 2026-01-01
tgs.exe dump -s my_channel --resume-from-id 5000 --retries 5Sends direct messages to users loaded from CSV and/or a source group.
Arguments:
-i, --input: CSV file with recipients-s, --source: source group to collect recipients from-t, --text: message file-f, --format:text,html, ormarkdown-j, --message-json: legacy structured message file--preview: render the first resolved message without sending--dry-run: validate recipients and rendering without sending--whitelist: CSV file with recipients to explicitly allow--blacklist: CSV file with recipients to exclude--limit-users: limit recipients after filters are applied--report-json: write a JSON results report--report-csv: write a CSV results report--verbose-log: write an extended structured JSON log-d, --delay: delay before starting the send task--delay-min: minimum delay between sends in seconds--delay-max: maximum delay between sends in seconds-m, --mode:user_idorusername, defaultuser_id-c, --config: config file
Template placeholders supported in message files:
%%username%%%%first_name%%%%last_name%%
Formatting behavior:
text: safely escaped and sent through the HTML pipelinehtml: validated and sent as HTMLmarkdown: converted to Telegram-compatible HTML before sending
Operational notes:
--previewand--dry-rundo not send anything--delaypostpones the whole send task--delay-min/--delay-maxcontrol per-recipient pacing- recipients are deduplicated by user ID
- buttons are not used in the user-account send workflow
Examples:
tgs.exe send -i tgs_data\users\members.csv -t message.txt -f text
tgs.exe send -i tgs_data\users\members.csv -t message.html -f html
tgs.exe send -i tgs_data\users\members.csv -t message.md -f markdown --preview
tgs.exe send -i tgs_data\users\members.csv -t message.md -f markdown --dry-run
tgs.exe send -s source_group -t message.html -f html
tgs.exe send -i tgs_data\users\members.csv -t message.html -f html --whitelist tgs_data\users\testers.csv --limit-users 10
tgs.exe send -i tgs_data\users\members.csv -t message.html -f html --blacklist tgs_data\users\do_not_contact.csv
tgs.exe send -i tgs_data\users\members.csv -t message.html -f html --report-csv tgs_data\reports\send_results.csv
tgs.exe send -i tgs_data\users\members.csv -t message.html -f html --verbose-log tgs_data\logs\send_verbose.json
tgs.exe send -i tgs_data\users\members.csv -t message.html -f html --delay 21:30 --delay-min 8 --delay-max 15Posts one formatted message into a target group or channel.
Arguments:
-g, --group: target group/channel ID, username, or title-t, --text: message file-f, --format:text,html, ormarkdown-j, --message-json: legacy structured message file--preview: render the final message without posting--dry-run: validate target resolution and rendering without posting-d, --delay: delay before starting the post task--delay-min: randomized minimum delay before posting--delay-max: randomized maximum delay before posting--verbose-log: write an extended structured JSON log-c, --config: config file
Behavior:
- if
--groupis omitted, the tool opens the selector - if a title matches multiple local chats, it shows a choice list
text,html, andmarkdownuse the same rendering pipeline assend
Examples:
tgs.exe post -t announcement.html -f html
tgs.exe post -g test_vscode -t announcement.md -f markdown
tgs.exe post -g "OpenAir Belgrade" -t announcement.txt -f text --preview
tgs.exe post -g my_channel -t announcement.html -f html --dry-run
tgs.exe post -g my_channel -t announcement.html -f html --delay 21:30
tgs.exe post -g my_channel -t announcement.html -f html --verbose-log tgs_data\logs\post_verbose.jsonChecks the current local license state or creates a local license request when needed.
Arguments:
-c, --config: config file
Usage:
tgs.exe licensetgs_automation is a companion binary for automation-oriented workflows.
Current scope:
- validate an automation plan JSON
- print a normalized plan view
- show which main runner will be used
- show the concrete
tgscommands implied by the plan - execute jobs that are due right now through
run-due - record automation state in SQLite for later inspection
Runner resolution behavior:
- it prefers the compiled
tgs.exeortgsbinary when present - it falls back to
python tgs.pyonly when the main binary is not available run-dueexpects an external scheduler heartbeat such as Windows Task Scheduler or cron- nothing runs just because a job exists in a plan file; a scheduler still has to call
run-due run-duevalidates the configured license before execution and skips due jobs until the license passes
Examples:
tgs_automation.exe -h
tgs_automation.exe validate-plan plan.json
tgs_automation.exe show-plan plan.json
tgs_automation.exe show-runner
tgs_automation.exe show-commands plan.json
tgs_automation.exe run-due plan.jsonFor send and post, the preferred workflow is:
- message file plus
--format
Supported values:
texthtmlmarkdown
Typical examples:
tgs.exe send -i tgs_data\users\members.csv -t message.txt -f text
tgs.exe send -i tgs_data\users\members.csv -t message.html -f html
tgs.exe send -i tgs_data\users\members.csv -t message.md -f markdownCommon export targets:
users: CSVposts:text,json,csv,sqlitedump: SQLite
Typical output folders created by the tool:
tgs_data/users/tgs_data/posts/tgs_data/dump/tgs_config/licenses/tgs_config/license_requests/
tgs.exe users -s source_group -o tgs_data\users\members.csvtgs.exe posts -s my_channel -t csv -o tgs_data\posts\messages.csvtgs.exe dump -s my_channel -m -a -f "html,md,json"tgs.exe send -i tgs_data\users\members.csv -t message.md -f markdown --previewtgs.exe post -g my_channel -t announcement.html -f htmltgs_automation.exe validate-plan plan.json
tgs_automation.exe show-commands plan.jsontgs_automation.exe run-due plan.jsonOperational model:
- save the plan file from the GUI or prepare it manually
- let Task Scheduler, cron, or another wrapper call
run-duerepeatedly - if the current local date/time is earlier than a job slot, the job is skipped for now
- if the current local date/time is later than the slot, the job runs once and is recorded in SQLite
- the default automation state DB lives next to the plan as
<plan_name>_automation.sqlite - accepted schedule styles include
Daily HH:MM,Mon-Fri HH:MM,Mon-Thu HH:MM,Mon-Wed|Fri HH:MM, andDay <N> HH:MM
tgs.exeis the Windows main CLItgsis the Linux main CLItgs_automation.exeis the Windows automation helpertgs_automationis the Linux automation helper- all included artifacts are one-file executables
- behavior may still depend on Telegram account state, session files, and target chat access
- The tool works with real Telegram accounts and real chats
- some commands intentionally wait between actions to reduce rate-limit issues
- generated exports may contain personal data and message history
- use the tool only where you have permission and understand platform restrictions
This repository is intended for binary distribution.
It does not ship source snapshots and does not document internal implementation details. For development history and source-level changes, see: