A Python bot designed to monitor the stock status of the Astro Bot limited edition DualSense wireless controller on the German PlayStation Direct store. The bot sends notifications via Telegram and WhatsApp using CallMeBot and includes a real-time monitoring dashboard.
- ✨ Features
- 🔧 Requirements
- ⚙️ Installation
- 🖥️ Flask Dashboard Overview
- 🚀 Bot Behavior on Startup and Shutdown
- 🔄 How It Works
- ⏱️ Modifying Timings
- 🤝 Contributing
- 📄 License
⚠️ Disclaimer
- Automated Stock Monitoring: Periodically checks the stock status of the specified PlayStation product.
- Multi-Platform Notifications: Sends notifications via Telegram and WhatsApp for key events such as startup, in-stock alerts, and errors.
- Web Dashboard: Provides a real-time web-based dashboard to monitor bot activity and metrics.
- Error Handling: Logs errors and sends notifications when API calls fail.
- Python 3.7+: Download the latest version here.
- Telegram Bot API Key: Create a Telegram bot using BotFather.
- WhatsApp API Key from CallMeBot: Follow instructions on the CallMeBot website.
- Basic understanding of Python and API usage.
git clone https://github.com/yourusername/playstation-stock-checker.git
cd playstation-stock-checker
Install the required Python packages using pip:
pip install -r requirements.txt
Edit the settings
dictionary in the main.py
file with your details:
settings = {
'API_URL': "https://api.direct.playstation.com/commercewebservices/ps-direct-de/users/anonymous/products/productList?fields=BASIC&lang=de_DE&productCodes=1000044988-DE",
'TELEGRAM_BOT_TOKEN': "YOUR_TELEGRAM_BOT_TOKEN",
'TELEGRAM_CHAT_ID': "YOUR_TELEGRAM_CHAT_ID",
'WHATSAPP_PHONE': "YOUR_WHATSAPP_PHONE",
'WHATSAPP_APIKEY': "YOUR_WHATSAPP_APIKEY",
'CHECK_INTERVAL': 60,
'STATUS_INTERVAL': 3600,
}
- Create a bot using BotFather.
- Copy the Bot Token provided and paste it into the
TELEGRAM_BOT_TOKEN
field. - Get your
TELEGRAM_CHAT_ID
by sending a message to your bot and then visitinghttps://api.telegram.org/bot<YourBotToken>/getUpdates
.
- Visit the CallMeBot WhatsApp API page.
- Follow the instructions to register your phone number.
- Use the API key provided by CallMeBot in the
WHATSAPP_APIKEY
field.
To start the bot, run:
python main.py
Monitor the bot's activity by navigating to http://localhost:5000
in your web browser. The dashboard displays the number of API calls made, any errors encountered, and other useful metrics.
The Flask dashboard provides a real-time view of the bot’s operations:
- API Calls: Number of successful API requests.
- Errors: Number of API request failures.
- Last Response: Time taken by the last API response.
- Last In Stock: Last time the product was found in stock.
- Check Interval: How often the bot checks the stock status.
- Status Interval: How often the bot sends status updates.
When the bot starts, it sends a notification to both Telegram and WhatsApp to confirm that it has begun monitoring.
Example Notification:
Stock checker bot started and monitoring the product.
- Manual Shutdown: Stop the bot by terminating the Python process (e.g., Ctrl+C). No shutdown notification is sent.
- Restarting: On restart, the bot sends a startup notification.
- The bot checks the product's stock status every 60 seconds (by default).
- If the product is in stock, the bot sends a notification to Telegram and WhatsApp.
- The bot also sends a startup notification when it begins monitoring.
- The bot sends a status update every hour, summarizing its activity.
- This interval can be adjusted using the
STATUS_INTERVAL
setting.
- If an error occurs during an API call, the bot logs the error and sends a notification to both Telegram and WhatsApp. It continues to operate and will attempt the next scheduled check.
Adjust the checking and notification intervals by modifying the CHECK_INTERVAL
and STATUS_INTERVAL
in the settings
dictionary.
To check the stock every 30 seconds and send a status update every 2 hours, set:
settings = {
'CHECK_INTERVAL': 30,
'STATUS_INTERVAL': 7200,
}
Contributions are welcome!
- Fork the repository.
- Create a feature branch (
git checkout -b feature-branch
). - Commit your changes (
git commit -am 'Add some feature'
). - Push to the branch (
git push origin feature-branch
). - Open a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.
This bot is intended for personal use only. Be mindful of the terms of service of the APIs and websites you interact with using this bot. The author is not responsible for any misuse of this bot.