This project is a Python-based Telegram bot integrated with the OpenAI API, operating similar to ChatGPT, and offers additional audio sending features. It can be executed in a Python environment or within a Docker container for added flexibility.
Before you begin, ensure you have met the following requirements:
- Python 3.11.4 installed. You can download it from here.
- Docker (optional). If you want to use Docker, install it from here.
- A Telegram account along with a bot token. Follow this guide to create a new bot if you don't have one already.
- An OpenAI account and API key. You can create an account here.
ffmpeg
installed on your machine if you are not using Docker. For installation instructions, refer to the official guide based on your OS.
Follow these steps to get the bot up and running:
- Clone this repository to your local machine:
git clone https://github.com/DoMo-98/chatBOT-GPT.git
- Navigate to the project directory:
cd chatBOT-GPT
- If you're not using Docker, install the necessary Python dependencies:
pip install -r requirements.txt
- For non-Docker users, ensure
ffmpeg
is installed on your system.
To set up your API keys and bot tokens, execute the generate_env.py
script. This script will prompt you to input your OpenAI and Telegram credentials.
python3 generate_env.py
There are two ways to start the bot:
- Python - Run the
src.main
module:
python3 -m src.main
- Docker Compose - Start the service with Docker Compose:
docker compose up
Both methods will initiate the bot, and it will start listening for incoming messages.
The bot recognizes several commands to help you interact with it. Here are the available commands:
-
/start - Initialize the bot. The bot will reply with: "Hello! I'm an assistant bot. I can answer all your text and voice messages."
-
/text - Switch the bot to text mode. The bot will respond with text messages only, and will confirm with: "I will now send text messages."
-
/audio - Switch the bot to audio mode. The bot will send audio messages, and will confirm with: "I will now send voice messages."
-
/new - Start a new chat. The bot will clear the message history and reply with: "New chat!"
-
/gpt3 - Switch the bot to use GPT-3.5-Turbo. The bot will confirm with: "I will now use GPT-3.5-Turbo."
-
/gpt4 - Switch the bot to use GPT-4. The bot will confirm with: "I will now use GPT-4."
To use these commands, simply type them in the chat with the bot on Telegram.
Your contributions are welcome and appreciated. Before proposing a contribution, please open an issue to discuss your proposed changes. Remember to update or add tests as appropriate.
This project is licensed under the terms of the MIT License.