The telegram_alerts.py is a comprehensive alerting module designed for a Telegram bot application. It not only facilitates sending formatted alerts about cryptocurrency volume changes on exchanges like Binance and Kucoin but also integrates with Dextools and Dexscreener URL listeners for broader monitoring capabilities. Utilizing additional modules for formatting and determining alert levels, this script stands as a central hub for notification dispatch within the bot ecosystem.
- Versatile Alerting: Supports a wide range of alerts including exchange volume changes, Dextools and Dexscreener link detections, and direct address alerts.
- Dynamic Message Formatting: Leverages the formatting_btk module to format numerical values for easier readability.
- Alert Level Analysis: Integrates with alert_levels_tg to assess and communicate the significance of volume changes.
- Secure Configuration: Manages sensitive information such as API keys and bot tokens through a dedicated credentials_telegram.json file.
- Python 3.6+: Required for running the script.
- Requests: For making HTTP requests to the Telegram API.
- formatting_btk: A custom module for formatting numbers.
- alert_levels_tg: A custom module for determining and describing alert levels based on predefined criteria.
1. Ensure Python and Pip are installed:
Verify Python 3.6+ and pip are installed on your system by running python --version and pip --version.
2. Install Dependencies:
Install the Requests library and ensure formatting_btk and alert_levels_tg modules are accessible within your project environment:
pip install requests
3. Configure Credentials:
Edit credentials_telegram.json to include your Telegram bot's credentials. This file should be securely stored and properly referenced by the script.
{
"Telegram_bot_token": "INSERT YOUR TELEGRAM BOT TOKEN HERE (operational bot-1)",
"Telegram_chat_id": "INSERT THE TELEGRAM CHAT ID HERE WHERE YOU WANT TO RECEIVE TELEGRAM BOT NOTIFICATIONS (operational chat_id-1)"
"bot_token_1": "insert your_bot_token_here (operational bot-2)",
"chat_id_1": "insert your_listener_chat_id_here (operational chat_id-2)",
"response_chat_id": "insert your_response_chat_id_here",
"api_id": "insert_your_api_id_here",
"api_hash": "insert_your_api_hash_here",
"dextools_api_key": "insert_your_dextools_api_key_here"
}
The script is designed to be imported and utilized by other components within the bot application:
from telegram_alerts import handle_and_send_message
# Example alert details
alert_details = {
'exchange': 'Binance',
'symbol': 'BTC/USDT',
'curr_volume': 10234.56,
'prev_volume_mean': 9786.43,
'level': 'High',
'chart_url': 'https://example.com/chart'
}
credentials = load_telegram_credentials()
send_telegram_message(alert_details)
This will format and send an alert message to the specified Telegram chat or channel based on the provided details.
Contributions are welcome! If you have ideas for new features, improvements, or bug fixes, feel free to fork the repository, make your changes, and submit a pull request.
For issues, questions, or contributions, please open an issue in the GitHub repository.
Feedback and contributions are welcome!
This project is licensed under the MIT License - see the LICENSE file for details.