OpenTekHub / cryptobot

an telegram bot to track latest cryptocurrency prices
https://t.me/trackingcryptopricerbot
MIT License
11 stars 37 forks source link

Enhancements for Better Error Handling, Rate Limiting, and Pagination #55

Open Trumilnasit opened 3 weeks ago

Trumilnasit commented 3 weeks ago

This issue proposes several enhancements to improve the functionality, usability, and stability of the Crypto Bot. Below are the detailed changes that need to be implemented:

  1. Secure Bot Token Management Current Issue: The bot token is hardcoded in the code, which is not secure. Proposed Solution: Use environment variables (os.getenv('BOT_TOKEN')) to load the bot token securely and add error handling if the token is missing. Benefit: Prevents accidental token exposure, improving the bot’s security.
  2. Improved Error Handling Current Issue: The error handler only prints errors but does not inform the user or log details. Proposed Solution: Enhance the error_handler function to log errors for debugging purposes and notify the user with a friendly message when something goes wrong. Benefit: Helps developers debug and provides a better user experience.
  3. Rate Limiting and Retry Logic for API Requests Current Issue: API requests do not handle rate-limiting and could fail if the limit is hit. Proposed Solution: Add retry logic with a delay between requests to handle potential rate limits from the CoinGecko API. Benefit: Increases the reliability of the bot by reducing failed requests due to rate limits.
  4. Pagination for Large Data Sets Current Issue: When fetching large data sets (e.g., Top 100 Cryptocurrencies), the entire list is displayed, which may overwhelm users. Proposed Solution: Implement pagination for large data sets using inline buttons (Previous and Next) to navigate through pages of cryptocurrencies. Benefit: Improves the user experience by allowing them to view manageable chunks of data.
  5. Add Unit Tests Current Issue: The bot lacks unit tests, which makes it harder to verify the correctness of the code after changes. Proposed Solution: Add unit tests using a framework like pytest to cover the critical functions such as get_crypto_price() and get_crypto_details(). Benefit: Ensures that the bot's functionality remains intact during future changes and makes the code more robust.
  6. Better Search Functionality Current Issue: The search functionality does not provide suggestions if the exact match is not found. Proposed Solution: Improve the search functionality by offering suggestions for similar results when no exact match is found. Benefit: Enhances the usability of the search feature, making it more user-friendly.
  7. Logging for Debugging Current Issue: The bot currently lacks proper logging for activities and errors. Proposed Solution: Add logging to track important activities like bot startup and user actions, along with error logs for debugging purposes. Benefit: Simplifies debugging and helps track bot usage patterns.
  8. Additional Commands Current Issue: The bot could benefit from additional features, such as price history and crypto-related news. Proposed Solution: Add commands like /pricehistory to display historical prices and /news to fetch crypto news from relevant APIs. Benefit: Adds more functionality, making the bot more versatile and useful for users. Tasks: Replace hardcoded token with environment variable. Enhance the error handler to log errors and notify users. Implement retry logic and handle rate limits for API requests. Add pagination support for large data sets. Add unit tests for key functionalities. Improve the search feature with suggestions for similar results. Add logging for debugging. Implement new commands: /pricehistory and /news.

@Harish-2003 :--can you assign me this with all labels and level-2 badges for this issue

github-actions[bot] commented 3 weeks ago

Hi there! Thanks for opening this issue. We appreciate your contribution to this open-source project. We aim to respond or assign your issue as soon as possible.

harshitajha4680 commented 3 weeks ago

Please assign this issue to me, I'm intersted!