This site is deprecated; docs have moved to!

Difference between revisions of "Modules/filter pcre"

From the makers of InspIRCd.
Jump to: navigation, search
(stats s)
Line 43: Line 43:
*Ensure you have all required dependencies installed
*Ensure you have all required dependencies installed
*Copy the module .cpp file from src/modules/extra to src/modules
*Copy the module .cpp file from src/modules/extra to src/modules
*Re-run ./configure with the update switch to detect the new module:
*Re-run ./configure with the modupdate switch to detect the new module:
[[email protected]:inspircd]$ ./configure -update
[[email protected]:inspircd]$ ./configure -modupdate
Configuring default values...
Configuring default values...
Writing Makefile
Writing Makefile

Revision as of 02:49, 13 August 2007

filter pcre module (filter pcre version)

Current Future
2.0 Documentation 3.0 Documentation
Return to the filter pcre Module List
Allows filtering of text from private and channel messages and notices, part messages and quit messages, for abuse prevention and realtime blocking of viruses and worms.
Configuration Tags
To use this module you should add the following tag to your Configuration file:
<include file="filter.conf">

You should then create a filter.conf file, which contains filter entries. The filter.conf is a standard styled config file, containing tags formatted like the one below:

<keyword pattern="^querty$" reason="You qwertied!" action="gline" flags="pn" duration="1h6s">

The patterns used are perl compatible Regular Expressions which match against any PRIVMSG, PART, QUIT or NOTICE command. The action variable can be one of three values:

  • kill - Disconnects the user if they match the pattern, giving the value of 'reason' as the quit reason. When the 'kill' type is matched in a QUIT message, this acts identically to 'block', as there is little point in sending a KILL for a user who is quitting anyway.
  • block - Blocks the whole line and informs all opers with +s that the line was blocked, and who sent it, along with the reason text. In the case of PART and QUIT messages, a reason matching a block is replaced with 'Reason filtered', as it is not possible to block the whole line without desynching clients.
  • none - Do nothing except log the match. This is the default if the action variable is omitted from the tag.
  • gline - Set a gline on the user's IP address, lasting for 'duration' minutes, or permenant if the duration is omitted from the tag.
  • silent - This blocks the line only, and informs the user their message was blocked, but does not notify opers.

See below for a definition of the flags which can be used in the flags field.

NOTE: From 1.1 b5 onwards, you don't have to seperate out your filter definitions into a seperate file like this, although it keeps things tidy and is still recommended.

This module does not implement any extra user or channel modes.
Extended Bans (Extbans)
This module implements no extended bans.
/FILTER <filter-definition> [<action> <flags> [<gline-duration>] :<reason>]

This command will add a filter when more than one parameter is given, using the specified filter definition, action, gline duration (when the type is 'gline') and reason. When only one parameter is provided (the filter pattern) the provided filter will be removed. Note that if you remove a configuration-defined filter, it will re-appear at next rehash unless it is also removed from the config file.


The flags field is used to indicate what the filter affects:

  • p - Block private and channel messages
  • n - Block private and channel notices
  • P - Block part messages
  • q - Block quit messages
  • o - Don't match against opers
  • * - Represents all of the above flags
  • - - Does nothing, a non-op for when you do not want to specify any flags

Listing Filters

The following command will generate a list of all filters set on the server specified(optional)

/stats s [servername]
Special Notes
Please note that regular expressions are very resource intensive. Having a lot of regular expressions or a lot of users can impede performance. If performance is an issue and the matching patterns are not complex, please consider our lightweight m_filter module instead.

This module is an 'extra' module. This means that by default it is not compiled when you type make to build your IRCd. To build this module, follow these three steps:

  • Ensure you have all required dependencies installed
  • Copy the module .cpp file from src/modules/extra to src/modules
  • Re-run ./configure with the modupdate switch to detect the new module:
[[email protected]:inspircd]$ ./configure -modupdate
Configuring default values...
Writing Makefile
Writing inspircd
Writing src/modules/Makefile
*PCRE - The Perl Compatible Regexp Library
This module may not be used at the same time as