This project is a TypeScript-based application that includes a bot and an Express server. The bot handles various commands and interactions, while the server manages counts and goals.
- TypeScript
- Node.js
- Express
- Mongoose
- Yarn
- npm
-
Clone the repository:
git clone <repository-url> cd <repository-directory>
-
Install dependencies:
yarn install
-
Environment Variables
Create a
.envfile in the root directory and add the following variables:TELEGRAM_TOKEN: Token for the Telegram bot.SERVER_URL: URL for the server.PORT: Port number for the Express server.MONGO_URL: MongoDB connection string.GOOGLE_AI_KEY: API key for Google AI.SECRET_KEY: Secret key for the application.
Example
.envfile:TELEGRAM_TOKEN=your-telegram-token SERVER_URL=http://localhost:4000 PORT=4000 MONGO_URL=mongodb://your-mongo-url GOOGLE_AI_KEY=your-google-ai-key SECRET_KEY=your-secret-key
-
The bot will automatically start and listen for commands.
/missed: Prompts the user to choose a period for missed days./notification_on: Turns on notifications for the chat./notification_off: Turns off notifications for the chat./quote: Sends the quote of the day./rec: Sends a recommendation for the week.
- URL:
/count - Method:
GET - Query Parameters:
page(optional): Page number for pagination.chatId(required): ID of the chat.
- URL:
/count/total/:goalId - Method:
GET - Query Parameters:
period(optional): Period for the count (default isday).minus(optional): Subtracts the specified number of periods from the current date.
- URL:
/count - Method:
POST - Body Parameters:
goalId(required): ID of the goal.amount(required): Amount to add to the count.
All errors are logged to the console, and appropriate error messages are returned to the client.
This project is licensed under the MIT License.