Request limit#19
Merged
Merged
Conversation
This commit introduces rate limiting to the linebot to prevent abuse and ensure fair usage. - Added a new `redis_client.py` to manage the Redis connection. - Added a `RateLimiter` class in `rate_limiter.py` to handle rate limiting logic using Redis. - Modified `text_handler.py` to integrate the `RateLimiter`. - Implemented a check to determine if a user has exceeded their request limit. - If the limit is exceeded, a message is sent to the user informing them of the rate limit and the time remaining until they can make another request. - Added `flex_message.py` to convert flex message to json. - Added `__init__.py` to export the utils. - Added `redis` to `pyproject.toml`. - Added `*.rdb` to `.gitignore`.
This commit introduces Redis integration for rate limiting in the Line Bot application. It includes the following changes: - Added Redis configuration parameters (REDIS_HOST, REDIS_PORT, REDIS_DB) to the .env.example file. - Updated the README.md file to include instructions for installing sqlite3 and redis. - Modified the redis_client.py file to read Redis configuration from environment variables, allowing for flexible deployment. The addition of Redis enables the implementation of robust rate limiting mechanisms, preventing abuse and ensuring the stability of the Line Bot service.
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.
Add rate limiting to prevent excessive Dify API usage