Mole9000/speech input#11
Closed
yenslife wants to merge 15 commits into
Closed
Conversation
This commit introduces a significant refactoring of the message handling logic in the Line Bot application. The core changes involve: - Creation of handler modules: New modules for handling text, image, and audio messages have been created under the `linebot/app/services/ handlers/` directory. These modules encapsulate the specific logic for processing each type of message. - Common utilities module: A `common.py` module has been added to provide shared functions and constants used across different handler modules, such as creating quick reply buttons and sending messages. - Message service update: The `MessageService` class has been updated to delegate message handling to the appropriate handler module. This simplifies the `MessageService` class and makes it more maintainable. - Webhook handler update: The webhook handlers in `webhooks/handlers.py` have been updated to use the `MessageService` to handle messages. - API Compatibility: The `MessageService` class is kept as a wrapper to maintain compatibility with the old API. These changes improve the modularity, readability, and maintainability of the codebase. By separating the message handling logic into dedicated modules, it becomes easier to add new message types and modify existing ones. The use of a common utilities module promotes code reuse and reduces redundancy.
This commit introduces a centralized logging system. A new module `linebot/app/config/logger.py` is created to configure and provide logger instances. The logging configuration includes: - Log formatting with timestamp, logger name, level, and message. - Console output with configurable log level. - File output with rotating file handler (max 10MB, 5 backups). - A global `app_logger` instance for general application logging. The existing `print` statements in `linebot/app/api/vision.py` and `linebot/app/routers/linebot.py` are replaced with calls to the new logging system. This allows for better control and management of application logs. Additionally, the `.gitignore` file is updated to ignore the `logs/` directory, preventing log files from being committed to the repository.
This commit introduces the ability to handle postback events, specifically for terms and conditions acceptance/rejection. - Added `PostbackService` to manage postback event logic. - Created `handle_postback_event` in `services/handlers/postback.py` to process different postback data values. - Registered `PostbackEvent` handler in `linebot.py` to route events to the `PostbackService`. - Added `show_loading_animation` before handling the postback event. - Added `send_message` to send the reply messages to the user. - Created a new file `linebot/flex_messages/welcome/terms.json` (empty file, to be populated later with the flex message for terms and conditions). This allows the bot to respond to user interactions with buttons related to accepting or rejecting terms and conditions.
This commit introduces a welcome flow for new users, including: - Terms of service agreement with accept/reject options. - Language selection (Traditional Chinese/English). - Role selection (Faculty/Student/Visitor). - Welcome messages tailored to the selected role. - Quick reply buttons for help and settings. The implementation involves: - Adding new flex messages for terms, language, and role selection. - Updating the postback handler to process the new postback data. - Adding a utility function to convert flex message JSON files to Python objects. - Adding a constant for default message after setting up. - Adding a quickreply function to create quickreply buttons. - Adding error handling for sending messages to LINE. - Adding logging for messages sent to LINE. These changes enhance the user experience by providing a guided onboarding process and personalized welcome messages.
7adb7dc to
9876f3c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.