A Telegram bot that integrates GPT-powered conversations with activation-based functionality for group chats.
- Clone the repository: Clone this repository using
git clone
. - Download Dependencies: Download the required dependencies into the Virtual Environment
venv
usinguv
.
git clone https://github.com/grisha765/gpt4tg.git
cd gpt4tg
python -m venv .venv
.venv/bin/python -m pip install uv
.venv/bin/python -m uv sync
-
Run the bot:
TG_TOKEN="your_telegram_bot_token" uv run main.py
-
Other working env's:
LOG_LEVEL="INFO" TG_ID="your_telegram_api_id" TG_HASH="your_telegram_api_hash" TG_TOKEN="your_telegram_bot_token" DB_PATH="data.db" API_IP="127.0.0.1" API_PORT="1337" GENAI_API="your_gemini_api_key, your_gemini_api_key2, your_gemini_api_key3" # if not empty then gemini is activated GPT_MODEL="gpt-4o-mini" # also set for gemini GPT_PROVIDER="DDG" # only works in gpt4free or ollama GPT_TOKENS="512" GPT_TEMPERATURE="0.5" CHAT_MSG_STORAGE="10"
-
Pull container:
podman pull ghcr.io/grisha765/gpt4tg:latest
-
Run bot:
mkdir -p $HOME/database/ && \ podman run --tmpfs /tmp -d \ --name gpt4tg \ -v $HOME/database:/app/database:z \ -e TG_TOKEN="your_telegram_bot_token" \ ghcr.io/grisha765/gpt4tg:latest
-
Activation:
- Add the bot to a
group chat
. - The bot will generate a
password
in thelogs
. Activate
the group with the command:/activate <password>
- Add the bot to a
-
GPT Requests:
- Direct request
create virtual chat
:/gpt <message>
- Reply-based request:
Reply to the message generated by the bot to continue the
conversation
in this chat.
- Direct request
- Handles group chat
activations
with apassword
system. - Supports
OpenAI API
andGemini API
responses for user queries. Queue-based
message handling to process requests efficiently.- Chat history maintained for context in
conversations
. Configurable
through environment variables.