Alias / Spellchecker / Filter / Ignore / Slash : Add-on for World of Warcraft

Zip for Alias / Spellchecker / Filter / Ignore / Slash  addon to use with World of Warcraft
-- Updated Dec. 11, '11
Interface: 40300
Purpose
ASF: stands for ASF: stands for ASF: stands for ASF: stands for ASF: stands for ASF: stands for

Formerly known as Alias-Spellchecker. Now it's simply Alias-Spellchecker-Filter (aka ASF).

There are five components that make up this add-on: Alias, Spellchecker, Filter, Ignore, Slash.

1) The alias component lets you replace text with shortcuts that start with semicolon ';'.
For example, you can set a shortcut to send your main toon's name without retyping the whole thing every time you want to talk to your guild.
Ex: you can assign ;g to say /g <MyName>.
Go to alias section.

Alias replacements can call functions and execute scripts by enclosing with [[ and ]].
Ex: /alias ;pl [[ UnitLevel('player') ]]

You can also edit and create aliases in the alias frame. Open alias frame from minimap button (icon is papers with wax seal). You can also assign a keybinding for this.

Right-click an alias in alias frame to execute it. Shift-click or double-click to add to chat edit box.

In addition, it replaces %t with the target's name if you have a target in sight. Now you can send tells to your target without any fuss. You can turn this on or off by /aliastarget 1 or /aliastarget 0, respectively.

2) You can use this add-on as a spellchecker, and you can add words to the list of words to check.
Ex. /sp teh the
Go to spellchecker section.

3) Filter out incoming chat.
Ex. /filter crap stuff
Go to filter section.

4) Ignore chat based on message content or sender.
Ex. /ign msg www
Ex. /ign user aquendyn
Go to ignore section.

5) Create custom slash commands.
Ex. /slash loc print(GetPlayerMapPosition("player"))
/loc
Ex. /slash name return function(msg) print(UnitName(msg)) end
/name target
Go to slash section.

Each of these components can be turned on or off separately.
Go to toggles section.

Import default aliases with /aliasimport. May overwrite your current setup.
Index of default aliases and latest default.lua.

There are some bindings enclosed in Bindings.xml. You can find these in your keybindings options. One to open chat with semicolon (;), and one to open alias frame. Also, some example bindings to send aliases from which you can copy for your own bindings.
Installation
Unzip the files into <WoW>\Interface\AddOns folder. The new folder is called Alias. The add-on shows up as Alias-Spellchecker-Filter ingame.

Aliases

Slash commands help
[;] means semicolon ; is optional
<alias> means the alias you want to use
<replacement> means the actual text you want to send
surround <replacement> with [[ and ]] if using functions
To set an alias
/alias [;]<alias> <replacement>
Ex: /alias ;t %t
Ex. /alias ;target [[ UnitName('target') ]]
To remove an alias
/aliasremove [;]<alias>
/aliasr ...
/arem ...
Ex: /aliasr ;t
To list an alias
/aliaslist [;]<alias>
/aliasl ...
/alist ...
Ex: /aliasl ;t
To list all aliases
(Aliases are listed alphabetically)

/aliaslist, /aliasl, /alist
Ex: /aliasl
to bring up help
/alias
/aliashelp
Turn on or off alias component
/aliason
/aliasoff
How To Use Aliases
Suppose ;m is /dance. Open up chat edit by pressing Enter, then type ;m.
The alias ;m will be changed to /dance, which will be the final text sent to the chat.

Use only letters and numbers for alias names (not counting leading semicolon).
Ex. /alias a this is ok
Ex. /alias ;a this is equivalent to above

Ex. /alias . this is not ok
Ex. /alias ;. still not ok

