diff options
author | Adam <Adam@anope.org> | 2010-12-23 18:39:54 -0500 |
---|---|---|
committer | Adam <Adam@anope.org> | 2010-12-23 18:39:54 -0500 |
commit | 3009540a00d392912affea5f2545134e2f657c01 (patch) | |
tree | 15be0334f0d50dd67e0ce86e4e9f6ea273225ae3 /src | |
parent | 265006b69176e1d8130284c63bcb50a1b67a426f (diff) |
Rewrote the ignore code. Adds creator and reason to /os ignore list.
Diffstat (limited to 'src')
-rw-r--r-- | src/botserv.cpp | 4 | ||||
-rw-r--r-- | src/channels.cpp | 15 | ||||
-rw-r--r-- | src/language.cpp | 18 | ||||
-rw-r--r-- | src/memoserv.cpp | 4 | ||||
-rw-r--r-- | src/misc.cpp | 4 | ||||
-rw-r--r-- | src/process.cpp | 205 | ||||
-rw-r--r-- | src/protocol.cpp | 26 |
7 files changed, 23 insertions, 253 deletions
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 ")) |