Back to Blog

Twitter Filter Rule Reference#

Twitter Filter uses a simple expression language to match tweets in your timeline. Each rule has a condition (expression) and an action (mark, hide, or block). This page is the complete reference for writing rules.

Actions#

Action Effect
mark Yellow border + reduced opacity, with a label showing the matched rule
hide Completely hides the tweet from the timeline
block Hides the tweet immediately and blocks the account after a configurable delay (default 3s). A toast notification appears with an Undo button to cancel before the block executes

Warning: The block action will block real accounts on your behalf. Use with caution. The delay + undo mechanism helps prevent accidental blocking.

Available Fields#

User fields#

Field Type Description
user.id string / null Numeric user ID
user.name string Display name
user.screen_name string Username / handle (without @)
user.description string / null Bio
user.location string / null User-defined location (free text, not GPS — users can write anything here)
user.url string / null Profile URL
user.avatar string / null Avatar image URL
user.default_profile boolean Has default profile (never customized banner)
user.default_profile_image boolean Has default profile image (egg avatar)
user.blue_verified boolean Paid blue checkmark
user.verified boolean Gray/gold verification badge
user.verified_type string / null e.g. "Business", "Government"
user.followers number / null Follower count
user.following number / null Following count
user.statuses_count number / null Total tweets posted
user.created_at string / null Account creation date (ISO format)

Relationship & privacy fields#

Field Type Description
user.protected boolean Account is protected (locked)
user.is_following boolean You follow this user
user.followed_by boolean This user follows you
user.blocking boolean You are blocking this user
user.blocked_by boolean This user is blocking you
user.muting boolean You are muting this user

Tweet fields#

Field Type Description
tweet.text string Tweet text content
tweet.is_reply boolean Is a reply
tweet.has_links boolean Contains links
tweet.has_media boolean Contains images/videos
tweet.lang string / null BCP 47 language code (e.g. "en", "ja", "zh"). Special values: "und" (undetermined), "zxx" (no linguistic content)
tweet.is_promoted boolean Whether this is a promoted (ad) tweet

Operators#

Operator Description
==, != Equality / inequality
<, >, <=, >= Numeric comparison
&&, || Logical AND / OR
! Logical NOT
+, -, *, / Arithmetic
contains Case-insensitive substring match
matches Regex match (Unicode mode — \p{...} property escapes supported, e.g. \p{Extended_Pictographic})

Built-in Functions#

Function Description
is_null(val) Check if value is null/undefined
len(val) String length (returns 0 for non-strings)
days_since(date) Days elapsed since an ISO date string (returns Infinity for invalid dates)
lower(val) Convert string to lowercase

Null Handling#

Some fields can be null (e.g. user.followers, user.description). Here's how null behaves:

  • Arithmetic (+, -, *, /): if either side is null, result is null
  • Comparison (<, >, <=, >=): if either side is null, result is false
  • Equality (==, !=): works normally — user.description == null returns true when bio is empty
  • String ops (contains, matches): return false if either side is not a string
  • Use is_null(val) to explicitly check for null values

Examples#

Keyword filtering#

Filter tweets or bios containing specific keywords:

tweet.text contains 'crypto' || user.description contains 'crypto'

Suspicious accounts#

Low follower ratio combined with a new account:

user.followers / user.following < 0.01 && days_since(user.created_at) < 30

Bot-like username pattern#

Usernames that are letters followed by 8 or more digits (e.g. sarah83927482):

user.screen_name matches '^[a-zA-Z]+\d{8,}$'

Default or missing avatar#

Catch accounts that never set a profile picture:

user.default_profile_image == true

Hide non-English tweets#

tweet.lang != 'en'

Hide blocked users that still appear in timeline#

user.blocking == true

Hide promoted (ad) tweets#

tweet.is_promoted == true

Hide tweets from users you're muting#

In case muted tweets leak through:

user.muting == true

Mark protected accounts that don't follow you#

user.protected == true && user.followed_by == false

Only show tweets from accounts you follow#

Hide everything from accounts you don't follow:

user.is_following == false

Emoji-only replies#

Catch replies that contain only emoji and whitespace (commonly used by spam bots):

tweet.is_reply && tweet.text matches '^(@\w+\s+)*[\p{Emoji}\p{Emoji_Component}\s]+$' && len(tweet.text) > 7 && user.followers < 50

Complex: new unverified account with spam keywords#

Combine multiple conditions:

days_since(user.created_at) < 7
  && user.blue_verified == false
  && (tweet.text contains 'free' && tweet.text contains 'mint')

Tips#

  • Whitelist: Your own tweets and tweets from users you follow are always skipped — they will never be matched by any rule.
  • Rule priority: When multiple rules match the same tweet, the most severe action wins (block > hide > mark).
  • Screen name lists: Each rule can also have a list of usernames that it matches against directly, without needing a condition expression.
  • Testing rules: Set the action to mark first — matched tweets get a yellow border so you can see exactly what's being caught. Once you're happy with the results, switch to hide or block.