diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 1fec732..9692f7f 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -4,6 +4,8 @@ on: push: branches: - master + paths-ignore: + - '**/*.md' jobs: build-and-push: diff --git a/README.md b/README.md index 7a4658a..598cf7c 100644 --- a/README.md +++ b/README.md @@ -1,81 +1,233 @@ -# Turborepo starter +# Next-Downloader-Bot -This is an official starter Turborepo. +A Telegram bot for downloading TikTok videos and images without watermarks. Built with TypeScript, Grammy.js, and Redis for caching. -## Using this example +## ๐Ÿš€ Features -Run the following command: +- **TikTok Video Download**: Download TikTok videos without watermarks +- **Image Support**: Download TikTok image collections +- **Caching**: Redis-based caching to avoid re-downloading the same content +- **Rate Limiting**: Built-in rate limiting to prevent abuse +- **Internationalization**: Multi-language support (English, Russian) +- **Docker Support**: Easy deployment with Docker Compose +- **TypeScript**: Fully typed codebase for better development experience -```sh -npx create-turbo@latest +## ๐Ÿ“‹ Prerequisites + +- Node.js >= 18 +- pnpm >= 9.15.9 +- Redis server +- Telegram Bot Token + +## ๐Ÿ› ๏ธ Installation + +### 1. Clone the repository + +```bash +git clone https://github.com/yourusername/next-downloader-bot.git +cd next-downloader-bot ``` -## What's inside? +### 2. Install dependencies -This Turborepo includes the following packages/apps: - -### Apps and Packages - -- `docs`: a [Next.js](https://nextjs.org/) app -- `web`: another [Next.js](https://nextjs.org/) app -- `@repo/ui`: a stub React component library shared by both `web` and `docs` applications -- `@repo/eslint-config`: `eslint` configurations (includes `eslint-config-next` and `eslint-config-prettier`) -- `@repo/typescript-config`: `tsconfig.json`s used throughout the monorepo - -Each package/app is 100% [TypeScript](https://www.typescriptlang.org/). - -### Utilities - -This Turborepo has some additional tools already setup for you: - -- [TypeScript](https://www.typescriptlang.org/) for static type checking -- [ESLint](https://eslint.org/) for code linting -- [Prettier](https://prettier.io) for code formatting - -### Build - -To build all apps and packages, run the following command: - -``` -cd my-turborepo -pnpm build +```bash +pnpm install ``` -### Develop +### 3. Environment Setup -To develop all apps and packages, run the following command: +Create a `.env` file in the root directory: +```env +# Telegram Bot Configuration +BOT_TOKEN=your_telegram_bot_token_here +TELEGRAM_API_ROOT=https://api.telegram.org + +# Redis Configuration +REDIS_HOST=localhost +REDIS_PORT=6379 +REDIS_PASSWORD=your_redis_password_here + +# Rate Limiting (optional, default: 5000ms) +RATE_LIMIT=5000 ``` -cd my-turborepo + +### 4. Development + +```bash +# Start development mode pnpm dev + +# Build the project +pnpm build + +# Start production mode +pnpm start ``` -### Remote Caching +## ๐Ÿณ Docker Deployment -Turborepo can use a technique known as [Remote Caching](https://turbo.build/repo/docs/core-concepts/remote-caching) to share cache artifacts across machines, enabling you to share build caches with your team and CI/CD pipelines. +### Quick Start with Docker Compose -By default, Turborepo will cache locally. To enable Remote Caching you will need an account with Vercel. If you don't have an account you can [create one](https://vercel.com/signup), then enter the following commands: +1. Create your `.env` file with the required environment variables +2. Run the application: -``` -cd my-turborepo -npx turbo login +```bash +docker-compose up -d ``` -This will authenticate the Turborepo CLI with your [Vercel account](https://vercel.com/docs/concepts/personal-accounts/overview). +This will start: +- Redis server with password protection +- Telegram Bot API server +- Next-Downloader-Bot application -Next, you can link your Turborepo to your Remote Cache by running the following command from the root of your Turborepo: +### Development with Docker -``` -npx turbo link +For development, use the development compose file: + +```bash +docker-compose -f docker-compose.dev.yml up -d ``` -## Useful Links +## ๐Ÿ“ฑ Usage -Learn more about the power of Turborepo: +1. Start a conversation with your bot on Telegram +2. Send a TikTok video or image URL +3. The bot will download and send you the content without watermarks -- [Tasks](https://turbo.build/repo/docs/core-concepts/monorepos/running-tasks) -- [Caching](https://turbo.build/repo/docs/core-concepts/caching) -- [Remote Caching](https://turbo.build/repo/docs/core-concepts/remote-caching) -- [Filtering](https://turbo.build/repo/docs/core-concepts/monorepos/filtering) -- [Configuration Options](https://turbo.build/repo/docs/reference/configuration) -- [CLI Usage](https://turbo.build/repo/docs/reference/command-line-reference) +### Supported URL Formats + +- TikTok video URLs: `https://www.tiktok.com/@username/video/1234567890` +- TikTok image URLs: `https://www.tiktok.com/@username/photo/1234567890` + +## ๐Ÿ—๏ธ Project Structure + +``` +Next-Downloader-Bot/ +โ”œโ”€โ”€ apps/ +โ”‚ โ””โ”€โ”€ bot/ # Main bot application +โ”‚ โ”œโ”€โ”€ src/ +โ”‚ โ”‚ โ”œโ”€โ”€ bot/ # Bot logic and handlers +โ”‚ โ”‚ โ”œโ”€โ”€ config/ # Configuration files +โ”‚ โ”‚ โ”œโ”€โ”€ utils/ # Utility functions +โ”‚ โ”‚ โ””โ”€โ”€ index.ts # Entry point +โ”‚ โ”œโ”€โ”€ locales/ # Internationalization files +โ”‚ โ””โ”€โ”€ package.json +โ”œโ”€โ”€ packages/ # Shared packages +โ”‚ โ”œโ”€โ”€ eslint-config/ # ESLint configuration +โ”‚ โ”œโ”€โ”€ typescript-config/ # TypeScript configuration +โ”‚ โ””โ”€โ”€ lint-staged-config/ # Lint-staged configuration +โ”œโ”€โ”€ docker-compose.yml # Production Docker setup +โ”œโ”€โ”€ docker-compose.dev.yml # Development Docker setup +โ””โ”€โ”€ package.json +``` + +## ๐Ÿ”ง Configuration + +### Environment Variables + +| Variable | Description | Required | Default | +|----------|-------------|----------|---------| +| `BOT_TOKEN` | Telegram bot token from @BotFather | โœ… | - | +| `TELEGRAM_API_ROOT` | Telegram API root URL | โœ… | - | +| `REDIS_HOST` | Redis server host | โŒ | `redis` | +| `REDIS_PORT` | Redis server port | โŒ | `6379` | +| `REDIS_PASSWORD` | Redis server password | โœ… | - | +| `RATE_LIMIT` | Rate limit in milliseconds | โŒ | `5000` | + +### Redis Configuration + +The bot uses Redis for caching downloaded videos to avoid re-downloading the same content. Make sure Redis is properly configured with: + +- Password protection enabled +- Sufficient memory for caching +- Proper TTL settings + +## ๐Ÿงช Development + +### Available Scripts + +```bash +# Install dependencies +pnpm install + +# Development mode +pnpm dev + +# Build the project +pnpm build + +# Start production +pnpm start + +# Lint code +pnpm lint + +# Format code +pnpm format + +# Run tests +pnpm test:unit +pnpm test:e2e +``` + +### Code Quality + +The project uses: +- **ESLint** for code linting +- **Prettier** for code formatting +- **TypeScript** for type safety +- **Husky** for git hooks +- **Lint-staged** for pre-commit checks + +## ๐ŸŒ Internationalization + +The bot supports multiple languages. Language files are located in `apps/bot/locales/`: + +- `en.ftl` - English +- `ru.ftl` - Russian + +To add a new language: +1. Create a new `.ftl` file in the locales directory +2. Add the language to the bot configuration +3. Update the language detection logic + +## ๐Ÿ“Š Monitoring + +The bot includes comprehensive logging using Pino: + +- Request/response logging +- Error tracking +- Performance monitoring +- Rate limit tracking + +## ๐Ÿค Contributing + +1. Fork the repository +2. Create a feature branch (`git checkout -b feature/amazing-feature`) +3. Commit your changes (`git commit -m 'Add some amazing feature'`) +4. Push to the branch (`git push origin feature/amazing-feature`) +5. Open a Pull Request + +## ๐Ÿ“„ License + +This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. + +## โš ๏ธ Disclaimer + +This bot is for educational purposes only. Please respect TikTok's terms of service and copyright laws. Users are responsible for ensuring they have the right to download and use the content. + +## ๐Ÿ†˜ Support + +If you encounter any issues: + +1. Check the [Issues](https://github.com/yourusername/next-downloader-bot/issues) page +2. Create a new issue with detailed information +3. Include logs and error messages + +## ๐Ÿ”— Links + +- [Grammy.js Documentation](https://grammy.dev/) +- [Telegram Bot API](https://core.telegram.org/bots/api) +- [TikTok API DL](https://github.com/tobyg74/tiktok-api-dl) +- [Redis Documentation](https://redis.io/documentation)