Skip to content

Commit afd3fe8

Browse files
Update v1.1.6
🚀 New Features - Rate Limiting - Implemented a rate-limiting mechanism to control the number of messages sent in a short period, ensuring the bot does not exceed the set message limits in high-traffic channels. The bot now limits sending up to 5 messages per second, avoiding spamming and reducing the likelihood of triggering rate limits. - Private Settings Command - Modified the /settings command so that the bot now displays settings only to the user who invoked the command, using the ephemeral message feature. This ensures a private configuration experience. - Prevent Link Conversion with <> - Added support for users to enclose a link in angle brackets < > to prevent the bot from converting it. This gives users more control over which links are converted and which are left as-is. 🐞 Bug Fixes - Error Handling for Status Changes - Improved error handling for status updates, ensuring that failed status changes due to Discord API issues (like HTTPException) are logged and do not crash the bot. 🔧 Enhancements - Reddit Link Handling with vxReddit - Updated Reddit links to use vxReddit instead of rxddit. This enhances the display of videos and better supports additional Reddit features like listing stats, improving user experience when sharing Reddit content. - Performance Improvement - Used a deque for efficient management of the rate-limiting timestamps, allowing better memory management and faster operations when handling a high volume of messages. 📝 Documentation - Update Credits - Corrected the mention of vxReddit in the credits list to reflect the improved integration for handling Reddit links.
1 parent d140766 commit afd3fe8

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

main.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -588,12 +588,20 @@ async def on_message(message):
588588

589589
if channel_states.get(message.channel.id, True):
590590
try:
591+
# Standard link pattern to capture all the relevant links
591592
link_pattern = r"https?://(?:www\.)?(twitter\.com/\w+/status/\d+|x\.com/\w+/status/\d+|tiktok\.com/@[^/]+/video/\d+|tiktok\.com/t/\w+|instagram\.com/(?:p|reel)/[\w-]+|reddit\.com/r/\w+/s/\w+|reddit\.com/r/\w+/comments/\w+/\w+|old\.reddit\.com/r/\w+/comments/\w+/\w+|pixiv\.net/(?:en/)?artworks/\d+|vm\.tiktok\.com/\w+|threads\.net/@[^/]+/post/[\w-]+|bsky\.app/profile/[^/]+/post/[\w-]+)"
592593
matches = re.findall(link_pattern, message.content)
593594

595+
# Regex pattern to detect links surrounded by < >
596+
surrounded_link_pattern = r"<https?://(?:www\.)?(twitter\.com/\w+/status/\d+|x\.com/\w+/status/\d+|tiktok\.com/@[^/]+/video/\d+|tiktok\.com/t/\w+|instagram\.com/(?:p|reel)/[\w-]+|reddit\.com/r/\w+/s/\w+|reddit\.com/r/\w+/comments/\w+/\w+|old\.reddit\.com/r/\w+/comments/\w+/\w+|pixiv\.net/(?:en/)?artworks/\d+|vm\.tiktok\.com/\w+|threads\.net/@[^/]+/post/[\w-]+|bsky\.app/profile/[^/]+/post/[\w-]+)>"
597+
594598
valid_link_found = False
595599

596600
for original_link in matches:
601+
# Skip links if they are surrounded by < >
602+
if re.search(surrounded_link_pattern, message.content):
603+
continue # Skip processing this link
604+
597605
display_text = ""
598606
modified_link = original_link
599607
service = ""

0 commit comments

Comments
 (0)