From 75a9b0c8b04401954a08302e3d0665d8ba45cfa8 Mon Sep 17 00:00:00 2001 From: "B.Greenham" Date: Fri, 5 Mar 2010 14:26:40 -0500 Subject: [PATCH] Make oaccept work for multiple opers on the same target. --- extensions/m_oaccept.c | 11 ++++++++--- modules/core/m_message.c | 22 +++++++++++++--------- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/extensions/m_oaccept.c b/extensions/m_oaccept.c index a136f66..a01a962 100644 --- a/extensions/m_oaccept.c +++ b/extensions/m_oaccept.c @@ -28,9 +28,14 @@ mo_oaccept(struct Client *client_p, struct Client *source_p, int parc, const cha return; } - /* only allow one OACCEPT entry per user, so if there's an old one clear it */ - if(!(md = user_metadata_find(target_p, "OACCEPT"))) - user_metadata_delete(target_p, "OACCEPT", 1); + /* Don't allow someone to pointlessly fill up someone's metadata + * with identical OACCEPT entries. */ + 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); diff --git a/modules/core/m_message.c b/modules/core/m_message.c index cc98043..ad727e2 100644 --- a/modules/core/m_message.c +++ b/modules/core/m_message.c @@ -45,6 +45,7 @@ #include "s_stats.h" #include "tgchange.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_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; struct Metadata *md; + struct DictionaryIter iter; 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)) || (IsSetRegOnlyMsg(target_p) && !source_p->user->suser[0]))) { - md = user_metadata_find(target_p, "OACCEPT"); /* Here is the anti-flood bot/spambot code -db */ 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->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(md) + else if (IsOper(source_p)) { - if(!strcmp(md->value, source_p->name)) + DICTIONARY_FOREACH(md, &iter, target_p->user->metadata) { - add_reply_target(target_p, source_p); - sendto_one(target_p, ":%s!%s@%s %s %s :%s", - source_p->name, - source_p->username, - source_p->host, command, target_p->name, text); + if(!strcmp(md->value, source_p->name)) + { + add_reply_target(target_p, source_p); + sendto_one(target_p, ":%s!%s@%s %s %s :%s", + 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])