Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Global Message Feature #11

Open
rafacovez opened this issue Jun 20, 2023 · 0 comments
Open

Implement Global Message Feature #11

rafacovez opened this issue Jun 20, 2023 · 0 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@rafacovez
Copy link
Owner

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.

@rafacovez rafacovez added enhancement New feature or request good first issue Good for newcomers labels Jun 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant