This project is a Telegram bot built with Go. It uses PostgreSQL as the database and Docker for containerization.
- Docker
- Docker Compose
git clone https://github.com/DmitrySadovnikov/go-telegram-bot.git
cd go-telegram-bot
-
Build and start the services using Docker Compose:
docker compose up --build
-
The application will be available at
http://localhost:8080
.
The following environment variables are used in the project:
PORT
: The port on which the application runs (default: 8080).DATABASE_URL
: The URL for connecting to the PostgreSQL database.
- URL:
/api/messages
- Method:
POST
- Description: This endpoint processes incoming Telegram messages.
Request:
curl -X POST http://localhost:8080/messages -H "Content-Type: application/json" -d '{
"update_id": 394352518,
"message": {
"message_id": 5,
"from": {
"id": 123456789,
"is_bot": false,
"first_name": "Dmitry",
"last_name": "Sadovnikov",
"username": "DmitrySadovnikov",
"language_code": "en-RU"
},
"chat": {
"id": 123456789,
"first_name": "Dmitry",
"last_name": "Sadovnikov",
"username": "DmitrySadovnikov",
"type": "private"
},
"date": 1527367962,
"text": "hi"
}
}'
Response:
{
"message": "hi"
}
To run the project locally without Docker, ensure you have Go installed and follow these steps:
-
Install dependencies:
go mod download
-
Run the application:
go run main.go
This project uses gometalinter
for linting. To run the linter:
gometalinter --config=.gometalinter.json ./...
Contributions are welcome! Please open an issue or submit a pull request.
This project is licensed under the MIT License.