- Node.js installed
- MongoDB installed
- Telegram Bot token from BotFather
- OpenWeatherMap API key
Clone the Repository
git clone https://github.com/codecraft26/wheather-bot-server
cd wheather-bot-server
npm install
Create a .env file in the root directory with the following content:
TELEGRAM_BOT_TOKEN=YOUR_TELEGRAM_BOT_TOKEN
MONGODB_URI=YOUR_MONGODB_URI
OPENWEATHERMAP_API_KEY=YOUR_OPENWEATHERMAP_API_KEY
Replace YOUR_TELEGRAM_BOT_TOKEN, YOUR_MONGODB_URI, and YOUR_OPENWEATHERMAP_API_KEY with your actual values.
You can use a MongoDB GUI or shell to insert an admin user manually. Add a document to the users collection:
{
"username": "admin",
"password": "adminpassword",
"isAdmin": true
}
npm start
The bot will be accessible at http://localhost:8000.
- /start - Subscribe to daily weather updates.
- /stop - Unsubscribe from daily weather updates.
- Access the admin panel at http://localhost:8000/admin.
- Use Google login to authenticate.
- Update bot settings and manage user accounts.
- The bot sends weather updates daily at 9 AM using the OpenWeatherMap API.