fix: add caption handle

This commit is contained in:
Maxim Slipenko 2025-02-22 18:01:22 +03:00
parent 7c25c7b4a9
commit 4d25d2e83c
No known key found for this signature in database
GPG Key ID: 6DEA9FA7DE98C7D6
2 changed files with 6 additions and 4 deletions

View File

@ -133,7 +133,9 @@ class SpamDetectionMiddleware(BaseMiddleware):
event: "Message",
data: Dict[str, Any],
) -> Any:
if USER_STATS_AVAILABLE and event.text:
text = event.text or event.caption
if USER_STATS_AVAILABLE and text:
stats = await get_user_stats(event.chat.id, event.from_user.id)
verified_users_row = (
@ -146,8 +148,8 @@ class SpamDetectionMiddleware(BaseMiddleware):
if verified_users_row:
if not verified_users_row["verified"]:
if event.text:
is_spam, confidence = spam_predict(event.text)
if text:
is_spam, confidence = spam_predict(text)
log(
"message spam confidence",

View File

@ -79,7 +79,7 @@ class StatisticsMiddleware(BaseMiddleware):
"new message recieved",
trace_id=trace_id,
chat_id=event.chat.id,
message_text=event.text,
message_text=event.text or event.caption,
)
data["trace_id"] = trace_id