From the makers of InspIRCd.
Jump to: navigation, search

alias module (2.0 version)

Current Future
2.0 Documentation 3.0 Documentation
Return to the 2.0 Module List
The alias module adds support for aliases and custom fantasy commands, which allow you to -for example- create a command which will message a service when typed.
Configuration Tags
In InspIRCd 2.x, this module is more advanced than its previous counterparts. You may add alias definitions to your configuration file, as follows:
<alias text="NICKSERV" replace="PRIVMSG Nickserv :$2-"
format="*" requires="NickServ" uline="yes" operonly="no" matchcase="no">
  • The text value contains the command name which the alias provides. Cant contain spaces, but case insensitive. You may have multiple aliases with the same command name (text="" value), however the first found will be executed if its format value is matched, or it has no format value. Aliases are read from the top of the file to the bottom.
  • The replace string may contain any of the following special sequences, all of which are case sensitive:
  1. $1 through $9 are replaced with the 1st through 9th word of the actual command typed by the user. e.g. if the user typed "nickserv identify mypass", $2 would be "identify" and $3 would be "mypass".
  2. $1- through $9- are replaced with the 1st through 9th word of the actual command typed by the user, and everything which follows that word. For example if the user typed "nickserv identify mypass", $1- would contain the whole line, $2- would contain "identify mypass" and $3- would contain just "mypass".
  3. $nick is replaced with the nickname of the user issuing the command
  4. $ident is replaced by the ident/username of the user issuing the command
  5. $host is replaced with the real hostname of the user issuing the command
  6. $vhost is replaced with the virtual (displayed) hostname of the user issuing the command
  • If you set the uline variable to yes, then not only must the nickname be on the network for the alias to work, but the nickname must also be on a U:Lined server. If the nickname is not on a U:Lined server, but is on the network (e.g. it is an impersonator), then a warning will be sent out to all opers who have the +a SNOMASK, and the command will fail with an error message.
  • If you set the operonly variable to a true value, then you must be an IRC operator to use the alias. Any non-operator use of the alias is treated as though the alias does not exist.
  • If you set the format string, the parameters of the alias must match this glob pattern. For example if you want the first parameter to start with a '#' for the alias to be executed, set format="#*" in the alias definition. Note that the :'s which are part of IRC formatted lines will be preserved for matching of this text. This value is optional. When using the format string, you may also specify the matchcase string which indicates whether the format string is case sensitive or not. This allows you for example to swap over "STATS P" and "STATS p" which differ only in case.

Alias supports fantasy commands, adding these requires 2 extra configuration tags:

<fantasy prefix="!" allowbots="no">
  • The prefix value is what character you want to trigger the fantasy command. It is recommended you set this differently than the fantasy character in your services package (if it supports fantasy commands).
  • The allowbots variable is simply whether users with the usermode +B (botmode) can use fantasy commands.
<alias text="CS" usercommand="no" channelcommand="yes"
replace="PRIVMSG ChanServ :$2 $chan $3-" requires="ChanServ" uline="yes">
  • Many of these settings are the same as for normal aliases, so only additional settings are described below.
  • usercommand: This defines whether the command can be used anywhere (such as in a query window or in your server window) or not (default = yes).
  • channelcommand: This defines whether the command can be used in channels (default = no).
  • The replace string is mostly the same as it is for normal aliases, but it supports one additional parameter:
  1. $chan is replaced with the channel you're running the fantasy command in.

Advanced example:

Using the format value to create an alias with two different behaviours depending on the format of the parameters. The first alias catches all 'ID' commands where the first parameter starts with a '#', and the alias below it acts as a catchall, catching all other use of the 'ID' command.

 <alias text="ID" format="#*" replace="PRIVMSG ChanServ :IDENTIFY $2 $3"
  requires="ChanServ" uline="yes">

 <alias text="ID" replace="PRIVMSG NickServ :IDENTIFY $2"
  requires="NickServ" uline="yes">

Further examples of advanced aliases to add usermode +D functionality by aliasing the Advanced Silence command (required m_silence_ext)

 <alias text="MODE" replace="SILENCE +*!*@* p" format="*+D" matchcase="yes">
 <alias text="MODE" replace="SILENCE +*!*@* p" format="*-D" matchcase="yes">

NOTE: You may place multiple commands into the replace string by seperating them with \n. The \n sequence translates to an actual linefeed, so if you want the literal value "\n" in a replace line you must use "\\n". For example:

<alias text="BANME" replace="OPER secretoper secretpass\nGLINE *@$host 7d :Banned self for 7 days">

Although this example is of course inherently stupid, it does demonstrate the feature.

This module does not implement any extra user or channel modes.
Extended Bans (Extbans)
This module implements no extended bans.
Any required, see above.
Special Notes
You can find several examples in the source directory for different services. They are in the 'docs/aliases' directory.