Git Product home page Git Product logo

notify's Introduction

Disclaimer: Notify App is in Development Mode

Please note that the Notify app is currently in development mode, and as a result, you won't be able to use it directly by visiting https://t.me/playlistNotificationBot without reaching out to me first.

Usage Instructions:

  1. If you are interested in using the Notify app, contact me to be manually added to the whitelist. You can reach out to me through [email protected] to request access.
  2. Once you have contacted me and your request has been approved, you will receive further instructions on how to access and use the Notify app.

Notify

Notify is a Telegram bot that allows you to manage your playlist notifications and receive updates whenever there are changes to your favorite playlists on Spotify. It also offers a range of features to help you interact with your Spotify data.

Getting Started

To use the bot, you can either start a conversation with Notify Bot link or by searching for playlistNotificationBot in your Telegram app search bar.

Dependencies

This project is built using the following libraries and tools:

  • Telebot - A Python wrapper for the Telegram Bot API.
  • Spotipy - A lightweight Python library for the Spotify Web API.
  • sqlite3 - A built-in Python module for working with SQLite databases.
  • DigitalOcean - A cloud infrastructure provider used for server-side operations.

Contributing

Contributions to this project are welcome, and an issues list is available. If you're interested in contributing, please follow these guidelines:

  1. Fork the repository and create your branch.
  2. Make your changes and ensure they adhere to the code style and best practices.
  3. Write clear and concise commit messages.
  4. Test your changes thoroughly.
  5. Submit a pull request with a detailed description of the changes you made.

License

This project is licensed under the terms of the LICENSE file. Please refer to the license file for more information.

Resources

Here are some resources to help you get started:

If you have any questions or need assistance, feel free to reach out.

notify's People

Contributors

rafacovez avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

notify's Issues

Refactor BaseCommandHandler to Handle Multiple Commands

Issue Description

Modification Request: Refactoring BaseCommandHandler to Handle Multiple Commands

Problem Statement

The current code structure utilizes individual classes for each command, which can lead to code duplication, disorganization, and inefficient use of classes. This approach does not align with software engineering best practices and the intended usage of classes.

Proposed Solution

Refactor the BaseCommandHandler to handle multiple commands within a single class. This modification will improve code organization, reduce redundancy, and adhere to the principles of object-oriented programming.

Acceptance Criteria

  • Replace individual classes for each command with a single CommandHandler class.
  • The refactored class should handle all commands in the bot's code.
  • Maintain functionality of the existing code, including the common_code and specific_code methods.
  • Ensure the refactored code follows best practices for code structure, modularity, and reusability.

Technical Considerations

  • Identify the common functionality shared among the existing command classes and extract it to the CommandHandler class.
  • Modify the CommandHandler class to handle different commands based on input parameters or message content.
  • Refactor the code to remove the need for individual command classes and their corresponding method overrides.
  • Consider using command patterns or similar design patterns to manage the execution of different commands.

Additional Information

  • The current code relies on the BaseCommandHandler class as a template for individual command classes.
  • The common_code method contains common functionality executed before executing specific command code.
  • The specific_code method is intended to be overridden by derived classes for command-specific logic.

Implementation Guidance

To implement this modification, the following steps can be considered:

  1. Identify the common functionality shared among the existing command classes in the common_code method.
  2. Extract the common functionality to the CommandHandler class, keeping it as a separate method.
  3. Modify the CommandHandler class to handle different commands based on input parameters or message content.
  4. Refactor the codebase to remove the need for individual command classes.
  5. Implement appropriate design patterns or mechanisms to manage the execution of different commands within the CommandHandler class.
  6. Test the refactored code thoroughly to ensure it maintains the desired functionality of the original implementation.
  7. Update documentation and code comments to reflect the refactored code structure.

Please let me know if you need further assistance or clarification.

Implement Worker for Playlist Snapshot Comparison

Issue Description

Feature Request: Implement Worker for Playlist Snapshot Comparison

Problem Statement

The current code lacks a worker that compares the snapshot_id of playlists added to the notify_list table in the bot's database. This prevents the bot from automatically detecting changes in playlist snapshots and notifying users.

Proposed Solution

Implement a worker that runs periodically to check for differences in snapshot_id values. When a playlist's snapshot_id changes, the bot should send a notification to the user who added the playlist, including a clickable link to the playlist on Spotify.

Acceptance Criteria

  • Periodic worker to compare snapshot_id of playlists in notify_list table
  • Send notification to users when a playlist's snapshot_id changes
  • Notification message includes playlist name as clickable link to Spotify
  • Efficient implementation to avoid unnecessary resource consumption

