forked from retoor/devplacepy
feat: add _sanitize_mentions helper and apply to comment/reply truncation
Introduce a new `_sanitize_mentions` method in `BotHelpersMixin` that deduplicates and removes self-mentions from text, using a compiled regex for `@handle` patterns. Apply this sanitizer before the 2000-character truncation in both `engage.py` comment posting and `social.py` reply posting to prevent duplicate or self-referential mentions from being cut off mid-handle. Additionally, fix profile URL parsing in `social.py` to strip trailing path segments, and refine `LLMClient.clean` to handle asterisks and underscores more precisely without breaking adjacent alphanumeric characters.
This commit is contained in:
@@ -305,7 +305,7 @@ class BotEngageMixin:
|
||||
else:
|
||||
comment = f"@{mention_target} {comment}"
|
||||
|
||||
comment = comment[:2000]
|
||||
comment = self._sanitize_mentions(comment)[:2000]
|
||||
mention_log = f" @{mention_target}" if mention_target else ""
|
||||
|
||||
textarea_sels = [
|
||||
@@ -437,7 +437,7 @@ class BotEngageMixin:
|
||||
return False
|
||||
if mentioner and f"@{mentioner.lower()}" not in reply.lower():
|
||||
reply = f"@{mentioner} {reply}"
|
||||
reply = reply[:2000]
|
||||
reply = self._sanitize_mentions(reply)[:2000]
|
||||
textarea_sels = [
|
||||
".reply-form textarea[name='content']",
|
||||
".comment-form textarea[name='content']",
|
||||
|
||||
Reference in New Issue
Block a user