target change: Allow free replies.

When a user receives a private message, notice or RPL_UMODEGMSG,
add the source to a special set of 5 target slots.
These slots are checked in the normal way when sending messages,
allowing a reply without using up a free target.

This feature will not be very useful if a user is being messaged
by many different users; to help this, messages blocked entirely
by +g or +R do not affect the targets. CTCP replies also remain
free in terms of targets.
This commit is contained in:
Jilles Tjoelker 2010-02-15 01:07:07 +01:00
parent 179becdf5f
commit c9f01c4f2f
2 changed files with 50 additions and 3 deletions

View file

@ -54,6 +54,7 @@ struct Blacklist;
#define IDLEN 10
#define TGCHANGE_NUM 10 /* how many targets we keep track of */
#define TGCHANGE_REPLY 5 /* how many reply targets */
#define TGCHANGE_INITIAL 10 /* initial free targets (normal) */
#define TGCHANGE_INITIAL_LOW 4 /* initial free targets (possible spambot) */
@ -259,7 +260,11 @@ struct LocalUser
struct AuthRequest *auth_request;
/* target change stuff */
uint32_t targets[TGCHANGE_NUM]; /* targets were aware of (fnv32(use_id(target_p))) */
/* targets we're aware of (fnv32(use_id(target_p))):
* 0..TGCHANGE_NUM-1 regular slots
* TGCHANGE_NUM..TGCHANGE_NUM+TGCHANGE_REPLY-1 reply slots
*/
uint32_t targets[TGCHANGE_NUM + TGCHANGE_REPLY];
unsigned int targets_free; /* free targets */
time_t target_last; /* last time we cleared a slot */