Esempio n. 1
0
/* returns a list of DIRECT servernames for a specific channel */
void SpanningTreeUtilities::GetListOfServersForChannel(Channel* c, TreeSocketSet& list, char status, const CUList& exempt_list)
{
	unsigned int minrank = 0;
	if (status)
	{
		PrefixMode* mh = ServerInstance->Modes->FindPrefix(status);
		if (mh)
			minrank = mh->GetPrefixRank();
	}

	const UserMembList *ulist = c->GetUsers();

	for (UserMembCIter i = ulist->begin(); i != ulist->end(); i++)
	{
		if (IS_LOCAL(i->first))
			continue;

		if (minrank && i->second->getRank() < minrank)
			continue;

		if (exempt_list.find(i->first) == exempt_list.end())
		{
			TreeServer* best = TreeServer::Get(i->first);
			list.insert(best->GetSocket());
		}
	}
	return;
}
Esempio n. 2
0
void SpanningTreeUtilities::SendChannelMessage(const std::string& prefix, Channel* target, const std::string& text, char status, const CUList& exempt_list, const char* message_type, TreeSocket* omit)
{
	CmdBuilder msg(prefix, message_type);
	if (status == 0)
		status = ' ';
	msg.push(status).push_raw(target->name).push_last(text);

	TreeSocketSet list;
	this->GetListOfServersForChannel(target, list, status, exempt_list);
	for (TreeSocketSet::iterator i = list.begin(); i != list.end(); ++i)
	{
		TreeSocket* Sock = *i;
		if (Sock != omit)
			Sock->WriteLine(msg);
	}
}
Esempio n. 3
0
void SpanningTreeUtilities::SendChannelMessage(const std::string& prefix, Channel* target, const std::string& text, char status, const CUList& exempt_list, const char* message_type, TreeSocket* omit)
{
	std::string raw(":");
	raw.append(prefix).append(1, ' ').append(message_type).push_back(' ');
	if (status)
		raw.push_back(status);
	raw.append(target->name).append(" :").append(text);

	TreeSocketSet list;
	this->GetListOfServersForChannel(target, list, status, exempt_list);
	for (TreeSocketSet::iterator i = list.begin(); i != list.end(); ++i)
	{
		TreeSocket* Sock = *i;
		if (Sock != omit)
			Sock->WriteLine(raw);
	}
}