Skip to content

Commit a0c709b

Browse files
committed
chore: update test coverage statistics in README and refactor message handlers
- Updated README with per-module test coverage percentages (99% overall, 310 tests, 100% pass rate) - Services: all at 100% coverage - Handlers: 5 at 100%, anti_spam at 98% - Database, Config, Constants: all at 100% - Refactored message handler filters in src/bot/main.py for precision: - guard_warning_topic: process all messages (filters.ALL) - handle_new_user_spam: process only group messages (filters.ChatType.GROUPS) - handle_message: filter group messages excluding commands, moved to group=1 priority
1 parent ffc0661 commit a0c709b

2 files changed

Lines changed: 12 additions & 11 deletions

File tree

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,15 +150,15 @@ uv run pytest -v
150150
### Test Coverage
151151

152152
The project maintains comprehensive test coverage:
153-
- **Coverage**: 99% across all modules (1,057 statements, 2 missed)
153+
- **Coverage**: 99% (1,057 statements, 2 missed)
154154
- **Tests**: 310 total
155155
- **Pass Rate**: 100% (310/310 passed)
156156
- **All modules**: 99% coverage including JobQueue scheduler integration, captcha verification, and anti-spam enforcement
157-
- Services: `bot_info.py`, `scheduler.py`, `user_checker.py`, `telegram_utils.py`, `captcha_recovery.py`
158-
- Handlers: `anti_spam.py`, `captcha.py`, `dm.py`, `message.py`, `topic_guard.py`, `verify.py`
159-
- Database: `service.py`, `models.py`
160-
- Config: `config.py`
161-
- Constants: `constants.py`
157+
- Services: `bot_info.py` (100%), `scheduler.py` (100%), `user_checker.py` (100%), `telegram_utils.py` (100%), `captcha_recovery.py` (100%)
158+
- Handlers: `anti_spam.py` (98%), `captcha.py` (100%), `dm.py` (100%), `message.py` (100%), `topic_guard.py` (100%), `verify.py` (100%)
159+
- Database: `service.py` (100%), `models.py` (100%)
160+
- Config: `config.py` (100%)
161+
- Constants: `constants.py` (100%)
162162

163163
All modules are fully unit tested with:
164164
- Mocked async dependencies (telegram bot API calls)

src/bot/main.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ def main() -> None:
166166
# messages in the warning topic before other handlers process them
167167
application.add_handler(
168168
MessageHandler(
169-
filters.ALL & ~filters.COMMAND,
169+
filters.ALL,
170170
guard_warning_topic,
171171
),
172172
group=-1,
@@ -223,7 +223,7 @@ def main() -> None:
223223
# Handler 8: New-user anti-spam handler - checks for forwards/links from users on probation
224224
application.add_handler(
225225
MessageHandler(
226-
filters.ALL & ~filters.COMMAND,
226+
filters.ChatType.GROUPS,
227227
handle_new_user_spam,
228228
)
229229
)
@@ -233,11 +233,12 @@ def main() -> None:
233233
# group and warns/restricts users with incomplete profiles
234234
application.add_handler(
235235
MessageHandler(
236-
filters.TEXT & ~filters.COMMAND,
236+
filters.ChatType.GROUPS & ~filters.COMMAND,
237237
handle_message,
238-
)
238+
),
239+
group=1,
239240
)
240-
logger.info("Registered handler: message_handler (group=0)")
241+
logger.info("Registered handler: message_handler (group=1)")
241242

242243
# Register auto-restriction job to run every 5 minutes
243244
if application.job_queue:

0 commit comments

Comments
 (0)