This is a Telegram bot written in Go that provides two main functionalities:
- Reverses any incoming message
- Generates short sci-fi stories using OpenAI's GPT-3.5 API
- Message Reversal: The bot will respond to any message by sending back its reversed version
- Story Generation: Use the
/storycommand to receive a randomly generated sci-fi story (max 400 characters) - Environment Variables: Secure configuration using .env file
- Docker Support: Easy deployment using Docker and Docker Compose
- Docker and Docker Compose
- Telegram Bot Token (from @BotFather)
- OpenAI API Key
- Clone the repository:
git clone <repository-url>
cd GenAI-basics-HW2-3- Create a
.envfile based on.env.example:
cp .env.example .env- Edit the
.envfile and add your credentials:
TELEGRAM_BOT_TOKEN=your_telegram_bot_token_here
OPENAI_API_KEY=your_openai_api_key_here
- Build and run the bot in detached mode:
docker-compose up -d- Check the logs:
docker-compose logs -f- Stop the bot:
docker-compose down- Install Go 1.21 or higher
- Install dependencies:
go mod download- Run the bot:
go run main.goRun the unit tests:
go test ./utils.
├── main.go # Main bot implementation
├── utils/
│ ├── string_utils.go # String reversal function
│ └── string_utils_test.go # Unit tests
├── Dockerfile
├── docker-compose.yml
├── go.mod
├── go.sum
└── README.md
Feel free to submit issues and enhancement requests!