Skip to content

Kavazar-i/GenAI-basics-HW2-3

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Telegram Bot with Message Reversal and Story Generation

This is a Telegram bot written in Go that provides two main functionalities:

  1. Reverses any incoming message
  2. Generates short sci-fi stories using OpenAI's GPT-3.5 API

Features

  • Message Reversal: The bot will respond to any message by sending back its reversed version
  • Story Generation: Use the /story command 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

Prerequisites

  • Docker and Docker Compose
  • Telegram Bot Token (from @BotFather)
  • OpenAI API Key

Setup

  1. Clone the repository:
git clone <repository-url>
cd GenAI-basics-HW2-3
  1. Create a .env file based on .env.example:
cp .env.example .env
  1. Edit the .env file and add your credentials:
TELEGRAM_BOT_TOKEN=your_telegram_bot_token_here
OPENAI_API_KEY=your_openai_api_key_here

Running the Bot

Using Docker Compose (Recommended)

  1. Build and run the bot in detached mode:
docker-compose up -d
  1. Check the logs:
docker-compose logs -f
  1. Stop the bot:
docker-compose down

Local Development (Alternative)

  1. Install Go 1.21 or higher
  2. Install dependencies:
go mod download
  1. Run the bot:
go run main.go

Testing

Run the unit tests:

go test ./utils

Project Structure

.
├── 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

Contributing

Feel free to submit issues and enhancement requests!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published