Tip of the day: Channel mode +f is a powerful anti-flood feature. It is also slightly complex. Enable it in your most important channels, and consider setting a default in set::modes-on-join.

Crule

From UnrealIRCd documentation wiki
Jump to navigation Jump to search

Since UnrealIRCd 6.1.2 we support spamfilter::rule, security-group::rule and mask::rule. They allow you to filter in a C like if-style, eg: rule "reputation()>20";.

Syntax

  • You can call functions which may have 0, 1 or more arguments. Eg reputation()
  • Supported comparison operators are: xx>yy, xx<yy and x==y
  • You can use && (AND) and || (OR) expressions to combine multiple checks
  • You can use ( and ) to group items
  • You can use ! to represent negation, eg !has_user_mode('x')

Functions

The following functions are supported:

  • online_time(): number of seconds the user is online
  • reputation(): the Reputation score of the user
  • tag('TAGNAME'): read the value of a tag set on the user with name TAGNAME. Tags are set by set in Actions (e.g. by spamfilter).
  • cap_version(): returns the CAP protocol used by the client, such as 300.
  • cap_set('capname'): returns true if the the client has requested the capname capability via CAP REQ.
  • is_away(): returns true if the client is currently away. Requires UnrealIRCd 6.1.5+
  • has_user_mode('x'): returns true if all the specified user modes are set on the client. Requires UnrealIRCd 6.1.5+
  • has_channel_mode('x'): for a spamfilter, the destination channel for a message: return true if this channel contains all the specified channel modes. Requires UnrealIRCd 6.1.5+
  • destination('#channel'): for a spamfilter, allows you to check the destination of the message (which can be a channel or a nick), wildcards are supported.
  • inchannel('#channel'): returns true if user is a member of this channel. It is IMPORTANT not to confuse this with destination() in spamfilters! Optionally channel member flags are supported, eg inchannel('@#has_ops_here').

Examples

Simple comparisson

This rule will match if the Reputation score of the user is more than 20:

rule "reputation()>20";

And/Or

You can combine things with an AND operator and OR, and group them:

rule "!inchannel('#main') && (online_time()<180 || reputation()<50)";

This rule will match when:

  • User is not in the channel #main, AND
  • Either the online time is less than 180 seconds OR the Reputation score is less than 50