From ab670a553d95d009aa89e6210e1ad0a5475e66d1 Mon Sep 17 00:00:00 2001 From: difome Date: Tue, 27 Jan 2026 20:54:23 +0300 Subject: [PATCH 1/4] add .env.example for bot configuration and update README with setup instructions --- .env.example | 26 ++++++++++++++++++++++++++ README.md | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 77 insertions(+), 2 deletions(-) create mode 100644 .env.example diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..2b539f3 --- /dev/null +++ b/.env.example @@ -0,0 +1,26 @@ +# ============================================ +# TELEGRAM BOT CONFIGURATION +# ============================================ + +# Telegram Bot Token (Required) +# Get it from BotFather: https://t.me/botfather +BOT_TOKEN=your_bot_token_here + +# Creator ID (Required) +# Your Telegram user ID - the bot will recognize you as creator +CREATOR_ID=your_user_id_here + +# ============================================ +# OPTIONAL: AI MODELS +# ============================================ + +# Google Gemini +GEMINI_API_KEY= + +# Mistral AI +MISTRAL_API_KEY= + +# Ollama (Local) +OLLAMA_ADDRESS= +OLLAMA_MODEL= +SYSTEM_PROMPT= diff --git a/README.md b/README.md index 1dc7ffb..230d7f3 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,51 @@ -# tg-chat-bot - +# Telegram Chat Bot + + +## Quick Start + +```bash +cp .env.example .env +# Edit .env: add BOT_TOKEN and CREATOR_ID or +``` + +**With Bun (Recommended):** +```bash +bun install +bunx drizzle-kit generate && bunx drizzle-kit migrate +bun run build && bun start +``` + +**With Node.js:** +```bash +npm install +npx drizzle-kit generate && npx drizzle-kit migrate +npm run build && npm start +``` + +**With Docker:** +```bash +docker build -f Dockerfile -t tg-bot . +docker run -d --env-file .env -v $(pwd)/data:/config/data tg-bot +``` + +**With Docker (Bun):** +```bash +docker build -f Dockerfile-bun -t tg-bot-bun . +docker run -d --env-file .env -v $(pwd)/data:/config/data tg-bot-bun +``` + +## Requirements + +- Node.js >= 18 OR Bun >= 1.0 +- Docker (optional) + + +## Features + +- AI chat (Gemini, Mistral, Ollama) +- Custom answers and commands +- Admin management +- User blocking (mute/unmute) +- QR code generation +- System info +- And more... From c93da69281f7884e86e3bbb11e12fcb2f07e55b2 Mon Sep 17 00:00:00 2001 From: difome Date: Wed, 28 Jan 2026 04:48:22 +0200 Subject: [PATCH 2/4] update .env.example and README with additional bot configuration options --- .env.example | 41 ++++++++++++++++++++++++++++++++++++----- README.md | 5 ++++- 2 files changed, 40 insertions(+), 6 deletions(-) diff --git a/.env.example b/.env.example index 2b539f3..4afd715 100644 --- a/.env.example +++ b/.env.example @@ -2,25 +2,56 @@ # TELEGRAM BOT CONFIGURATION # ============================================ -# Telegram Bot Token (Required) +# Telegram Bot Token # Get it from BotFather: https://t.me/botfather BOT_TOKEN=your_bot_token_here -# Creator ID (Required) +# Creator ID # Your Telegram user ID - the bot will recognize you as creator CREATOR_ID=your_user_id_here # ============================================ -# OPTIONAL: AI MODELS +# BOT SETTINGS (Optional) +# ============================================ + +# Bot Prefix for commands +BOT_PREFIX= + +# Whitelist of chat IDs (comma-separated) +# Example: 123456789,987654321 +CHAT_IDS_WHITELIST= + +# Test environment mode +TEST_ENVIRONMENT=false + +# Docker deployment +IS_DOCKER=false + +# Only creator can use bot +ONLY_FOR_CREATOR_MODE=false + +# Use user names in AI prompts +USE_NAMES_IN_PROMPT=true + +# Maximum photo size in pixels +MAX_PHOTO_SIZE=1280 + +# ============================================ +# AI MODELS CONFIGURATION (Optional) # ============================================ # Google Gemini GEMINI_API_KEY= +GEMINI_MODEL=gemini-2.5-flash # Mistral AI MISTRAL_API_KEY= +MISTRAL_MODEL=mistral-small-latest -# Ollama (Local) +# Ollama (Local AI Model) OLLAMA_ADDRESS= OLLAMA_MODEL= -SYSTEM_PROMPT= +OLLAMA_API_KEY= + +# Custom system prompt for AI +SYSTEM_PROMPT= \ No newline at end of file diff --git a/README.md b/README.md index 230d7f3..c4e462a 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,12 @@ # Telegram Chat Bot +Bot for Telegram with a lot of commands and AI (Ollama/Gemini/Mistral) written in TypeScript + NodeJS/Bun runtime + Drizzle ORM (SQLite DB) ## Quick Start ```bash cp .env.example .env -# Edit .env: add BOT_TOKEN and CREATOR_ID or +# Edit .env: add BOT_TOKEN, CREATOR_ID and configure optional AI models (GEMINI_API_KEY, MISTRAL_API_KEY, OLLAMA_ADDRESS) ``` **With Bun (Recommended):** @@ -24,12 +25,14 @@ npm run build && npm start **With Docker:** ```bash +# Set IS_DOCKER=true in .env docker build -f Dockerfile -t tg-bot . docker run -d --env-file .env -v $(pwd)/data:/config/data tg-bot ``` **With Docker (Bun):** ```bash +# Set IS_DOCKER=true in .env docker build -f Dockerfile-bun -t tg-bot-bun . docker run -d --env-file .env -v $(pwd)/data:/config/data tg-bot-bun ``` From f2b8e55900a78001944572668d25ddf525f436fc Mon Sep 17 00:00:00 2001 From: difome Date: Wed, 28 Jan 2026 04:55:15 +0200 Subject: [PATCH 3/4] update README --- .env.example | 3 --- README.md | 2 -- 2 files changed, 5 deletions(-) diff --git a/.env.example b/.env.example index 4afd715..f5526e5 100644 --- a/.env.example +++ b/.env.example @@ -24,9 +24,6 @@ CHAT_IDS_WHITELIST= # Test environment mode TEST_ENVIRONMENT=false -# Docker deployment -IS_DOCKER=false - # Only creator can use bot ONLY_FOR_CREATOR_MODE=false diff --git a/README.md b/README.md index c4e462a..7fe6d07 100644 --- a/README.md +++ b/README.md @@ -25,14 +25,12 @@ npm run build && npm start **With Docker:** ```bash -# Set IS_DOCKER=true in .env docker build -f Dockerfile -t tg-bot . docker run -d --env-file .env -v $(pwd)/data:/config/data tg-bot ``` **With Docker (Bun):** ```bash -# Set IS_DOCKER=true in .env docker build -f Dockerfile-bun -t tg-bot-bun . docker run -d --env-file .env -v $(pwd)/data:/config/data tg-bot-bun ``` From 42417d71acfbe480529554b53288e31a0580ec06 Mon Sep 17 00:00:00 2001 From: difome Date: Wed, 28 Jan 2026 05:22:32 +0200 Subject: [PATCH 4/4] update README.md --- .env.example | 1 + README.md | 5 +++++ docker-compose.yml | 11 +++++++++++ 3 files changed, 17 insertions(+) create mode 100644 docker-compose.yml diff --git a/.env.example b/.env.example index f5526e5..2032fd8 100644 --- a/.env.example +++ b/.env.example @@ -8,6 +8,7 @@ BOT_TOKEN=your_bot_token_here # Creator ID # Your Telegram user ID - the bot will recognize you as creator +# To get your ID: send /id command to the bot and use the "from id" value CREATOR_ID=your_user_id_here # ============================================ diff --git a/README.md b/README.md index 7fe6d07..14d6dd6 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,11 @@ npx drizzle-kit generate && npx drizzle-kit migrate npm run build && npm start ``` +**With Docker Compose:** +```bash +docker compose up -d +``` + **With Docker:** ```bash docker build -f Dockerfile -t tg-bot . diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..195d85c --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,11 @@ +services: + tgchatbot: + container_name: tgchatbot + image: ghcr.io/melod1n/tg-chat-bot:latest + restart: unless-stopped + environment: + - PUID=1000 + - PGID=1000 + - TZ=Europe/Moscow + volumes: + - ./config:/config \ No newline at end of file