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.

Registering your command override
Registering your override is easy. Example: int mymod_nickoverride(Cmdoverride *ovr, aClient *cptr, aClient *sptr, int parc, char *parv[]); /* Forward declaration */

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

The command override function
Generally you want your code to execute before the real (core?) function is called: static int mymod_nickoverride(Cmdoverride *ovr, aClient *cptr, aClient *sptr, int parc, char *parv[]) {   sendnotice(sptr, "We are about to call the real function. We could do something useful here.");

return CallCmdoverride(ovr, cptr, sptr, 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: static int mymod_nickoverride(Cmdoverride *ovr, aClient *cptr, aClient *sptr, int parc, char *parv[]) {   int ret = CallCmdoverride(ovr, cptr, sptr, parc, parv); // call the real function

if (ret == FLUSH_BUFFER) return ret; /* 'sptr' no longer exists as it has been killed / client exited, we MUST return */

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

return 0; }