Files
smartsoltech_site/scripts/update_bot_token.sh
Andrew K. Choi d9adac609b chore: reorganize project structure and prepare for deployment
- Organize files into logical directories (docs/, scripts/, tests/)
- Add comprehensive documentation (README, CONTRIBUTING, CHANGELOG)
- Create deployment automation scripts
- Add Docker production configuration
- Update .gitignore and add .dockerignore
- Remove temporary and test files from root
- Improve settings.py with DEBUG from env variable

Added:
- README.md with project overview
- CONTRIBUTING.md for contributors
- CHANGELOG.md for version tracking
- PROJECT_STATUS.md with current state
- docker-compose.prod.yml for production
- nginx.conf for production web server
- scripts/deploy.sh for automated deployment
- scripts/check-config.sh for configuration validation
- scripts/setup-ssl.sh for SSL certificate setup
- docs/DEPLOYMENT.md with detailed deployment guide
- docs/ENV_VARIABLES.md with all environment variables

Moved:
- Documentation to docs/
- Scripts to scripts/
- Test files to tests/

Removed:
- .history/ directory
- Test response JSON files from root
- settings_production.py (merged into settings.py)

This commit prepares the project for:
- Production deployment
- Team collaboration
- Docker containerization
- Proper documentation
2025-11-24 07:12:04 +09:00

50 lines
1.9 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# Скрипт для обновления токена Telegram бота
# Использование: ./update_bot_token.sh "НОВЫЙ_ТОКЕН"
if [ $# -eq 0 ]; then
echo "❌ Ошибка: Необходимо указать токен"
echo "Использование: $0 \"НОВЫЙ_ТОКЕН\""
echo ""
echo "Пример: $0 \"1234567890:ABCDEFghijklmnopqrstuvwxyz\""
echo ""
echo "Получите токен от @BotFather в Telegram:"
echo "1. Отправьте /mybots"
echo "2. Выберите своего бота"
echo "3. Нажмите 'API Token'"
exit 1
fi
NEW_TOKEN="$1"
echo "🔄 Обновление токена Telegram бота..."
# Проверяем валидность токена
echo "🔍 Проверка валидности токена..."
RESPONSE=$(curl -s "https://api.telegram.org/bot${NEW_TOKEN}/getMe")
if echo "$RESPONSE" | grep -q '"ok":true'; then
BOT_USERNAME=$(echo "$RESPONSE" | grep -o '"username":"[^"]*"' | cut -d'"' -f4)
echo "✅ Токен валиден! Бот: @${BOT_USERNAME}"
else
echo "❌ Ошибка: Токен невалиден!"
echo "Ответ API: $RESPONSE"
exit 1
fi
# Обновляем токен в базе данных
echo "💾 Обновление токена в базе данных..."
docker exec postgres_db psql -U trevor -d 2st_db -c "
UPDATE comunication_telegramsettings
SET bot_token = '$NEW_TOKEN', bot_name = '@${BOT_USERNAME}'
WHERE id = 1;
"
if [ $? -eq 0 ]; then
echo "✅ Токен успешно обновлен в базе данных!"
echo "🔄 Перезапуск контейнера telegram_bot..."
docker restart telegram_bot
echo "🎉 Готово! Проверьте логи: docker logs telegram_bot"
else
echo "❌ Ошибка при обновлении базы данных"
exit 1
fi