Skip to content

Conversation

@kotopyos
Copy link

@kotopyos kotopyos commented Dec 31, 2025

Fixes: #1532

Description

Original enhancement request is to add custom message in case of violation Locality. I moved handling input, locality and privacy violations to separate protected methods so they can be overriden

Changes

  1. BaseAbilityBot:
    • Refactored checkInput, checkLocality, and checkPrivacy to delegate error handling to new protected methods instead of hardcoded logic.
    • Added protected void onInputViolation(Update, Ability) to customize reaction to invalid arguments
    • Added protected void onLocalityViolation(Update, Ability) to customize reaction to locality violations (e.g. Group vs Private).
    • Added protected void onPrivacyViolation(Update, Ability) to customize reaction to insufficient permissions.

Example usage

Developer can now override protected hooks to customize behavior:

@Override
protected void onLocalityViolation(Update update, Ability ability) {
    // Send custom message or silent ignore or ban the punk idk
    silent.send("Custom error message", getChatId(update));
}

Issue #1532

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant