Пример #1
0
	virtual int ProcessMessages(userrec* user,chanrec* chan,std::string &text)
	{
		if (!IS_LOCAL(user) || CHANOPS_EXEMPT(ServerInstance, 'g') && chan->GetStatus(user) == STATUS_OP)
			return 0;

		// Create a copy of the string in irc::string
		irc::string line = text.c_str();

		modelist* list;
		chan->GetExt(cf->GetInfoKey(), list);

		if (list)
		{
			for (modelist::iterator i = list->begin(); i != list->end(); i++)
			{
				if (line.find(i->mask.c_str()) != std::string::npos)
				{
					user->WriteServ("936 %s %s %s :Your message contained a censored word, and was blocked",user->nick, chan->name, i->mask.c_str());
					return 1;
				}
			}
		}

		return 0;
	}
Пример #2
0
	void ProcessMessages(userrec* user,chanrec* dest, const std::string &text)
	{
		if (!IS_LOCAL(user) || CHANOPS_EXEMPT(ServerInstance, 'f') && dest->GetStatus(user) == STATUS_OP)
		{
			return;
		}

		floodsettings *f;
		if (dest->GetExt("flood", f))
		{
			f->addmessage(user);
			if (f->shouldkick(user))
			{
				/* Youre outttta here! */
				f->clear(user);
				if (f->ban)
				{
					const char* parameters[3];
					parameters[0] = dest->name;
					parameters[1] = "+b";
					parameters[2] = user->MakeWildHost();
					ServerInstance->SendMode(parameters,3,user);
					std::deque<std::string> n;
					/* Propogate the ban to other servers.
					 * We dont know what protocol we may be using,
					 * so this event is picked up by our protocol
					 * module and formed into a ban command that
					 * suits the protocol in use.
					 */
					n.push_back(dest->name);
					n.push_back("+b");
					n.push_back(user->MakeWildHost());
					Event rmode((char *)&n, NULL, "send_mode");
					rmode.Send(ServerInstance);
				}
				char kickmessage[MAXBUF];
				snprintf(kickmessage, MAXBUF, "Channel flood triggered (limit is %d lines in %d secs)", f->lines, f->secs);
				if (!dest->ServerKickUser(user, kickmessage, true))
					delete dest;
			}
		}
	}
Пример #3
0
	// format of a config entry is <badword text="shit" replace="poo">
	virtual int OnUserPreMessage(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
	{
		if (!IS_LOCAL(user))
			return 0;

		bool active = false;

		if (target_type == TYPE_USER)
			active = ((User*)dest)->IsModeSet('G');
		else if (target_type == TYPE_CHANNEL)
		{
			active = ((Channel*)dest)->IsModeSet('G');
			Channel* c = (Channel*)dest;
			if (CHANOPS_EXEMPT(ServerInstance, 'G') && c->GetStatus(user) == STATUS_OP)
			{
				return 0;
			}
		}

		if (!active)
			return 0;

		irc::string text2 = text.c_str();
		for (censor_t::iterator index = censors.begin(); index != censors.end(); index++)
		{
			if (text2.find(index->first) != irc::string::npos)
			{
				if (index->second.empty())
				{
					user->WriteNumeric(ERR_WORDFILTERED, "%s %s %s :Your message contained a censored word, and was blocked", user->nick.c_str(), ((Channel*)dest)->name.c_str(), index->first.c_str());
					return 1;
				}

				SearchAndReplace(text2, index->first, index->second);
			}
		}
		text = text2.c_str();
		return 0;
	}