[Obsolete warning:] Symbols not to use: % ^ ( ) [ space
[You are still not allowed to use these symbols. You can use only letters and numbers.]

Be careful with nested aliases (aliases inside another). Try to keep them simple.
Avoid circular aliases, that is, self-referencing or cyclic.
For example, you shouldn't do /alias ;t ;t. Nor
/alias ;t ;r
/alias ;r ;t
Otherwise, the program may (read: will very likely) go into an infinite loop and cause stack overflow or hang the app.

Functions in aliases
Alias can retrieve return values from function calls. Replacement may be a simple function call or newly defined function enclosed by [[ and ]]. They may also contain other aliases (see ;title example below). Make sure your script has no errors.

Ex. /alias ;target [[ UnitName('target') ]]
Ex. /alias ;loc [[ function() local px, py= GetPlayerMapPosition( 'player' ) return string.format( '(%s, %s) %s', floor(px * 100 + 0.5), floor(py * 100 + 0.5), GetZoneText() ) end ]]
Examples
The following aliases are built-in, but they can be replaced:
;a is /alias
;alist is /aliasl
;arem is /aliasr
;ding is Ding! level ;pl
;grats is Congratulations! Keep up the good work.
;lfg is Level ;pl ;pr ;pc looking for group. Please send tell
;m is /dance
;sp is /sp
;splist is /splist
;sprem is /spremove
;t is %t
;tt is /t ;t
;ty is thank you
;x is /s Good ;day ;target

Aliases using functions:
;target is [[ UnitName('target') ]]
;tl is [[ UnitLevel('target') ]]
;pl is [[ UnitLevel('player') ]]
;me is [[ UnitName('player') ]]
;sex is [[ function() if UnitSex('target')==0 then return 'male' elseif UnitSex('target')==1 then return 'female' else return 'it' end end ]]
;title is [[ function() if (';sex'=='male') then return 'Mr.' elseif (';sex'=='female') then return 'Ms.' else return 'Lil' end end ]]
;tc is [[ UnitClass('target') ]]
;pc is [[ UnitClass('player') ]]

Other aliases I use:
;b is /bow
;w is /wave
;y is /follow
;loc shows current location

Spellchecker

Slash commands help
<wrong> means the wrong spelling
<right> means the right spelling
<word> means the word you want to remove or to list
to add word to list
/sp <wrong> <right>
/spellcheck ...
Ex: /sp teh the
to remove word from list
/spremove <word>
Ex: /spremove teh
to list a word
/splist <word>
Ex: /splist teh
to list all words
(Words are listed alphabetically.)

/splist
Ex: /splist
to bring up help
/sp
/sphelp
Turn on or off spellchecker component
/spellon
/spelloff
How To Use Spellchecker
Suppose rouge is rogue. Open up chat edit by pressing Enter, then type rouge.
The word will change to rogue, which will be the final text sent to the chat.

Spellchecker checks for whole words. This means you would have to make a separate entry for plurals. For instance, you would have to do both /sp cta cat and /sp ctas cats.
Examples
The following words are built-in, but they can be replaced:
Rouge is Rogue
Rouges is Rogues
fro is for
hepl is help
ne1 is anyone
rouge is rogue
rouges is rogues
teh is the

Filtering Chat

Slash commands help
<wrong> means the wrong spelling
<right> means the right spelling
<word> means the word you want to remove or to list
To add word to list
/filter <wrong> <right>
Ex: /filter teh the
To remove word from list
/filterremove <word>
/filterr <word>
Ex: /filterr teh
To list a word
/filterlist <word>
/filterl <word>
Ex: /filterl teh
To list all words
(Words are listed alphabetically.)

/filterlist
/filterl
Ex: /filterl
To bring up help
/filter
/filterhelp
Turn on or off filter component
/filteron
/filteroff
How To Use Filter
Whenever an incoming message has a filtered word, it will be altered to the word or phrase of your preference.

Filter checks for whole words. This means you would have to make a separate entry for plurals. For instance, you would have to do both /filter cta cat and /filter ctas cats.

The filter list starts out empty, but you can add words to it.

Ignore Chat by Sender or Message Content

Slash commands help
To add message to list
/ign msg <content>
Ex: /ign msg www
Ex: /ign msg .com
To add user to list
/ign user <name>
Ex: /ign user aquendyn
Ex: /ign user legolas
To remove message from list
/ignremove msg <message>
/ignr msg <message>
Ex: /ignr msg www
Ex: /ignremove msg .com
To remove a user from list
/ignremove user <user>
/ignr user <user>
Ex: /ignr user aquendyn
Ex: /ignremove user legolas
To list all entries on the ignore chat list
/ignlist
/ignl
Ex: /ignl

It will display the list in a tree-like fashion, like this:
List of ignored messages and users:
	ROOT {
		www {
			[msg] => 1
		}
		.com {
			[msg] => 1
		}
		headbut {
			[msg => 1
			[user] => 1
		}
	}

According to this example, any message that contains www, .com, or headbut will be ignored. Any messages sent by the user named Headbut will also be ignored.
To bring up help
/ign
/ignhelp
Turn on or off ignore component
/ignon
/ignoff
How To Use Ignore
If an incoming includes an ignored phrase or if it comes from an ignored sender, the entire message will be ignored and won't appear in your chat frame. It is case insensitive. So if www is on the list, then any messages that include www or WWW or any combination of lower and upper cases will be ignored in entirety. I created this to ignore mainly spam by gold sellers that put up their web addresses.

The ignore chat list starts out with two entries, but you can add messages or users to it.

Creating Slash Commands

Slash commands help
To add command to list
/slash <command> <script>
Ex. /slash loc print(GetPlayerMapPosition("player"))
To remove command from list
/slashremove <command>
/slashr <command>
Ex: /slashr loc
To list a command
/slashlist <command>
/slashl <command>
Ex: /slashl loc
To list all commands
(Commands are listed alphabetically.)

/slashlist
/slashl
Ex: /slashl
To bring up help
/slash
/slashhelp
How To Create and Use Slash Commands
There are two ways to write the scripts for custom slash commands, depending on whether you need parameters or not.

1) If you don't need to pass parameters, then just write the script as if you were writing a macro under /script.
Ex. /slash loc print(GetPlayerMapPosition("player"))
Usage:
/loc

2) If you need to work with parameters, then surround your script with the following text:
return function(msg)
-- do something with msg
end
Ex. /slash name return function(msg) print(UnitName(msg)) end
Usage:
/name target
/name player
/name pet
/name mouseover
etc.

