mirror of
https://github.com/unrealircd/unrealircd.git
synced 2026-07-08 20:23:12 +02:00
can_send() now returns 0 (false) or 1 (true), rather than magic values.
Also, the HOOKTYPE_CAN_SEND prototype changed so you can communicate the error message in a flexible way, similar to what I just did with extbans.
This commit is contained in:
@@ -32,7 +32,7 @@ Cmode_t EXTCMODE_NONOTICE;
|
||||
|
||||
#define IsNoNotice(chptr) (chptr->mode.extmode & EXTCMODE_NONOTICE)
|
||||
|
||||
int nonotice_check_can_send(aClient *cptr, aChannel *chptr, char *msgtext, Membership *lp, int notice);
|
||||
int nonotice_check_can_send(aClient *cptr, aChannel *chptr, Membership *lp, char **msg, char **errmsg, int notice);
|
||||
|
||||
MOD_TEST(nonotice)
|
||||
{
|
||||
@@ -65,7 +65,7 @@ MOD_UNLOAD(nonotice)
|
||||
return MOD_SUCCESS;
|
||||
}
|
||||
|
||||
int nonotice_check_can_send(aClient *cptr, aChannel *chptr, char *msgtext, Membership *lp, int notice)
|
||||
int nonotice_check_can_send(aClient *cptr, aChannel *chptr, Membership *lp, char **msg, char **errmsg, int notice)
|
||||
{
|
||||
Hook *h;
|
||||
int i;
|
||||
@@ -81,7 +81,8 @@ int nonotice_check_can_send(aClient *cptr, aChannel *chptr, char *msgtext, Membe
|
||||
}
|
||||
if (i == HOOK_ALLOW)
|
||||
return HOOK_CONTINUE; /* bypass restriction */
|
||||
return CANNOT_SEND_NONOTICE; /* block notice */
|
||||
*errmsg = "NOTICEs are not permitted in this channel";
|
||||
return HOOK_DENY; /* block notice */
|
||||
}
|
||||
|
||||
return HOOK_CONTINUE;
|
||||
|
||||
@@ -34,8 +34,8 @@ static char errMsg[2048];
|
||||
|
||||
#define IsRegOnlySpeak(chptr) (chptr->mode.extmode & EXTCMODE_REGONLYSPEAK)
|
||||
|
||||
int regonlyspeak_can_send (aClient* cptr, aChannel *chptr, char* message, Membership* lp, int notice);
|
||||
char * regonlyspeak_part_message (aClient* sptr, aChannel *chptr, char* comment);
|
||||
int regonlyspeak_can_send(aClient *cptr, aChannel *chptr, Membership *lp, char **msg, char **errmsg, int notice);
|
||||
char *regonlyspeak_part_message (aClient* sptr, aChannel *chptr, char* comment);
|
||||
|
||||
MOD_TEST(regonlyspeak)
|
||||
{
|
||||
@@ -81,7 +81,7 @@ char *regonlyspeak_part_message (aClient *sptr, aChannel *chptr, char *comment)
|
||||
return comment;
|
||||
}
|
||||
|
||||
int regonlyspeak_can_send (aClient *cptr, aChannel *chptr, char *message, Membership *lp, int notice)
|
||||
int regonlyspeak_can_send(aClient *cptr, aChannel *chptr, Membership *lp, char **msg, char **errmsg, int notice)
|
||||
{
|
||||
Hook *h;
|
||||
int i;
|
||||
@@ -100,7 +100,8 @@ int regonlyspeak_can_send (aClient *cptr, aChannel *chptr, char *message, Member
|
||||
if (i == HOOK_ALLOW)
|
||||
return HOOK_CONTINUE; /* bypass +M restriction */
|
||||
|
||||
return CANNOT_SEND_MODREG; /* BLOCK message */
|
||||
*errmsg = "You must have a registered nick (+r) to talk on this channel";
|
||||
return HOOK_DENY; /* BLOCK message */
|
||||
}
|
||||
|
||||
return HOOK_CONTINUE;
|
||||
|
||||
+4
-24
@@ -178,25 +178,6 @@ int m_message(aClient *cptr, aClient *sptr, MessageTag *recv_mtags, int parc, ch
|
||||
MessageTag *mtags;
|
||||
int sendflags;
|
||||
|
||||
/*
|
||||
* Reasons why someone can't send to a channel
|
||||
* Note: a few have been moved to modules now, but don't just blindly delete them!! as we use the array index ;p
|
||||
*/
|
||||
static char *err_cantsend[] = {
|
||||
"You need voice (+v)",
|
||||
"No external channel messages",
|
||||
"Color is not permitted in this channel <<NOLONGERUSED>>",
|
||||
"You are banned",
|
||||
"CTCPs are not permitted in this channel <<NOLONGERUSED>>",
|
||||
"You must have a registered nick (+r) to talk on this channel",
|
||||
"Swearing is not permitted in this channel",
|
||||
"NOTICEs are not permitted in this channel",
|
||||
NULL
|
||||
};
|
||||
|
||||
if (IsHandshake(sptr))
|
||||
return 0;
|
||||
|
||||
if (parc < 2 || *parv[1] == '\0')
|
||||
{
|
||||
sendnumeric(sptr, ERR_NORECIPIENT, cmd);
|
||||
@@ -344,14 +325,13 @@ int m_message(aClient *cptr, aClient *sptr, MessageTag *recv_mtags, int parc, ch
|
||||
errmsg = NULL;
|
||||
if (MyClient(sptr) && !IsULine(sptr))
|
||||
{
|
||||
int cansend = can_send(sptr, chptr, &text, &errmsg, notice);
|
||||
if (cansend != 0)
|
||||
if (!can_send(sptr, chptr, &text, &errmsg, notice))
|
||||
{
|
||||
if (!notice || (cansend == 8))
|
||||
if (!notice)
|
||||
{
|
||||
/* Send error message */
|
||||
// TODO: move all the cansend shit to *errmsg ? if possible?
|
||||
sendnumeric(sptr, ERR_CANNOTSENDTOCHAN, chptr->chname, errmsg ? errmsg : err_cantsend[cansend - 1], p2);
|
||||
// TODO: move all the cansend shit to *errmsg ? if possible?
|
||||
sendnumeric(sptr, ERR_CANNOTSENDTOCHAN, chptr->chname, errmsg, p2);
|
||||
}
|
||||
continue; /* skip */
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user