Telegram inline бот, использующий ChatGPT для ответов на запросы.
- Скопируйте файл
env.exampleв.env:
cp env.example .env- Отредактируйте файл
.envи заполните необходимые переменные:
TELEGRAM_BOT_TOKEN- токен вашего бота (получите у @BotFather)OPENROUTER_API_KEY- ваш API ключ OpenRouterOPENROUTER_MODEL- опционально, модель (напримерopenai/gpt-4o-mini)LLM_SYSTEM_PROMPT- опционально, системный промпт для ChatGPT
- Соберите Docker образ:
docker build -t chatgpt-inline-bot .- Запустите контейнер:
docker run -d --name chatgpt-bot --env-file .env chatgpt-inline-bot- Просмотр логов:
docker logs chatgpt-bot - Остановка:
docker stop chatgpt-bot - Запуск:
docker start chatgpt-bot - Удаление:
docker rm chatgpt-bot
- Найдите бота в Telegram
- В любом чате введите @имя_вашего_бота и ваш запрос
- Выберите ответ из предложенных вариантов
- Inline mode: just type
@YourBotName your questionin any chat - Uses OpenRouter-compatible models for answers
- Shows both the answer and the original query
- English-only interface for all user messages
- Query length limits (min 10, max 200 characters)
- Python 3.8+
- Telegram bot token (how to get one)
- OpenRouter API key (how to get one)
- Clone the repository:
git clone https://github.com/yourusername/ChatGPTInlineBot.git cd ChatGPTInlineBot - Install dependencies:
pip install -r requirements.txt
- Create a
.envfile:TELEGRAM_BOT_TOKEN=your_telegram_bot_token OPENROUTER_API_KEY=your_openrouter_api_key # Optional: OPENROUTER_MODEL=openai/gpt-4o-mini # Optional: LLM_SYSTEM_PROMPT=You are a helpful assistant.
Run the bot:
python ChatGPTInlineBot.pyAdd your bot to Telegram and use inline mode:
@YourBotName your question here
- Remove sensitive data: Make sure
.envand any files with secrets are in.gitignore. - Add a
.gitignorefile (if not present):.env __pycache__/ *.pyc - Check for hardcoded tokens or keys in the code.
- Write a short project description in the repo (GitHub settings).
- Add a license (MIT, Apache 2.0, etc.) if you want others to use your code.
- (Optional) Add usage examples/screenshots to the README.
Enjoy your ChatGPT-powered Telegram inline bot!