This repository contains a Telegram bot for tracking cryptocurrency prices and setting up price alerts. The bot uses the CoinGecko API to fetch cryptocurrency prices and the python-telegram-bot library to interact with Telegram users.
- Get the current price of a specified cryptocurrency.
- Set up price alerts for specific conditions (e.g., when the price goes above or below a target value).
- View and manage active price alerts.
- Caching of coin mappings to reduce API calls.
- Periodic checking of price alerts.
-
Clone the repository:
git clone https://github.com/paragrudani1/telegram-crypto-alert-bot.git cd telegram-crypto-alert-bot -
Create and activate a virtual environment (optional but recommended):
python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
-
Install the required dependencies:
pip install -r requirements.txt
-
Create a
.envfile in the root directory and add your Telegram bot token:TELEGRAM_API_TOKEN=your_telegram_bot_token
-
Run the bot:
python price_alert_bot.py
-
Interact with the bot on Telegram using the following commands:
/start: Start the bot and get a welcome message./price <crypto> <currency>: Get the current price of the specified cryptocurrency./alert <crypto> <condition> <target_price> <currency>: Set up a price alert./alerts: View active price alerts./del <alert_id>: Delete a specific price alert.
/price BTC USD: Get the current price of Bitcoin in USD./alert BTC above 50000 USD: Set an alert for when Bitcoin's price goes above 50,000 USD./alerts: View your active price alerts./del 1: Delete the alert with ID 1.
Contributions are welcome! Please open an issue or submit a pull request for any improvements or bug fixes.
This project is licensed under the MIT License. See the LICENSE file for details.