Technical Considerations

  • Implement worker as a separate component or module
  • Use background task scheduler for periodic execution
  • Handle errors and resilience (network/database)
  • Utilize appropriate logging mechanisms

Additional Information

  • notify_list table stores playlists added by users
  • snapshot_id field in table stores playlist snapshot identifier
  • Users expect notifications for playlist snapshot changes

Implementation Guidance

  1. Modify code to store snapshot_id when adding playlists to notify_list table.
  2. Implement periodic worker to compare stored snapshot_id with current snapshot from Spotify API.
  3. Send notification to respective Telegram user when a difference is detected.
  4. Handle errors and log worker execution.

Please let me know if you need further assistance or clarification.

Implement Global Message Feature

Modification Request: Implement Global Message Feature

Problem Statement

The Python Telegram bot "Notify" currently lacks a feature to send a global message to all Telegram users whose user_id is stored in the "users" table of the SQLite3 database. This feature would be beneficial for efficiently broadcasting messages to all users in one go. Additionally, the bot lacks proper error and success logging, which hinders developers' visibility into message delivery status.

Proposed Solution

To address this issue, the following modifications need to be implemented:

  1. Create a new file in the "Notify" bot's codebase to handle the global message feature.
  2. Write logic in the new file to iterate through all the user_id values stored in the "users" table of the SQLite3 database.
  3. Send the global message to each user ID and log any errors encountered during the process.
  4. Implement success logging to notify developers about the number of users the message was successfully sent to.

Acceptance Criteria

The modifications should meet the following criteria:

  1. The new file should retrieve all user_id values from the "users" table of the SQLite3 database.
  2. If there are no user IDs found in the "users" table, an error message should be logged, indicating that there are no users to send the message to.
  3. The global message should be sent to each user ID obtained from the "users" table.
  4. After sending the message to all users, the script should terminate.
  5. For each successful message sent, a success message should be logged, indicating the number of users the message was sent to.
  6. If there are any errors encountered while sending the message to users, they should be logged with appropriate error messages.

Technical Considerations

Consider the following technical aspects while implementing the solution:

  1. Connect to the SQLite3 database and retrieve the user_id values from the "users" table.
  2. Use a loop to iterate through the retrieved user_id values and send the global message to each user.
  3. Implement error handling to log any exceptions or errors that occur during the process.
  4. Use appropriate logging mechanisms to log both errors and successes.
  5. Ensure the script terminates after sending the message to all users.

Implementation Guidance

To implement this modification, follow these steps:

  1. Create a new Python file in the "Notify" bot's codebase to handle the global message feature.
  2. Write code to establish a connection with the SQLite3 database and retrieve the user_id values from the "users" table.
  3. Implement error handling to check if there are no user IDs available in the "users" table and log an appropriate error message if necessary.
  4. Use a loop to iterate through the retrieved user_id values and send the global message to each user.
  5. Log successes and errors encountered during the process using appropriate logging mechanisms.
  6. Terminate the script after sending the message to all users.

Additional Information

  • The "Notify" bot is a Python-based Telegram bot that uses the Telegram Bot API for communication with users.
  • The SQLite3 database contains a table named "users" with a column named "user_id" to store Telegram user IDs.
  • The global message feature aims to send a message to all users whose user IDs are present in the "users" table.
  • Proper logging is crucial to provide developers with insights into the success and failure of the global message sending process.

Please feel free to ask for any further assistance or clarification.

Inconsistent Functionality for Sixth User Authorization

Issue: Inconsistent Functionality for Sixth User Authorization

Description

After the sixth user authorizes the bot to access their Spotify user data, they are only able to use a command once before encountering an error. Upon attempting to use the bot for the second time, it fails to work and displays an error message stating that the user is not registered in the Spotify developer settings for the app, even though the user is registered correctly.

Steps to Reproduce

  1. Install and set up the Notify bot from the GitHub repository.
  2. Authorize the bot to access your Spotify user data.
  3. Use the bot for the first time by executing a command (e.g., "play my favorite playlist").
  4. Verify that the command executes successfully and the desired action is performed.
  5. Attempt to use the bot for the second time by executing another command (e.g., "skip to the next track").
  6. Observe the error message stating that the user is not registered in the Spotify developer settings for the app, despite being registered correctly.

Expected Behavior

The Notify bot should allow the sixth user and subsequent users to use its commands multiple times after authorizing the bot to access their Spotify user data. The bot should not display an error message incorrectly claiming that the user is not registered in the Spotify developer settings.

Actual Behavior

