+ /* QUIT with no reason: nothing to do */
+ if (parameters.size() < 1)
+ return MOD_RES_PASSTHRU;
+
+ parting = false;
+ flags = FLAG_QUIT;
+ }
+ else if (command == "PART")
+ {
+ /* PART with no reason: nothing to do */
+ if (parameters.size() < 2)
+ return MOD_RES_PASSTHRU;
+
+ if (exemptfromfilter.find(parameters[0]) != exemptfromfilter.end())
+ return MOD_RES_PASSTHRU;
+
+ parting = true;
+ flags = FLAG_PART;
+ }
+ else
+ /* We're only messing with PART and QUIT */
+ return MOD_RES_PASSTHRU;
+
+ FilterResult* f = this->FilterMatch(user, parameters[parting ? 1 : 0], flags);
+ if (!f)
+ /* PART or QUIT reason doesnt match a filter */
+ return MOD_RES_PASSTHRU;
+
+ /* We cant block a part or quit, so instead we change the reason to 'Reason filtered' */
+ parameters[parting ? 1 : 0] = "Reason filtered";
+
+ /* We're blocking, OR theyre quitting and its a KILL action
+ * (we cant kill someone whos already quitting, so filter them anyway)
+ */
+ if ((f->action == FA_BLOCK) || (((!parting) && (f->action == FA_KILL))) || (f->action == FA_SILENT))
+ {
+ return MOD_RES_PASSTHRU;
+ }
+ else
+ {
+ /* Are they parting, if so, kill is applicable */
+ if ((parting) && (f->action == FA_KILL))
+ {
+ user->WriteServ("NOTICE %s :*** Your PART message was filtered: %s", user->nick.c_str(), f->reason.c_str());
+ ServerInstance->Users->QuitUser(user, "Filtered: " + f->reason);
+ }
+ if (f->action == FA_GLINE)
+ {
+ /* Note: We gline *@IP so that if their host doesnt resolve the gline still applies. */
+ GLine* gl = new GLine(ServerInstance->Time(), f->gline_time, ServerInstance->Config->ServerName.c_str(), f->reason.c_str(), "*", user->GetIPString());
+ if (ServerInstance->XLines->AddLine(gl,NULL))
+ {
+ ServerInstance->XLines->ApplyLines();
+ }
+ else
+ delete gl;
+ }
+ return MOD_RES_DENY;