This Go program processes Telegram messages with URLs, validates them, and generates link previews. It outputs cleaned, unique URLs and their previews to JSON files.
- Extracts and validates URLs from Telegram messages.
- Removes session-related query strings.
- Ensures unique, valid URLs.
- Generates link previews.
- Configurable via command-line arguments or environment variables.
-import-urls: Import URLs from a JSON file (default:imports/export.json) and output cleaned URLs (default:dist/urls.json).-import-input: Input JSON file path (default:imports/export.json).-import-output: Output JSON file path (default:dist/urls.json).
-generate-preview: Generate link previews.-preview-input: Input JSON file for URLs (default:dist/urls.json).-preview-output: Output JSON file for previews (default:dist/previews.json).
export IMPORT_IGNORE=".*example.com.*"
go run . -import-urls -import-input=imports/export.json -import-output=dist/urls.jsonexport DEBUG=true
go run . -generate-preview -preview-input=dist/urls.json -preview-output=dist/previews.jsonIMPORT_IGNORE: Regex to ignore URLs.- Example:
export IMPORT_IGNORE=".*example.com.*" - Default: No URLs ignored.
- Example:
DEBUG: Enable debug logging.- Example:
export DEBUG=true - Default:
false.
- Example:
- Go 1.24.2 or later.
- Make (optional): For running Makefile commands.
make setup
make hooksThe pre-commit hook will run tests and linting before each commit. You can also run them manually:
make test
make lintor
make lint-fixto automatically fix linting issues.
The commit-msg hook will ensure that your commit messages follow the conventional commit format. If you want to skip this check, you can use the --no-verify flag when committing.
$ tree -d
.
├── bin
├── dist
├── imports
├── internal
│ ├── imports
│ ├── previews
│ ├── types
│ ├── utils
│ └── validation
└── scriptsThis project is licensed under the MIT License. See the LICENSE file for details.