Dev:Command Overrides

Command overrides allow you to "override" a core command (or a command from other modules). Your code will then execute either before or after the actual command is executed. Or, you can choose not to execute the real command at all.

Generally people prefer the Dev:Hook API as it's more fine-grained and requires less work on your hand. People generally revert to Command Override's if Hooks do not provide (all) the functionality they are looking for.

About the variables available via CMD_OVERRIDE_FUNC
For command overrides we will use the  macro. These are the variables that you will receive in your override handler in your module:

Registering your command override
Registering your override is easy. Example: CMD_OVERRIDE_FUNC(mymod_nickoverride); /* Forward declaration */

MOD_LOAD(mymod) {   CmdoverrideAdd(modinfo->handle, "NICK", mymod_nickoverride); }

The command override function
Generally you want your code to execute before the real (core?) function is called: CMD_OVERRIDE_FUNC(mymod_nickoverride) {   sendnotice(client, "We are about to call the real function. We could do something useful here.");

return CallCommandOverride(ovr, client, recv_mtags, parc, parv); // call the real function and return it's return value }

If you want to execute your function after this is also possible, it just takes some extra care: CMD_OVERRIDE_FUNC(mymod_nickoverride) {   CallCommandOverride(ovr, client, recv_mtags, parc, parv); // call the real function

if (IsDead(client)) return; /* killed or client exited, we MUST return */

sendnotice(client, "The command was executed. We could do something useful here afterwards."); }