znc/znc — pull request #450 by TheWug (2013-12-20 21:43:52+00:00)
Title: Add *alias module for ZNC-side command substitution

*alias is a module which hooks custom commands sent by clients and rewrites them to one or more commands before sending them to the irc server.

Consider the following example command, sent by a client:
FJOIN #mychan
*alias can hook FJOIN and translate this command into a more useful series of commands:
CS unban #mychan %nick%
CS unquiet #mychan %nick%
CS invite #mychan
JOIN #mychan

This series of commands will attempt to remove any simple restrictions on the channel that prevent you from joining, and then join the channel.

The following substitutions are available:
- any substitution provided by CModule::ExpandString() (see http://wiki.znc.in/ExpandString)
- tokens of the form %n%, which denote the n-th parameter of the command recieved from the client (parameter zero is the name of the command)
- tokens of the form %?n%, which are the same as %n%, except are allowed to be blank
- tokens of the form %n+%, which are the same as %n%, except are all parameters from the n-th onwards
- tokens which include both the + and ? modifiers, which consume all remaining parameters, or can be blank

Limitations:
- since ZNC has no way to know what channel buffer a command is entered into, the channel must usually be explicitly specified.
- PRIVMSGs and NOTICEs raised by aliases are not echoed to clients or logged (though they are perfectly visible on the upstream server). This may be changed in the future.

Additionally, CString was modified to include a few new convenience functions, including CString::Join to join an array into a single string, and CString::Convert, which is meant to replace the various conversion functions. They both work using stringstreams, so any type T for which ostream &operator<<(ostream&, const T&) exists will automatically support Join, and any for which istream &operator>>(istream &, T &) exists will automatically support Convert.