This project is a Telegram bot that interacts with users, processes messages, and performs various database operations to save message details and user information. The bot also communicates with an external API to enhance its functionalities.
- Go (version 1.18 or higher)
- PostgreSQL
- A Telegram bot token (obtainable from the BotFather)
- API key for the external service (replace
API_URL
inapi/client.go
if necessary)
-
Clone the repository:
git clone https://github.com/alirezadp10/english-editor-bot.git cd projectname
-
Configure Environment Variables: Create a
.env
file in the root directory and add the necessary environment variables:BOT_TOKEN=your_telegram_bot_token API_KEY=your_api_key POSTGRES_USER=your_postgres_username POSTGRES_PASSWORD=your_postgres_password POSTGRES_DB=your_postgres_db POSTGRES_PORT=your_postgres_port
-
Install Go dependencies:
go mod tidy
-
Run the Bot:
go run main.go
The main entry point initializes the bot, connects to the database, and starts the bot with configured handlers.
- bot.go: Initializes the bot and defines its settings.
- handlers.go: Contains bot command handlers and message processing functions.
- connection.go: Manages the PostgreSQL database connection.
- models.go: Defines models for the database (User, Chat, Message, etc.).
- operations.go: Includes functions to perform operations like saving users, chats, and messages.
- client.go: Handles the creation and sending of requests to the external API.
- parser.go: Parses responses from the external API.
- config.go: Loads environment variables from the
.env
file.
- After starting the bot, you can interact with it on Telegram by sending messages.
- Use
/check
command to trigger the bot's message processing and API interaction.
This project is licensed under the MIT License. See LICENSE
for details.