mirror of
https://github.com/agessaman/meshcore-bot.git
synced 2026-06-04 23:01:19 +00:00
feat: Implement per-user rate limiting for bot responses
- Added per-user rate limiting functionality to control the minimum time between bot replies to the same user, identified by public key or sender name. - Updated configuration files to include `per_user_rate_limit_seconds` and `per_user_rate_limit_enabled` options for enabling and configuring this feature. - Enhanced the command manager and message handler to support per-user rate limiting, ensuring efficient message handling and reduced spam. - Updated documentation to reflect the new rate limiting options and their usage.
This commit is contained in:
@@ -2895,10 +2895,15 @@ class MessageHandler:
|
||||
|
||||
# Send response (pass command_id so transmission record uses it directly)
|
||||
try:
|
||||
rate_limit_key = self.bot.command_manager.get_rate_limit_key(message)
|
||||
if message.is_dm:
|
||||
success = await self.bot.command_manager.send_dm(message.sender_id, response, command_id)
|
||||
success = await self.bot.command_manager.send_dm(
|
||||
message.sender_id, response, command_id, rate_limit_key=rate_limit_key
|
||||
)
|
||||
else:
|
||||
success = await self.bot.command_manager.send_channel_message(message.channel, response, command_id)
|
||||
success = await self.bot.command_manager.send_channel_message(
|
||||
message.channel, response, command_id, rate_limit_key=rate_limit_key
|
||||
)
|
||||
|
||||
if not success:
|
||||
self.logger.warning(f"Failed to send keyword response for '{keyword}' to {message.sender_id if message.is_dm else message.channel}")
|
||||
|
||||
Reference in New Issue
Block a user