Skip to main content
The networkfilter module provides functionality for banning users, ignoring users, and filtering by IP address or country.

NetworkFilter Class

Manages user and IP-based filtering.

Attributes

dict
Pending IP ban requests
dict
Pending IP ignore requests

Methods

ban_user()

Bans a user by username.
str
Username to ban

unban_user()

Unbans a previously banned user.
str
Username to unban

is_user_banned()

Checks if a user is banned.
str
Username to check
bool
True if user is banned

ban_user_ip()

Bans a user by IP address.
str
Username (IP will be looked up if not provided)
str
IP address to ban directly
str
The banned IP address

is_user_ip_banned()

Checks if a user’s IP is banned, including wildcard matching.
str
Username to check
str
IP address to check
bool
True if IP is banned

ignore_user()

Ignores a user (hides their messages).
str
Username to ignore

unignore_user()

Unignores a previously ignored user.
str
Username to unignore

is_user_ignored()

Checks if a user is ignored.
str
Username to check
bool
True if user is ignored

IP Address Utilities

get_country_code()

Determines the country code for an IP address.
str
IP address to lookup
str
Two-letter country code (e.g., “US”, “GB”, “DE”)

is_ip_address()

Validates whether a string is a valid IPv4 address.
str
String to validate
bool
default:true
Whether to accept “0.0.0.0”
bool
default:true
Whether to accept wildcards like “192.168..”
bool
True if valid IP address

Country Codes

The COUNTRIES dictionary maps ISO country codes to country names.

IP Wildcards

IP banning and ignoring supports wildcard patterns:
  • 192.168.1.* - Matches all IPs in 192.168.1.0/24 subnet
  • 10.*.*.* - Matches all IPs in 10.0.0.0/8 subnet
  • 172.16.*.5 - Matches specific IPs across subnets

Configuration Integration

Filtered users are persisted in the configuration:
Changes to ban and ignore lists are automatically persisted to the configuration file.