コード例 #1
0
void NmdcHub::kick(const User::Ptr& aUser, const string& aMsg) {
	checkstate(); 
	dcdebug("NmdcHub::kick\n");
	static const char str[] = 
		"$To: %s From: %s $<%s> You are being kicked because: %s|<%s> %s is kicking %s because: %s|";
	string msg2 = toNmdc(Util::validateMessage(aMsg, false));
	
	char* tmp = new char[sizeof(str) + 2*aUser->getNick().length() + 2*msg2.length() + 4*getNick().length()];
	const char* u = aUser->getNick().c_str();
	const char* n = getNick().c_str();
	const char* m = msg2.c_str();
	sprintf(tmp, str, u, n, n, m, n, n, u, m);
	send(tmp);
	delete[] tmp;
	
	// Short, short break to allow the message to reach the NmdcHub...
	Thread::sleep(200);
	send("$Kick " + toNmdc(aUser->getNick()) + "|");
}
コード例 #2
0
ファイル: AdcHub.cpp プロジェクト: BackupTheBerlios/linuxdcpp
void AdcHub::handle(Command::MSG, Command& c) throw() {
	if(c.getFrom().isZero() || c.getParameters().empty())
		return;
	User::Ptr p = ClientManager::getInstance()->getUser(c.getFrom(), false);
	if(!p)
		return;
	if(c.getParameters().size() == 2 && c.getParameters()[1] == "PM") { // add PM<group-cid> as well
		const string& msg = c.getParameters()[0];
		if(c.getFrom() == getMe()->getCID()) {
			p = ClientManager::getInstance()->getUser(c.getTo(), false);
			if(!p)
				return;
		}
		fire(ClientListener::PrivateMessage(), this, p, msg);
	} else {
		string msg = '<' + p->getNick() + "> " + c.getParameters()[0];
		fire(ClientListener::Message(), this, msg);
	}		
}