Make oaccept work for multiple opers on the same target.

This commit is contained in:
B.Greenham 2010-03-05 14:26:40 -05:00
parent a18f1b6ef8
commit 75a9b0c8b0
2 changed files with 21 additions and 12 deletions

View File

@ -28,9 +28,14 @@ mo_oaccept(struct Client *client_p, struct Client *source_p, int parc, const cha
return; return;
} }
/* only allow one OACCEPT entry per user, so if there's an old one clear it */ /* Don't allow someone to pointlessly fill up someone's metadata
if(!(md = user_metadata_find(target_p, "OACCEPT"))) * with identical OACCEPT entries. */
user_metadata_delete(target_p, "OACCEPT", 1); if((md = user_metadata_find(target_p, "OACCEPT")))
if(!strcmp(source_p->name, md->value))
{
sendto_one_notice(source_p, ":You're already on %s's OACCEPT list", target_p->name);
return;
}
user_metadata_add(target_p, "OACCEPT", source_p->name, 1); user_metadata_add(target_p, "OACCEPT", source_p->name, 1);

View File

@ -45,6 +45,7 @@
#include "s_stats.h" #include "s_stats.h"
#include "tgchange.h" #include "tgchange.h"
#include "inline/stringops.h" #include "inline/stringops.h"
#include "irc_dictionary.h"
static int m_message(int, const char *, struct Client *, struct Client *, int, const char **); static int m_message(int, const char *, struct Client *, struct Client *, int, const char **);
static int m_privmsg(struct Client *, struct Client *, int, const char **); static int m_privmsg(struct Client *, struct Client *, int, const char **);
@ -731,6 +732,7 @@ msg_client(int p_or_n, const char *command,
{ {
int do_floodcount = 0; int do_floodcount = 0;
struct Metadata *md; struct Metadata *md;
struct DictionaryIter iter;
if(MyClient(source_p)) if(MyClient(source_p))
{ {
@ -791,7 +793,6 @@ msg_client(int p_or_n, const char *command,
(IsSetSCallerId(target_p) && !has_common_channel(source_p, target_p)) || (IsSetSCallerId(target_p) && !has_common_channel(source_p, target_p)) ||
(IsSetRegOnlyMsg(target_p) && !source_p->user->suser[0]))) (IsSetRegOnlyMsg(target_p) && !source_p->user->suser[0])))
{ {
md = user_metadata_find(target_p, "OACCEPT");
/* Here is the anti-flood bot/spambot code -db */ /* Here is the anti-flood bot/spambot code -db */
if(accept_message(source_p, target_p)) if(accept_message(source_p, target_p))
{ {
@ -801,16 +802,19 @@ msg_client(int p_or_n, const char *command,
source_p->username, source_p->username,
source_p->host, command, target_p->name, text); source_p->host, command, target_p->name, text);
} }
/* slightly ugly, meh. if anyone can think of a cleaner way to do this, by all means, do it. */ else if (IsOper(source_p))
else if(md)
{ {
if(!strcmp(md->value, source_p->name)) DICTIONARY_FOREACH(md, &iter, target_p->user->metadata)
{ {
add_reply_target(target_p, source_p); if(!strcmp(md->value, source_p->name))
sendto_one(target_p, ":%s!%s@%s %s %s :%s", {
source_p->name, add_reply_target(target_p, source_p);
source_p->username, sendto_one(target_p, ":%s!%s@%s %s %s :%s",
source_p->host, command, target_p->name, text); source_p->name,
source_p->username,
source_p->host, command, target_p->name, text);
break;
}
} }
} }
else if (IsSetRegOnlyMsg(target_p) && !source_p->user->suser[0]) else if (IsSetRegOnlyMsg(target_p) && !source_p->user->suser[0])