mirror of
https://github.com/matrix-construct/construct
synced 2024-11-15 22:41:12 +01: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:
parent
7e1bb8ad0d
commit
6357ad5fd9
2 changed files with 14 additions and 0 deletions
|
@ -132,6 +132,7 @@ typedef struct
|
|||
struct Channel *chptr;
|
||||
const char *text;
|
||||
int approved;
|
||||
const char *reason;
|
||||
} hook_data_privmsg_channel;
|
||||
|
||||
typedef struct
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue