Skip to content

Instantly share code, notes, and snippets.

@westor7
Last active May 12, 2022 15:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save westor7/98cf20386001550ae16d0a326ef35575 to your computer and use it in GitHub Desktop.
Save westor7/98cf20386001550ae16d0a326ef35575 to your computer and use it in GitHub Desktop.
/SNOTICE UnrealIRCD 6 module
#include "unrealircd.h"
#define MSG_SNOTICE "SNOTICE"
CMD_FUNC(cmd_snotice);
ModuleHeader MOD_HEADER
= {
"third/snotice",
"1.0",
"Implements /snotice command to allow send a server notice",
"westor",
"unrealircd-6",
};
MOD_INIT() {
if (CommandExists(MSG_SNOTICE)) {
config_error("Command %s already exists", MSG_SNOTICE);
return MOD_FAILED;
}
CommandAdd(modinfo->handle, MSG_SNOTICE, cmd_snotice, 2, CMD_OPER);
return MOD_SUCCESS;
}
MOD_LOAD() { return MOD_SUCCESS; }
MOD_UNLOAD() { return MOD_SUCCESS; }
// /snotice NICK TEXT
CMD_FUNC(cmd_snotice) {
Client *target;
if (parc < 2) {
sendnumeric(client, ERR_NEEDMOREPARAMS, MSG_SNOTICE);
return;
}
if (BadPtr(parv[1]) || !strlen(parv[1])) {
sendnumeric(client, ERR_NORECIPIENT, MSG_SNOTICE);
return;
}
if (BadPtr(parv[2]) || !strlen(parv[2])) {
sendnumeric(client, ERR_NOTEXTTOSEND);
return;
}
if (!(target = find_user(parv[1], NULL))) {
sendnumeric(client, ERR_NOSUCHNICK, parv[1]);
return;
}
if (IsULine(target)) {
sendnumeric(client, ERR_CANTSENDTOUSER, MSG_SNOTICE, "Cannot be used on network services.");
return;
}
sendnotice(target, "%s", parv[2]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment