mirror of
https://github.com/unrealircd/unrealircd.git
synced 2026-07-10 18:23:12 +02:00
Use generic numeric 531 (ERR_CANTSENDTOUSER) for all such cases and use hook
CAN_SEND_TO_USER rather than HOOKTYPE_PRE_USERMSG (which is now removed). As for the numeric change: this makes it much easier for client devs. You rarely need to differentiate in the client code between the various causes. One only cares about detecting that the message was not sent and that the user needs to be informed. This replaces various NOTICEs, ERR_NOCTCP, ERR_NONONREG etc. with just the new numeric 531, which is taken from InspIRCd. The syntax is: :server 531 yourname targetname :reason for the block This makes it similar to numeric 404 (ERR_CANNOTSENDTOCHAN) that is used to indicate that a channel message was blocked. For module devs, the new hook CAN_SEND_TO_USER prototype is: int hooktype_can_send_to_user(Client *client, Client *target, char **text, char **errmsg, int notice); You can replace the text via this, by setting *text in your function. You can block the message, by returning HOOK_DENY. If doing so, then you must also set *errmsg to an appropriate value. Do not send any error message to the user! UnrealIRCd will take care of sending the error message for you, if you set *errmsg. Only if you need something special you could violate this rule, but preferably not! As you can see, CAN_SEND_TO_USER works just like CAN_SEND_TO_CHANNEL.
This commit is contained in:
+2
-2
@@ -284,7 +284,7 @@ extern void sendto_ops_and_log(FORMAT_STRING(const char *pattern), ...) __attrib
|
||||
|
||||
extern MODVAR int writecalls, writeb[];
|
||||
extern int deliver_it(Client *cptr, char *str, int len, int *want_read);
|
||||
extern int check_for_target_limit(Client *client, void *target, const char *name);
|
||||
extern int target_limit_exceeded(Client *client, void *target, const char *name);
|
||||
extern char *canonize(char *buffer);
|
||||
extern ConfigItem_deny_dcc *dcc_isforbidden(Client *client, char *filename);
|
||||
extern ConfigItem_deny_dcc *dcc_isdiscouraged(Client *client, char *filename);
|
||||
@@ -311,7 +311,7 @@ extern int umode_allow_all(Client *client, int what);
|
||||
extern int umode_allow_unset(Client *client, int what);
|
||||
extern int umode_allow_opers(Client *client, int what);
|
||||
extern int umode_allow_none(Client *client, int what);
|
||||
extern int umode_delete(char ch, long val);
|
||||
extern int umode_delete(char ch, long val);
|
||||
extern void build_umode_string(Client *client, long old, long sendmask, char *umode_buf);
|
||||
extern void send_umode_out(Client *client, int show_to_user, long old);
|
||||
|
||||
|
||||
+5
-2
@@ -931,7 +931,6 @@ extern void SavePersistentLongX(ModuleInfo *modinfo, char *varshortname, long va
|
||||
#define HOOKTYPE_FREE_CLIENT 59
|
||||
#define HOOKTYPE_FREE_USER 60
|
||||
#define HOOKTYPE_PRE_CHANMSG 61
|
||||
#define HOOKTYPE_PRE_USERMSG 62
|
||||
#define HOOKTYPE_KNOCK 63
|
||||
#define HOOKTYPE_MODECHAR_ADD 64
|
||||
#define HOOKTYPE_MODECHAR_DEL 65
|
||||
@@ -973,6 +972,8 @@ extern void SavePersistentLongX(ModuleInfo *modinfo, char *varshortname, long va
|
||||
#define HOOKTYPE_PRE_LOCAL_QUIT_CHAN 102
|
||||
#define HOOKTYPE_IDENT_LOOKUP 103
|
||||
#define HOOKTYPE_CONFIGRUN_EX 104
|
||||
#define HOOKTYPE_CAN_SEND_TO_USER 105
|
||||
// FIXME: ^^ make this enums? or..?
|
||||
|
||||
/* Adding a new hook here?
|
||||
* 1) Add the #define HOOKTYPE_.... with a new number
|
||||
@@ -1008,6 +1009,7 @@ int hooktype_remote_kick(Client *client, Client *victim, Channel *channel, Messa
|
||||
char *hooktype_pre_usermsg(Client *client, Client *to, char *text, int notice);
|
||||
int hooktype_usermsg(Client *client, Client *to, MessageTag *mtags, char *text, int notice);
|
||||
int hooktype_can_send_to_channel(Client *client, Channel *channel, Membership *member, char **text, char **errmsg, int notice);
|
||||
int hooktype_can_send_to_user(Client *client, Client *target, char **text, char **errmsg, int notice);
|
||||
int hooktype_pre_chanmsg(Client *client, Channel *channel, MessageTag *mtags, char *text, int notice);
|
||||
int hooktype_chanmsg(Client *client, Channel *channel, int sendflags, int prefix, char *target, MessageTag *mtags, char *text, int notice);
|
||||
char *hooktype_pre_local_topic(Client *client, Channel *channel, char *topic);
|
||||
@@ -1145,11 +1147,11 @@ _UNREAL_ERROR(_hook_error_incompatible, "Incompatible hook function. Check argum
|
||||
((hooktype == HOOKTYPE_INVITE) && !ValidateHook(hooktype_invite, func)) || \
|
||||
((hooktype == HOOKTYPE_CAN_JOIN) && !ValidateHook(hooktype_can_join, func)) || \
|
||||
((hooktype == HOOKTYPE_CAN_SEND_TO_CHANNEL) && !ValidateHook(hooktype_can_send_to_channel, func)) || \
|
||||
((hooktype == HOOKTYPE_CAN_SEND_TO_USER) && !ValidateHook(hooktype_can_send_to_user, func)) || \
|
||||
((hooktype == HOOKTYPE_CAN_KICK) && !ValidateHook(hooktype_can_kick, func)) || \
|
||||
((hooktype == HOOKTYPE_FREE_CLIENT) && !ValidateHook(hooktype_free_client, func)) || \
|
||||
((hooktype == HOOKTYPE_FREE_USER) && !ValidateHook(hooktype_free_user, func)) || \
|
||||
((hooktype == HOOKTYPE_PRE_CHANMSG) && !ValidateHook(hooktype_pre_chanmsg, func)) || \
|
||||
((hooktype == HOOKTYPE_PRE_USERMSG) && !ValidateHook(hooktype_pre_usermsg, func)) || \
|
||||
((hooktype == HOOKTYPE_KNOCK) && !ValidateHook(hooktype_knock, func)) || \
|
||||
((hooktype == HOOKTYPE_MODECHAR_ADD) && !ValidateHook(hooktype_modechar_add, func)) || \
|
||||
((hooktype == HOOKTYPE_MODECHAR_DEL) && !ValidateHook(hooktype_modechar_del, func)) || \
|
||||
@@ -1276,6 +1278,7 @@ enum EfunctionType {
|
||||
EFUNC_TKL_CHARTOTYPE,
|
||||
EFUNC_TKL_TYPE_STRING,
|
||||
EFUNC_CAN_SEND_TO_CHANNEL,
|
||||
EFUNC_CAN_SEND_TO_USER,
|
||||
EFUNC_BROADCAST_MD_GLOBALVAR,
|
||||
EFUNC_BROADCAST_MD_GLOBALVAR_CMD,
|
||||
EFUNC_TKL_IP_HASH,
|
||||
|
||||
@@ -148,6 +148,7 @@
|
||||
#define ERR_OPERONLY 520
|
||||
#define ERR_LISTSYNTAX 521
|
||||
|
||||
#define ERR_CANTSENDTOUSER 531
|
||||
/*
|
||||
* Numberic replies from server commands.
|
||||
* These are currently in the range 200-399.
|
||||
|
||||
+2
-2
@@ -23,7 +23,7 @@
|
||||
#ifndef proto_h
|
||||
#define proto_h
|
||||
/* channel.c */
|
||||
extern int sendmodeto_one(Client *cptr, char *from, char *name, char *mode, char *param, time_t creationtime);
|
||||
extern int sendmodeto_one(Client *cptr, char *from, char *name, char *mode, char *param, time_t creationtime);
|
||||
|
||||
/* lusers.c */
|
||||
extern void init_irccounts(void);
|
||||
@@ -54,7 +54,7 @@ extern EVENT(save_tunefile);
|
||||
extern void read_motd(const char *filename, MOTDFile *motd);
|
||||
|
||||
/* s_user.c */
|
||||
extern int check_for_target_limit(Client *client, void *target, const char *name);
|
||||
extern int target_limit_exceeded(Client *client, void *target, const char *name);
|
||||
extern void make_umodestr(void);
|
||||
extern char *get_mode_str(Client *acptr);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user