Other Slash Commands

Import default aliases
/aliasimport

Replace %t with target or no
/aliastarget 1 or 0

Turn off alias replacement
/aliasoff

Turn on alias replacement
/aliason

Turn off spellchecker
/spelloff

Turn on spellchecker
/spellon

Turn off filter
/filteroff

Turn on filter
/filteron

Turn off ignore
/ignoff

Turn on ignore
/ignon

VERSION HISTORY

TODO
localize strings
confirm import default aliases

4030
updated toc to 40300
double-click alias in alias frame to add it to chat frame

1923
updated toc to 20300
replaced function delimiters from %F and %f to [[ and ]]  (where %f is for focus in default UI) (do Import Defaults)
capped button text size to 285 px (else, overflow frame)
modified default ignore list, taking into account regexp patterns

1900
can create slash commands

1890
removed hyperlink targeting
added ignore chat based on message or sender
added default ignored chat messages (www and .com)
added IgnoreChatList to SavedVariables
changed AliasSpellcheckOptions to ASFOptions in alias.toc

1880
update toc 20000
remove hook ChatFrame_ParseText
replaced chat functions ChatFrame_SendTell, ChatEdit_OnUpdate, ChatEdit_OnEnterPressed, ChatEdit_OnSpacePressed, ChatEdit_OnTextSet

1870
if aliastarget is enabled and you have no target, then %t will be erased
now also replaces %T

1860
new default aliases: yw, np, bye, cya, fil, fillist, filrem
shift-click on alias in alias frame to add it to chat edit. will open chat edit if not open.
SendAlias for use in bindings and macros. usage: SendAlias(msg) where msg may include aliases
ex. SendAlias(";x")
ex. SendAlias(";np ;t")
ex. SendAlias("what a beautiful ;day")
2 new bindings for hello and bye

1850
optimized AliasRunScript

1840
bindings to open chat with ; and to open alias frame
fixed frame update for 1.9

1830
Alias frame to create, modify, and delete aliases

1820
more default aliases
player links

1810
fixed Sky incompatibility
more default aliases
can import default aliases with /aliasimport

1800
alias can contain script
compatible with Sea
filter incoming chat
new slash commands to turn on/off components

4150
spellchecker capability

4114?
%t replaced by target's name (optional)

1?
alias capability