0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-09-27 19:28:52 +02:00

Add a reason pointer to hook_data_privmsg_channel. When set, the reason is appended to the text of ERR_CANNOTSENDTOCHAN. The pointer will not be free()'ed.

This commit is contained in:
Jason Volk 2016-01-29 09:02:56 -08:00 committed by William Pitcock
parent 7e1bb8ad0d
commit 6357ad5fd9
2 changed files with 14 additions and 0 deletions

View file

@ -132,6 +132,7 @@ typedef struct
struct Channel *chptr;
const char *text;
int approved;
const char *reason;
} hook_data_privmsg_channel;
typedef struct

View file

@ -490,6 +490,7 @@ msg_channel(enum message_type msgtype,
hdata.chptr = chptr;
hdata.text = text;
hdata.approved = 0;
hdata.reason = NULL;
call_hook(h_privmsg_channel, &hdata);
@ -497,7 +498,17 @@ msg_channel(enum message_type msgtype,
text = hdata.text;
if (hdata.approved != 0)
{
if (msgtype == MESSAGE_TYPE_PRIVMSG)
{
if (!EmptyString(hdata.reason))
sendto_one_numeric(source_p, ERR_CANNOTSENDTOCHAN,form_str(ERR_CANNOTSENDTOCHAN)" (%s).",chptr->chname,hdata.reason);
else
sendto_one_numeric(source_p, ERR_CANNOTSENDTOCHAN,form_str(ERR_CANNOTSENDTOCHAN),chptr->chname);
}
return;
}
/* hook may have reduced the string to nothing. */
if (EmptyString(text))
@ -575,6 +586,7 @@ msg_channel_opmod(enum message_type msgtype,
hdata.chptr = chptr;
hdata.text = text;
hdata.approved = 0;
hdata.reason = NULL;
call_hook(h_privmsg_channel, &hdata);
@ -656,6 +668,7 @@ msg_channel_flags(enum message_type msgtype, struct Client *client_p,
hdata.chptr = chptr;
hdata.text = text;
hdata.approved = 0;
hdata.reason = NULL;
call_hook(h_privmsg_channel, &hdata);