Difference between revisions of "Filters"

From Mibbit Wiki
Jump to: navigation, search
m
m (How to Use)
 
(12 intermediate revisions by 4 users not shown)
Line 1: Line 1:
Filters are a simple yet useful system to replace text. They can be applied to incoming or outgoing IRC chat.
+
{{notice|Main client and Premium Widgets Only}}
 +
 
 +
'''Filters''' are a simple yet useful system to replace (main client only) or block text. They can be applied to incoming or outgoing IRC chat.
 +
 
 +
==How to Use==
  
 
Just go to Prefs -> Filters and setup your own.
 
Just go to Prefs -> Filters and setup your own.
  
* REGEXP - This is a javascript regular expression to match against
+
{| border="1"
* Replacement - The text you want to replace with
+
|-
* In - If checked, it'll be applied to any incoming IRC chat
+
! Part !! What it does
* Out - If checked, it'll be applied to any outgoing IRC chat
+
|-
 +
| REGEXP || This is a javascript regular expression to match against
 +
|-
 +
| Replacement || The text you want to replace with (not available in premium widgets)
 +
|-
 +
| Command || Commands to send when REGEXP matches. <span style="color:red">Not in all releases yet (only in cbe00*).</span>
 +
|-
 +
| In || If checked, it'll be applied to any incoming IRC chat
 +
|-
 +
| Out || If checked, it'll be applied to any outgoing IRC chat
 +
|-
 +
| Block || If checked, do not send or show text.
 +
|}
  
 
Note that the filters are applied from first to last, only once.
 
Note that the filters are applied from first to last, only once.
Line 12: Line 28:
 
For the regular expression syntax, see https://developer.mozilla.org/En/Core_JavaScript_1.5_Guide/Regular_Expressions
 
For the regular expression syntax, see https://developer.mozilla.org/En/Core_JavaScript_1.5_Guide/Regular_Expressions
  
 +
If part of the regex is going to be in the replacement, place it in parenthesis, and call it by $<number> where the number is signified by which set of parenthesis it is.
 +
 +
==Possible Usages==
  
You could use this to:
+
For the main client:
* Replace irritating abbreviations
+
* Replace irritating abbreviations:
 
** BRB -> Be right back  
 
** BRB -> Be right back  
 
** i18n -> internationalization
 
** i18n -> internationalization
* Filter out offensive words
+
* Filter out offensive words:
 
** Damn -> by the beard of Zeus!
 
** Damn -> by the beard of Zeus!
* Store commonly used responses
+
* Store commonly used responses:
 
** tellWidget -> "The widget is a fantastic thing that you can find more info about here....."
 
** tellWidget -> "The widget is a fantastic thing that you can find more info about here....."
 +
* default:
 +
** \bmibbiturl\b -> http://www.mibbit.com/chat/  (\b = word boundary)
 +
* Use a matched text within the replaced string
 +
** \b([^ ]+)url\b -> http://www.$1.com -> mozillaurl -> http://www.mozilla.com
 +
 +
==Examples==
 +
 +
* <nowiki>^gn$</nowiki>
 +
**  Matches only if you send "gn".  Will not match " gn" or "gn " or "You have a gn".
 +
**  [Start of line][g][n][End of line]
 +
 +
[[Category:Preferences]][[Category:Features]][[Category:Main client]][[Category:Premium]]

Latest revision as of 10:23, 11 May 2011

Main client and Premium Widgets Only

Filters are a simple yet useful system to replace (main client only) or block text. They can be applied to incoming or outgoing IRC chat.

How to Use

Just go to Prefs -> Filters and setup your own.

Part What it does
REGEXP This is a javascript regular expression to match against
Replacement The text you want to replace with (not available in premium widgets)
Command Commands to send when REGEXP matches. Not in all releases yet (only in cbe00*).
In If checked, it'll be applied to any incoming IRC chat
Out If checked, it'll be applied to any outgoing IRC chat
Block If checked, do not send or show text.

Note that the filters are applied from first to last, only once.

For the regular expression syntax, see https://developer.mozilla.org/En/Core_JavaScript_1.5_Guide/Regular_Expressions

If part of the regex is going to be in the replacement, place it in parenthesis, and call it by $<number> where the number is signified by which set of parenthesis it is.

Possible Usages

For the main client:

  • Replace irritating abbreviations:
    • BRB -> Be right back
    • i18n -> internationalization
  • Filter out offensive words:
    • Damn -> by the beard of Zeus!
  • Store commonly used responses:
    • tellWidget -> "The widget is a fantastic thing that you can find more info about here....."
  • default:
  • Use a matched text within the replaced string

Examples

  • ^gn$
    • Matches only if you send "gn". Will not match " gn" or "gn " or "You have a gn".
    • [Start of line][g][n][End of line]