After the sixth user authorizes the bot, they can only execute a command once. Any subsequent attempts to use the bot result in an error message stating that the user is not registered in the Spotify developer settings for the app, even though the user is correctly registered.

Additional Information

  • The issue occurs specifically for the sixth user and beyond. Users prior to the sixth authorization do not encounter this problem.
  • The error message is inconsistent with the user's actual registration status in the Spotify developer settings.
  • The Notify bot should provide uninterrupted functionality to all users who have authorized it to access their Spotify user data.

Reproducibility

  • This issue is reproducible consistently for the sixth user and subsequent users who authorize the bot.

Possible Solution

The issue could be related to the registration and authentication process between the Notify bot and the Spotify developer settings. It is recommended to review the authentication flow and ensure that the bot can correctly recognize users who have registered and authorized access to their Spotify user data.

Thank you for addressing this issue promptly. If any further information is needed, please let me know.

Add Error Handling and Logging Statements

Issue Description

Enhancement Request: Add Error Handling and Logging Statements

Problem Statement

The current code lacks proper error handling and logging statements, which can make it difficult to diagnose issues and track the execution flow of the bot. Additionally, there is a need to include print statements to provide initial startup and status messages for the bot.

Proposed Solution

To address this issue, we need to add appropriate try-except blocks for error handling and logging statements to track the execution flow. Additionally, we can include print statements to provide meaningful startup and status messages for the bot.

Acceptance Criteria

  • Implement try-except blocks to handle potential exceptions and errors.
  • Include logging statements to track the execution flow, error messages, and important events.
  • Add print statements to provide initial startup and status messages for the bot.
  • Ensure the logging mechanism is configurable and follows best practices for log levels and formatting.

Technical Considerations

  • Identify critical sections of the code where exceptions can occur and wrap them in try-except blocks.
  • Utilize appropriate logging mechanisms, such as the Python logging module, to log important information, warnings, and errors.
  • Determine the desired log levels (e.g., DEBUG, INFO, ERROR) for different types of messages.
  • Consider implementing a centralized logging approach to consolidate logs from multiple components of the bot.
  • Place print statements strategically to provide essential information during startup and status updates.

Additional Information

  • The current code lacks try-except blocks and logging statements.
  • Including print statements will help provide informative startup and status messages.

Implementation Guidance

To implement this enhancement, the following steps can be considered:

  1. Identify critical sections of the code where exceptions can occur.
  2. Wrap those sections in try-except blocks to catch and handle potential exceptions.
  3. Determine the appropriate logging mechanism for your bot, such as using the Python logging module.
  4. Introduce logging statements at key points in the code to track the execution flow and important events.
  5. Configure the logging mechanism to specify log levels, formatting, and log output destination (e.g., file, console).
  6. Add print statements strategically to provide informative startup and status messages for the bot.
  7. Test the code thoroughly to ensure proper error handling, logging functionality, and print statements.
  8. Update documentation and code comments to reflect the changes made for error handling, logging, and print statements.

Please let me know if you need any further assistance or clarification regarding this enhancement request.

/shownotifylist doesn't tell the user they don't have any playlists in their Notify list yet.

Issue Description

Problem Statement

Currently, the /shownotifylist command does not inform the user if they don't have any playlists in their Notify list on the first try of a fresh start of the bot. Even if no playlists have been added, the code does not display any message indicating an empty list.

Expected Behavior

When a user does not have any playlists in their Notify list, the code should inform them with an appropriate message.

Actual Behavior

The code does not notify the user if they have an empty Notify list on the first try.

Steps to Reproduce

  1. Run the bot for the first time without adding any playlists to the Notify list.
  2. Observe that no message is displayed indicating an empty Notify list.

Code Snippet

class ShowNotifyListCommandHandler(BaseCommandHandler):
    def specific_code(self, message, user_sp, chat_id, user_id):
        conn = sqlite3.connect(database)
        cursor = conn.cursor()

        user_id_in_db = cursor.execute(
            "SELECT user_id FROM notify_list WHERE user_id = ?", (user_id,)
        ).fetchone()

        if user_id_in_db is None:
            bot.send_message(
                chat_id, "You don't have any playlists in your Notify list yet."
            )

        else:
            user_playlists_name = cursor.execute(
                "SELECT playlist_name FROM notify_list WHERE user_id = ?", (user_id,)
            ).fetchall()
            user_playlists_name_arr = [result[0] for result in user_playlists_name]
            notify_list = "\n- ".join(user_playlists_name_arr)

            bot.send_message(
                chat_id, f"This is your Notify list right now: \n\n- {notify_list}"
            )

        cursor.close()
        conn.close()

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.