summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/extern.h8
-rw-r--r--include/language.h4
-rw-r--r--include/modules.h10
-rw-r--r--include/services.h10
-rw-r--r--modules/core/os_ignore.cpp259
-rw-r--r--modules/core/os_set.cpp35
-rw-r--r--modules/protocol/inspircd11.cpp4
-rw-r--r--src/botserv.cpp4
-rw-r--r--src/channels.cpp15
-rw-r--r--src/language.cpp18
-rw-r--r--src/memoserv.cpp4
-rw-r--r--src/misc.cpp4
-rw-r--r--src/process.cpp205
-rw-r--r--src/protocol.cpp26
14 files changed, 250 insertions, 356 deletions
diff --git a/include/extern.h b/include/extern.h
index 7dc49e929..fee91178d 100644
--- a/include/extern.h
+++ b/include/extern.h
@@ -293,14 +293,6 @@ E bool is_on_access(const User *u, const NickCore *nc);
/**** process.c ****/
-E int allow_ignore;
-E std::list<IgnoreData *> ignore;
-
-E void add_ignore(const Anope::string &nick, time_t delta);
-E IgnoreData *get_ignore(const Anope::string &nick);
-E int delete_ignore(const Anope::string &nick);
-E int clear_ignores();
-
E void process(const Anope::string &buf);
/**** send.c ****/
diff --git a/include/language.h b/include/language.h
index 4b04028f9..e40b93432 100644
--- a/include/language.h
+++ b/include/language.h
@@ -998,9 +998,6 @@ enum LanguageString
OPER_SZLINE_VIEW_HEADER,
OPER_SZLINE_CLEAR,
OPER_SET_SYNTAX,
- OPER_SET_IGNORE_ON,
- OPER_SET_IGNORE_OFF,
- OPER_SET_IGNORE_ERROR,
OPER_SET_READONLY_ON,
OPER_SET_READONLY_OFF,
OPER_SET_READONLY_ERROR,
@@ -1458,7 +1455,6 @@ enum LanguageString
OPER_HELP_SET_DEBUG,
OPER_HELP_SET_NOEXPIRE,
OPER_HELP_SET_SUPERADMIN,
- OPER_HELP_SET_IGNORE,
OPER_HELP_SET_LIST,
OPER_HELP_NOOP,
OPER_HELP_JUPE,
diff --git a/include/modules.h b/include/modules.h
index 0afd033a3..4f7bddf69 100644
--- a/include/modules.h
+++ b/include/modules.h
@@ -1026,6 +1026,14 @@ class CoreExport Module : public Extensible
* @param s Our uplink
*/
virtual void OnUplinkSync(Server *s) { }
+
+ /** Called when we receive a PRIVMSG for one of our clients
+ * @param u The user sending the PRIVMSG
+ * @param bi The target of the PRIVMSG
+ * @param message The message
+ * @return EVENT_STOP to halt processing
+ */
+ virtual EventReturn OnBotPrivmsg(User *u, BotInfo *bi, const Anope::string &message) { return EVENT_CONTINUE; }
};
/** Implementation-specific flags which may be set in ModuleManager::Attach()
@@ -1078,7 +1086,7 @@ enum Implementation
I_OnServerQuit, I_OnTopicUpdated,
I_OnEncrypt, I_OnEncryptCheckLen, I_OnDecrypt, I_OnCheckPassword,
I_OnChannelModeSet, I_OnChannelModeUnset, I_OnUserModeSet, I_OnUserModeUnset, I_OnChannelModeAdd, I_OnUserModeAdd,
- I_OnMLock, I_OnUnMLock, I_OnServerSync, I_OnUplinkSync,
+ I_OnMLock, I_OnUnMLock, I_OnServerSync, I_OnUplinkSync, I_OnBotPrivmsg,
I_END
};
diff --git a/include/services.h b/include/services.h
index 645afc911..d86729e51 100644
--- a/include/services.h
+++ b/include/services.h
@@ -793,16 +793,6 @@ class Entry : public Flags<EntryType>
/*************************************************************************/
-/* Ignorance list data. */
-
-struct IgnoreData
-{
- Anope::string mask;
- time_t time; /* When do we stop ignoring them? */
-};
-
-/*************************************************************************/
-
/* News stuff */
enum NewsType
diff --git a/modules/core/os_ignore.cpp b/modules/core/os_ignore.cpp
index 79bb28d24..91a3fff79 100644
--- a/modules/core/os_ignore.cpp
+++ b/modules/core/os_ignore.cpp
@@ -12,14 +12,147 @@
/*************************************************************************/
#include "module.h"
+#include "os_ignore.h"
+
+class OSIgnoreService : public IgnoreService
+{
+ public:
+ OSIgnoreService(Module *o, const Anope::string &n) : IgnoreService(o, n) { }
+
+ void AddIgnore(const Anope::string &mask, const Anope::string &creator, const Anope::string &reason, time_t delta = Anope::CurTime)
+ {
+ /* If it s an existing user, we ignore the hostmask. */
+ Anope::string realmask = mask;
+ size_t user, host;
+
+ User *u = finduser(mask);
+ if (u)
+ realmask = "*!*@" + u->host;
+ /* Determine whether we get a nick or a mask. */
+ else if ((host = mask.find('@')) != Anope::string::npos)
+ {
+ /* Check whether we have a nick too.. */
+ if ((user = mask.find('!')) != Anope::string::npos)
+ {
+ /* this should never happen */
+ if (user > host)
+ return;
+ }
+ else
+ /* We have user@host. Add nick wildcard. */
+ realmask = "*!" + mask;
+ }
+ /* We only got a nick.. */
+ else
+ realmask = mask + "!*@*";
+
+ /* Check if we already got an identical entry. */
+ IgnoreData *ign = this->Find(realmask);
+ if (ign != NULL)
+ {
+ if (!delta)
+ ign->time = 0;
+ else
+ ign->time = Anope::CurTime + delta;
+ }
+ /* Create new entry.. */
+ else
+ {
+ IgnoreData newign;
+ newign.mask = realmask;
+ newign.creator = creator;
+ newign.reason = reason;
+ newign.time = delta ? Anope::CurTime + delta : 0;
+ this->ignores.push_back(newign);
+ }
+ }
+
+ bool DelIgnore(const Anope::string &mask)
+ {
+ for (std::list<IgnoreData>::iterator it = this->ignores.begin(), it_end = this->ignores.end(); it != it_end; ++it)
+ {
+ IgnoreData &idn = *it;
+ if (idn.mask.equals_ci(mask))
+ {
+ this->ignores.erase(it);
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ IgnoreData *Find(const Anope::string &mask)
+ {
+ User *u = finduser(mask);
+ std::list<IgnoreData>::iterator ign = this->ignores.begin(), ign_end = this->ignores.end();
+
+ if (u)
+ {
+ for (; ign != ign_end; ++ign)
+ {
+ Entry ignore_mask(ign->mask);
+ if (ignore_mask.Matches(u))
+ break;
+ }
+ }
+ else
+ {
+ size_t user, host;
+ Anope::string tmp;
+ /* We didn't get a user.. generate a valid mask. */
+ if ((host = mask.find('@')) != Anope::string::npos)
+ {
+ if ((user = mask.find('!')) != Anope::string::npos)
+ {
+ /* this should never happen */
+ if (user > host)
+ return NULL;
+ tmp = mask;
+ }
+ else
+ /* We have user@host. Add nick wildcard. */
+ tmp = "*!" + mask;
+ }
+ /* We only got a nick.. */
+ else
+ tmp = mask + "!*@*";
+
+ for (; ign != ign_end; ++ign)
+ if (Anope::Match(tmp, ign->mask))
+ break;
+ }
+
+ /* Check whether the entry has timed out */
+ if (ign != ign_end)// && (*ign)->time && (*ign)->time <= Anope::CurTime)
+ {
+ IgnoreData &id = *ign;
+
+ if (id.time && id.time <= Anope::CurTime)
+ {
+ Log(LOG_DEBUG) << "Expiring ignore entry " << id.mask;
+ this->ignores.erase(ign);
+ }
+ else
+ return &id;
+ }
+
+ return NULL;
+ }
+};
class CommandOSIgnore : public Command
{
private:
CommandReturn DoAdd(CommandSource &source, const std::vector<Anope::string> &params)
{
+ service_reference<IgnoreService> ignore_service("operserv/ignore");
+ if (!ignore_service)
+ return MOD_CONT;
+
const Anope::string &time = params.size() > 1 ? params[1] : "";
const Anope::string &nick = params.size() > 2 ? params[2] : "";
+ const Anope::string &reason = params.size() > 3 ? params[3] : "";
if (time.empty() || nick.empty())
{
@@ -35,16 +168,12 @@ class CommandOSIgnore : public Command
source.Reply(OPER_IGNORE_VALID_TIME);
return MOD_CONT;
}
- else if (!t)
- {
- add_ignore(nick, t);
+
+ ignore_service->AddIgnore(nick, source.u->nick, reason, t);
+ if (!t)
source.Reply(OPER_IGNORE_PERM_DONE, nick.c_str());
- }
else
- {
- add_ignore(nick, t);
source.Reply(OPER_IGNORE_TIME_DONE, nick.c_str(), time.c_str());
- }
}
return MOD_CONT;
@@ -52,46 +181,58 @@ class CommandOSIgnore : public Command
CommandReturn DoList(CommandSource &source)
{
- if (ignore.empty())
- {
- source.Reply(OPER_IGNORE_LIST_EMPTY);
+ service_reference<IgnoreService> ignore_service("operserv/ignore");
+ if (!ignore_service)
return MOD_CONT;
- }
- source.Reply(OPER_IGNORE_LIST);
- for (std::list<IgnoreData *>::iterator ign = ignore.begin(), ign_end = ignore.end(); ign != ign_end; ++ign)
- source.Reply("%s", (*ign)->mask.c_str());
+ const std::list<IgnoreData> &ignores = ignore_service->GetIgnores();
+ if (ignores.empty())
+ source.Reply(OPER_IGNORE_LIST_EMPTY);
+ else
+ {
+ source.Reply(OPER_IGNORE_LIST);
+ for (std::list<IgnoreData>::const_iterator ign = ignores.begin(), ign_end = ignores.end(); ign != ign_end; ++ign)
+ {
+ const IgnoreData &ignore = *ign;
+
+ source.Reply(" %-11s %-11s %-11s %s", ignore.mask.c_str(), ignore.creator.c_str(), ignore.reason.c_str(), do_strftime(ignore.time).c_str());
+ }
+ }
return MOD_CONT;
}
CommandReturn DoDel(CommandSource &source, const std::vector<Anope::string> &params)
{
- Anope::string nick = params.size() > 1 ? params[1] : "";
+ service_reference<IgnoreService> ignore_service("operserv/ignore");
+ if (!ignore_service)
+ return MOD_CONT;
+
+ const Anope::string nick = params.size() > 1 ? params[1] : "";
if (nick.empty())
this->OnSyntaxError(source, "DEL");
+ else if (ignore_service->DelIgnore(nick))
+ source.Reply(OPER_IGNORE_DEL_DONE, nick.c_str());
else
- {
- if (delete_ignore(nick))
- {
- source.Reply(OPER_IGNORE_DEL_DONE, nick.c_str());
- return MOD_CONT;
- }
source.Reply(OPER_IGNORE_LIST_NOMATCH, nick.c_str());
- }
return MOD_CONT;
}
CommandReturn DoClear(CommandSource &source)
{
- clear_ignores();
+ service_reference<IgnoreService> ignore_service("operserv/ignore");
+ if (!ignore_service)
+ return MOD_CONT;
+
+ ignore_service->ClearIgnores();
source.Reply(OPER_IGNORE_LIST_CLEARED);
return MOD_CONT;
}
+
public:
- CommandOSIgnore() : Command("IGNORE", 1, 3, "operserv/ignore")
+ CommandOSIgnore() : Command("IGNORE", 1, 4, "operserv/ignore")
{
}
@@ -132,30 +273,38 @@ class CommandOSIgnore : public Command
class OSIgnore : public Module
{
+ OSIgnoreService osignoreservice;
CommandOSIgnore commandosignore;
public:
- OSIgnore(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator)
+ OSIgnore(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator), osignoreservice(this, "operserv/ignore")
{
this->SetAuthor("Anope");
this->SetType(CORE);
this->AddCommand(OperServ, &commandosignore);
- Implementation i[] = { I_OnDatabaseRead, I_OnDatabaseWrite };
- ModuleManager::Attach(i, this, 2);
+ Implementation i[] = { I_OnDatabaseRead, I_OnDatabaseWrite, I_OnPreCommandRun, I_OnBotPrivmsg };
+ ModuleManager::Attach(i, this, 4);
+
+ ModuleManager::RegisterService(&this->osignoreservice);
}
EventReturn OnDatabaseRead(const std::vector<Anope::string> &params)
{
- if (params[0].equals_ci("OS") && params.size() >= 4 && params[1].equals_ci("IGNORE"))
+ if (params.size() >= 4 && params[0].equals_ci("OS") && params[1].equals_ci("IGNORE"))
{
- IgnoreData *ign = new IgnoreData();
- ign->mask = params[2];
- ign->time = params[3].is_pos_number_only() ? convertTo<time_t>(params[3]) : 0;
- ignore.push_front(ign);
+ service_reference<IgnoreService> ignore_service("operserv/ignore");
+ if (ignore_service)
+ {
+ const Anope::string &mask = params[2];
+ time_t time = params[3].is_pos_number_only() ? convertTo<time_t>(params[3]) : 0;
+ const Anope::string &creator = params.size() > 4 ? params[4] : "";
+ const Anope::string &reason = params.size() > 5 ? params[5] : "";
+ ignore_service->AddIgnore(mask, creator, reason, time - Anope::CurTime);
- return EVENT_STOP;
+ return EVENT_STOP;
+ }
}
return EVENT_CONTINUE;
@@ -163,23 +312,43 @@ class OSIgnore : public Module
void OnDatabaseWrite(void (*Write)(const Anope::string &))
{
- for (std::list<IgnoreData *>::iterator ign = ignore.begin(), ign_end = ignore.end(); ign != ign_end; )
+ service_reference<IgnoreService> ignore_service("operserv/ignore");
+ if (ignore_service)
{
- if ((*ign)->time && (*ign)->time <= Anope::CurTime)
+ for (std::list<IgnoreData>::iterator ign = ignore_service->GetIgnores().begin(), ign_end = ignore_service->GetIgnores().end(); ign != ign_end; )
{
- Log(LOG_DEBUG) << "[os_ignore] Expiring ignore entry " << (*ign)->mask;
- delete *ign;
- ign = ignore.erase(ign);
- }
- else
- {
- std::stringstream buf;
- buf << "OS IGNORE " << (*ign)->mask << " " << (*ign)->time;
- Write(buf.str());
- ++ign;
+ if (ign->time && ign->time <= Anope::CurTime)
+ {
+ Log(LOG_DEBUG) << "[os_ignore] Expiring ignore entry " << ign->mask;
+ ign = ignore_service->GetIgnores().erase(ign);
+ }
+ else
+ {
+ std::stringstream buf;
+ buf << "OS IGNORE " << ign->mask << " " << ign->time << " " << ign->creator << " :" << ign->reason;
+ Write(buf.str());
+ ++ign;
+ }
}
}
}
+
+ EventReturn OnPreCommandRun(User *&u, BotInfo *&bi, Anope::string &command, Anope::string &message, ChannelInfo *&ci)
+ {
+ return this->OnBotPrivmsg(u, bi, message);
+ }
+
+ EventReturn OnBotPrivmsg(User *u, BotInfo *bi, const Anope::string &message)
+ {
+ service_reference<IgnoreService> ignore_service("operserv/ignore");
+ if (ignore_service)
+ {
+ if (ignore_service->Find(u->nick))
+ return EVENT_STOP;
+ }
+
+ return EVENT_CONTINUE;
+ }
};
MODULE_INIT(OSIgnore)
diff --git a/modules/core/os_set.cpp b/modules/core/os_set.cpp
index 063eeaefd..f371fd61a 100644
--- a/modules/core/os_set.cpp
+++ b/modules/core/os_set.cpp
@@ -22,8 +22,6 @@ class CommandOSSet : public Command
LanguageString index;
- index = allow_ignore ? OPER_SET_LIST_OPTION_ON : OPER_SET_LIST_OPTION_OFF;
- source.Reply(index, "IGNORE");
index = readonly ? OPER_SET_LIST_OPTION_ON : OPER_SET_LIST_OPTION_OFF;
source.Reply(index, "READONLY");
index = debug ? OPER_SET_LIST_OPTION_ON : OPER_SET_LIST_OPTION_OFF;
@@ -34,35 +32,6 @@ class CommandOSSet : public Command
return MOD_CONT;
}
- CommandReturn DoSetIgnore(CommandSource &source, const std::vector<Anope::string> &params)
- {
- User *u = source.u;
- const Anope::string &setting = params.size() > 1 ? params[1] : "";
-
- if (setting.empty())
- {
- this->OnSyntaxError(source, "IGNORE");
- return MOD_CONT;
- }
-
- if (setting.equals_ci("ON"))
- {
- Log(LOG_ADMIN, u, this) << "ON";
- allow_ignore = 1;
- source.Reply(OPER_SET_IGNORE_ON);
- }
- else if (setting.equals_ci("OFF"))
- {
- Log(LOG_ADMIN, u, this) << "OFF";
- allow_ignore = 0;
- source.Reply(OPER_SET_IGNORE_OFF);
- }
- else
- source.Reply(OPER_SET_IGNORE_ERROR);
-
- return MOD_CONT;
- }
-
CommandReturn DoSetReadOnly(CommandSource &source, const std::vector<Anope::string> &params)
{
User *u = source.u;
@@ -204,8 +173,6 @@ class CommandOSSet : public Command
if (option.equals_ci("LIST"))
return this->DoList(source);
- else if (option.equals_ci("IGNORE"))
- return this->DoSetIgnore(source, params);
else if (option.equals_ci("READONLY"))
return this->DoSetReadOnly(source, params);
else if (option.equals_ci("SUPERADMIN"))
@@ -230,8 +197,6 @@ class CommandOSSet : public Command
source.Reply(OPER_HELP_SET_READONLY);
else if (subcommand.equals_ci("NOEXPIRE"))
source.Reply(OPER_HELP_SET_NOEXPIRE);
- else if (subcommand.equals_ci("IGNORE"))
- source.Reply(OPER_HELP_SET_IGNORE);
else if (subcommand.equals_ci("SUPERADMIN"))
source.Reply(OPER_HELP_SET_SUPERADMIN);
else
diff --git a/modules/protocol/inspircd11.cpp b/modules/protocol/inspircd11.cpp
index 42c016a37..270a3e013 100644
--- a/modules/protocol/inspircd11.cpp
+++ b/modules/protocol/inspircd11.cpp
@@ -587,6 +587,8 @@ class InspircdIRCdMessage : public IRCdMessage
}
IRCdMessage::OnCapab(source, params);
+
+ return true;
}
bool OnSJoin(const Anope::string &source, const std::vector<Anope::string> &params)
@@ -676,6 +678,8 @@ class InspircdIRCdMessage : public IRCdMessage
c->UnsetFlag(CH_SYNCING);
c->Sync();
}
+
+ return true;
}
};
diff --git a/src/botserv.cpp b/src/botserv.cpp
index ddd8dc15f..c42cfbd05 100644
--- a/src/botserv.cpp
+++ b/src/botserv.cpp
@@ -312,10 +312,6 @@ void botchanmsgs(User *u, ChannelInfo *ci, const Anope::string &buf)
}
}
- /* return if the user is on the ignore list */
- if (get_ignore(u->nick))
- return;
-
/* Fantaisist commands */
if (ci->botflags.HasFlag(BS_FANTASY) && buf[0] == Config->BSFantasyCharacter[0] && !was_action)
{
diff --git a/src/channels.cpp b/src/channels.cpp
index c8c52f188..8873931f5 100644
--- a/src/channels.cpp
+++ b/src/channels.cpp
@@ -125,15 +125,12 @@ void Channel::JoinUser(User *user)
update_ts = true;
}
- if (!get_ignore(user->nick))
+ if (this->ci && check_access(user, this->ci, CA_MEMO) && this->ci->memos.memos.size() > 0)
{
- if (this->ci && check_access(user, this->ci, CA_MEMO) && this->ci->memos.memos.size() > 0)
- {
- if (this->ci->memos.memos.size() == 1)
- user->SendMessage(MemoServ, MEMO_X_ONE_NOTICE, this->ci->memos.memos.size(), this->ci->name.c_str());
- else
- user->SendMessage(MemoServ, MEMO_X_MANY_NOTICE, this->ci->memos.memos.size(), this->ci->name.c_str());
- }
+ if (this->ci->memos.memos.size() == 1)
+ user->SendMessage(MemoServ, MEMO_X_ONE_NOTICE, this->ci->memos.memos.size(), this->ci->name.c_str());
+ else
+ user->SendMessage(MemoServ, MEMO_X_MANY_NOTICE, this->ci->memos.memos.size(), this->ci->name.c_str());
}
if (!Config->s_BotServ.empty() && this->ci && this->ci->bi)
@@ -1168,7 +1165,7 @@ void chan_set_correct_modes(User *user, Channel *c, int give_modes)
Log(LOG_DEBUG) << "Setting correct user modes for " << user->nick << " on " << c->name << " (" << (give_modes ? "" : "not ") << "giving modes)";
- if (give_modes && !get_ignore(user->nick) && (!user->Account() || user->Account()->HasFlag(NI_AUTOOP)))
+ if (give_modes && (!user->Account() || user->Account()->HasFlag(NI_AUTOOP)))
{
if (owner && check_access(user, ci, CA_AUTOOWNER))
c->SetMode(NULL, CMODE_OWNER, user->nick);
diff --git a/src/language.cpp b/src/language.cpp
index 13e1675f5..55ba2db18 100644
--- a/src/language.cpp
+++ b/src/language.cpp
@@ -2220,12 +2220,6 @@ const char *const language_strings[LANG_STRING_COUNT] = {
_("The SZLINE list has been cleared."),
/* OPER_SET_SYNTAX */
_("SET option setting"),
- /* OPER_SET_IGNORE_ON */
- _("Ignore code will be used."),
- /* OPER_SET_IGNORE_OFF */
- _("Ignore code will not be used."),
- /* OPER_SET_IGNORE_ERROR */
- _("Setting for IGNORE must be ON or OFF."),
/* OPER_SET_READONLY_ON */
_("Services are now in read-only mode."),
/* OPER_SET_READONLY_OFF */
@@ -2269,7 +2263,7 @@ const char *const language_strings[LANG_STRING_COUNT] = {
/* OPER_RELOAD */
_("Services' configuration file has been reloaded."),
/* OPER_IGNORE_SYNTAX */
- _("IGNORE {ADD|DEL|LIST|CLEAR} [time] [nick | mask]"),
+ _("IGNORE {ADD|DEL|LIST|CLEAR} [time] [nick] [reason]"),
/* OPER_IGNORE_VALID_TIME */
_("You have to enter a valid number as time."),
/* OPER_IGNORE_TIME_DONE */
@@ -2279,7 +2273,8 @@ const char *const language_strings[LANG_STRING_COUNT] = {
/* OPER_IGNORE_DEL_DONE */
_("%s will no longer be ignored."),
/* OPER_IGNORE_LIST */
- _("Services ignore list:"),
+ _("Services ignore list:\n"
+ " Mask Creator Reason Expires"),
/* OPER_IGNORE_LIST_NOMATCH */
_("Nick %s not found on ignore list."),
/* OPER_IGNORE_LIST_EMPTY */
@@ -4462,7 +4457,7 @@ const char *const language_strings[LANG_STRING_COUNT] = {
"The ALL displays the user and uptime statistics, and\n"
"everything you'd see with MEMORY and UPLINK options."),
/* OPER_HELP_IGNORE */
- _("Syntax: IGNORE {ADD|DEL|LIST|CLEAR} [time] [nick | mask]\n"
+ _("Syntax: IGNORE {ADD|DEL|LIST|CLEAR} [time] [nick] [reason]\n"
" \n"
"Allows Services Operators to make Services ignore a nick or mask\n"
"for a certain time or until the next restart. The default\n"
@@ -4689,7 +4684,6 @@ const char *const language_strings[LANG_STRING_COUNT] = {
" DEBUG Activate or deactivate debug mode\n"
" NOEXPIRE Activate or deactivate no expire mode\n"
" SUPERADMIN Activate or deactivate super-admin mode\n"
- " IGNORE Activate or deactivate ignore mode\n"
" LIST List the options"),
/* OPER_HELP_SET_READONLY */
_("Syntax: SET READONLY {ON | OFF}\n"
@@ -4728,10 +4722,6 @@ const char *const language_strings[LANG_STRING_COUNT] = {
"ability to be \"founder\" on all channel's etc...\n"
"This option is not persistent, and should only be used when\n"
"needed, and set back to OFF when no longer needed."),
- /* OPER_HELP_SET_IGNORE */
- _("Syntax: SET IGNORE {ON | OFF}\n"
- "Setting this will toggle Anope's usage of the IGNORE system \n"
- "on or off."),
/* OPER_HELP_SET_LIST */
_("Syntax: SET LIST\n"
"Display the various %S settings"),
diff --git a/src/memoserv.cpp b/src/memoserv.cpp
index ef6a9a5f8..13543011a 100644
--- a/src/memoserv.cpp
+++ b/src/memoserv.cpp
@@ -239,7 +239,7 @@ void memo_send(CommandSource &source, const Anope::string &name, const Anope::st
if (Config->MSNotifyAll)
{
- if (nc->HasFlag(NI_MEMO_RECEIVE) && !get_ignore(name))
+ if (nc->HasFlag(NI_MEMO_RECEIVE))
{
for (std::list<NickAlias *>::iterator it = nc->aliases.begin(), it_end = nc->aliases.end(); it != it_end; ++it)
{
@@ -274,7 +274,7 @@ void memo_send(CommandSource &source, const Anope::string &name, const Anope::st
if (check_access(cu->user, c->ci, CA_MEMO))
{
- if (cu->user->Account() && cu->user->Account()->HasFlag(NI_MEMO_RECEIVE) && !get_ignore(cu->user->nick))
+ if (cu->user->Account() && cu->user->Account()->HasFlag(NI_MEMO_RECEIVE))
cu->user->SendMessage(MemoServ, MEMO_NEW_X_MEMO_ARRIVED, c->ci->name.c_str(), Config->s_MemoServ.c_str(), c->ci->name.c_str(), mi->memos.size());
}
}
diff --git a/src/misc.cpp b/src/misc.cpp
index 51899270b..6aa90820e 100644
--- a/src/misc.cpp
+++ b/src/misc.cpp
@@ -201,7 +201,7 @@ time_t dotime(const Anope::string &s)
if (s.empty())
return -1;
- int amount = 0;
+ int amount;
Anope::string end;
try
@@ -230,7 +230,7 @@ time_t dotime(const Anope::string &s)
}
catch (const CoreException &) { }
- return amount;
+ return -1;
}
/*************************************************************************/
diff --git a/src/process.cpp b/src/process.cpp
index 0f714e9f0..251ededcf 100644
--- a/src/process.cpp
+++ b/src/process.cpp
@@ -12,211 +12,6 @@
#include "services.h"
#include "modules.h"
-/*************************************************************************/
-
-/* Use ignore code? */
-int allow_ignore = 1;
-
-/* Masks to ignore. */
-std::list<IgnoreData *> ignore;
-
-/*************************************************************************/
-
-/**
- * Add a mask/nick to the ignorelist for delta seconds.
- * @param nick Nick or (nick!)user@host to add to the ignorelist.
- * @param delta Seconds untill new entry is set to expire. 0 for permanent.
- */
-void add_ignore(const Anope::string &nick, time_t delta)
-{
- if (nick.empty())
- return;
- /* If it s an existing user, we ignore the hostmask. */
- Anope::string mask;
- User *u = finduser(nick);
- size_t user, host;
- if (u)
- mask = "*!*@" + u->host;
- /* Determine whether we get a nick or a mask. */
- else if ((host = nick.find('@')) != Anope::string::npos)
- {
- /* Check whether we have a nick too.. */
- if ((user = nick.find('!')) != Anope::string::npos)
- {
- /* this should never happen */
- if (user > host)
- return;
- mask = nick;
- }
- else
- /* We have user@host. Add nick wildcard. */
- mask = "*!" + nick;
- }
- /* We only got a nick.. */
- else
- mask = nick + "!*@*";
- /* Check if we already got an identical entry. */
- std::list<IgnoreData *>::iterator ign = ignore.begin(), ign_end = ignore.end();
- for (; ign != ign_end; ++ign)
- if (mask.equals_ci((*ign)->mask))
- break;
- /* Found one.. */
- if (ign != ign_end)
- {
- if (!delta)
- (*ign)->time = 0;
- else if ((*ign)->time < Anope::CurTime + delta)
- (*ign)->time = Anope::CurTime + delta;
- }
- /* Create new entry.. */
- else
- {
- IgnoreData *newign = new IgnoreData();
- newign->mask = mask;
- newign->time = delta ? Anope::CurTime + delta : 0;
- ignore.push_front(newign);
- Log(LOG_DEBUG) << "Added new ignore entry for " << mask;
- }
-}
-
-/*************************************************************************/
-
-/**
- * Retrieve an ignorance record for a nick or mask.
- * If the nick isn't being ignored, we return NULL and if necesary
- * flush the record from the ignore list (i.e. ignore timed out).
- * @param nick Nick or (nick!)user@host to look for on the ignorelist.
- * @return Pointer to the ignore record, NULL if none was found.
- */
-IgnoreData *get_ignore(const Anope::string &nick)
-{
- if (nick.empty())
- return NULL;
- /* User has disabled the IGNORE system */
- if (!allow_ignore)
- return NULL;
- User *u = finduser(nick);
- std::list<IgnoreData *>::iterator ign = ignore.begin(), ign_end = ignore.end();
- /* If we find a real user, match his mask against the ignorelist. */
- if (u)
- {
- /* Opers are not ignored, even if a matching entry may be present. */
- if (u->HasMode(UMODE_OPER))
- return NULL;
- for (; ign != ign_end; ++ign)
- {
- Entry ignore_mask((*ign)->mask);
- if (ignore_mask.Matches(u))
- break;
- }
- }
- else
- {
- Anope::string tmp;
- size_t user, host;
- /* We didn't get a user.. generate a valid mask. */
- if ((host = nick.find('@')) != Anope::string::npos)
- {
- if ((user = nick.find('!')) != Anope::string::npos)
- {
- /* this should never happen */
- if (user > host)
- return NULL;
- tmp = nick;
- }
- else
- /* We have user@host. Add nick wildcard. */
- tmp = "*!" + nick;
- }
- /* We only got a nick.. */
- else
- tmp = nick + "!*@*";
- for (; ign != ign_end; ++ign)
- if (Anope::Match(tmp, (*ign)->mask))
- break;
- }
- /* Check whether the entry has timed out */
- if (ign != ign_end && (*ign)->time && (*ign)->time <= Anope::CurTime)
- {
- Log(LOG_DEBUG) << "Expiring ignore entry " << (*ign)->mask;
- delete *ign;
- ignore.erase(ign);
- ign = ign_end = ignore.end();
- }
- if (ign != ign_end)
- Log(LOG_DEBUG) << "Found ignore entry (" << (*ign)->mask << ") for " << nick;
- return ign == ign_end ? NULL : *ign;
-}
-
-/*************************************************************************/
-
-/**
- * Deletes a given nick/mask from the ignorelist.
- * @param nick Nick or (nick!)user@host to delete from the ignorelist.
- * @return Returns 1 on success, 0 if no entry is found.
- */
-int delete_ignore(const Anope::string &nick)
-{
- if (nick.empty())
- return 0;
- /* If it s an existing user, we ignore the hostmask. */
- Anope::string tmp;
- size_t user, host;
- User *u = finduser(nick);
- if (u)
- tmp = "*!*@" + u->host;
- /* Determine whether we get a nick or a mask. */
- else if ((host = nick.find('@')) != Anope::string::npos)
- {
- /* Check whether we have a nick too.. */
- if ((user = nick.find('!')) != Anope::string::npos)
- {
- /* this should never happen */
- if (user > host)
- return 0;
- tmp = nick;
- }
- else
- /* We have user@host. Add nick wildcard. */
- tmp = "*!" + nick;
- }
- /* We only got a nick.. */
- else
- tmp = nick + "!*@*";
- std::list<IgnoreData *>::iterator ign = ignore.begin(), ign_end = ignore.end();
- for (; ign != ign_end; ++ign)
- if (tmp.equals_ci((*ign)->mask))
- break;
- /* No matching ignore found. */
- if (ign == ign_end)
- return 0;
- Log(LOG_DEBUG) << "Deleting ignore entry " << (*ign)->mask;
- /* Delete the entry and all references to it. */
- delete *ign;
- ignore.erase(ign);
- return 1;
-}
-
-/*************************************************************************/
-
-/**
- * Clear the ignorelist.
- * @return The number of entries deleted.
- */
-int clear_ignores()
-{
- if (ignore.empty())
- return 0;
- for (std::list<IgnoreData *>::iterator ign = ignore.begin(), ign_end = ignore.end(); ign != ign_end; ++ign)
- {
- Log(LOG_DEBUG) << "Deleting ignore entry " << (*ign)->mask;
- delete *ign;
- }
- int deleted = ignore.size();
- ignore.clear();
- return deleted;
-}
-
/** Main process routine
* @param buffer A raw line from the uplink to do things with
*/
diff --git a/src/protocol.cpp b/src/protocol.cpp
index cc4112970..9d10c9a0d 100644
--- a/src/protocol.cpp
+++ b/src/protocol.cpp
@@ -382,7 +382,7 @@ bool IRCdMessage::OnPrivmsg(const Anope::string &source, const std::vector<Anope
if (bi)
ircdproto->SendMessage(bi, source, "%s", GetString(USER_RECORD_NOT_FOUND).c_str());
- return MOD_CONT;
+ return true;
}
if (receiver[0] == '#' && !Config->s_BotServ.empty())
@@ -394,19 +394,6 @@ bool IRCdMessage::OnPrivmsg(const Anope::string &source, const std::vector<Anope
}
else
{
- /* Check if we should ignore. Operators always get through. */
- if (allow_ignore && !u->HasMode(UMODE_OPER))
- {
- if (get_ignore(source))
- {
- Anope::string target = myStrGetToken(message, ' ', 0);
- BotInfo *bi = findbot(target);
- if (bi)
- Log(bi) << "Ignored message from " << source << " using command " << target;
- return MOD_CONT;
- }
- }
-
/* If a server is specified (nick@server format), make sure it matches
* us, and strip it off. */
Anope::string botname = receiver;
@@ -416,22 +403,27 @@ bool IRCdMessage::OnPrivmsg(const Anope::string &source, const std::vector<Anope
Anope::string servername(receiver.begin() + s + 1, receiver.end());
botname = botname.substr(0, s);
if (!servername.equals_ci(Config->ServerName))
- return MOD_CONT;
+ return true;
}
else if (Config->UseStrictPrivMsg)
{
BotInfo *bi = findbot(receiver);
if (!bi)
- return MOD_CONT;
+ return true;
Log(LOG_DEBUG) << "Ignored PRIVMSG without @ from " << source;
u->SendMessage(bi, INVALID_TARGET, receiver.c_str(), receiver.c_str(), Config->ServerName.c_str(), receiver.c_str());
- return MOD_CONT;
+ return true;
}
BotInfo *bi = findbot(botname);
if (bi)
{
+ EventReturn MOD_RESULT;
+ FOREACH_RESULT(I_OnBotPrivmsg, OnBotPrivmsg(u, bi, message));
+ if (MOD_RESULT == EVENT_STOP)
+ return true;
+
if (message[0] == '\1' && message[message.length() - 1] == '\1')
{
if (message.substr(0, 6).equals_ci("\1PING "))