From 4d25d2e83c9d41f13fb10d2abe70836f14c58e03 Mon Sep 17 00:00:00 2001 From: Maxim Slipenko Date: Sat, 22 Feb 2025 18:01:22 +0300 Subject: [PATCH] fix: add caption handle --- src/karkas_blocks/karkas_blocks/standard/spam/main.py | 8 +++++--- .../karkas_blocks/standard/statistics/main.py | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/karkas_blocks/karkas_blocks/standard/spam/main.py b/src/karkas_blocks/karkas_blocks/standard/spam/main.py index 7120ed6..edfcdf5 100644 --- a/src/karkas_blocks/karkas_blocks/standard/spam/main.py +++ b/src/karkas_blocks/karkas_blocks/standard/spam/main.py @@ -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", diff --git a/src/karkas_blocks/karkas_blocks/standard/statistics/main.py b/src/karkas_blocks/karkas_blocks/standard/statistics/main.py index afd3ba7..76df22f 100644 --- a/src/karkas_blocks/karkas_blocks/standard/statistics/main.py +++ b/src/karkas_blocks/karkas_blocks/standard/statistics/main.py @@ -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