コード例 #1
0
ファイル: blockuser.cpp プロジェクト: ZachBeta/znc
	bool Block(const CString& sUser) {
		CUser *pUser = CZNC::Get().FindUser(sUser);

		if (!pUser)
			return false;

		// Disconnect all clients
		vector<CClient*>& vpClients = pUser->GetClients();
		vector<CClient*>::iterator it;
		for (it = vpClients.begin(); it != vpClients.end(); ++it) {
			(*it)->PutStatusNotice(MESSAGE);
			(*it)->Close(Csock::CLT_AFTERWRITE);
		}

		// Disconnect from IRC...
		CIRCSock *pIRCSock = pUser->GetIRCSock();
		if (pIRCSock) {
			pIRCSock->Quit();
		}

		// ...and don't reconnect
		pUser->SetIRCConnectEnabled(false);

		SetNV(pUser->GetUserName(), "");
		return true;
	}
コード例 #2
0
ファイル: lastseen.cpp プロジェクト: eatnumber1/znc
	virtual bool OnWebRequest(CWebSock& WebSock, const CString& sPageName, CTemplate& Tmpl) {
		if (sPageName == "index") {
			CModules& GModules = CZNC::Get().GetModules();
			Tmpl["WebAdminLoaded"] = CString(GModules.FindModule("webadmin") != NULL);

			MTimeMulti mmSorted;
			const MUsers& mUsers = CZNC::Get().GetUserMap();

			for (MUsers::const_iterator uit = mUsers.begin(); uit != mUsers.end(); ++uit) {
				mmSorted.insert(pair<time_t, CUser*>(GetTime(uit->second), uit->second));
			}

			for (MTimeMulti::const_iterator it = mmSorted.begin(); it != mmSorted.end(); ++it) {
				CUser *pUser = it->second;
				CTemplate& Row = Tmpl.AddRow("UserLoop");

				Row["Username"] = pUser->GetUserName();
				Row["IsSelf"] = CString(pUser == WebSock.GetSession()->GetUser());
				Row["LastSeen"] = FormatLastSeen(pUser, "never");

				Row["Info"] = CString(pUser->GetClients().size()) +
					" client" + CString(pUser->GetClients().size() == 1 ? "" : "s");
				if (!pUser->IsIRCConnected()) {
					Row["Info"] += ", not connected to IRC";
				} else {
					unsigned int uChans = 0;
					const vector<CChan*>& vChans = pUser->GetChans();
					for (unsigned int a = 0; a < vChans.size(); ++a) {
						if (vChans[a]->IsOn()) ++uChans;
					}
					unsigned int n = uChans;
					Row["Info"] += ", joined to " + CString(uChans);
					if(uChans != vChans.size()) {
						Row["Info"] += " out of " + CString(vChans.size()) + " configured";
						n = vChans.size();
					}
					Row["Info"] += " channel" + CString(n == 1 ? "" : "s");
				}
			}

			return true;
		}

		return false;
	}
コード例 #3
0
ファイル: queryloop.cpp プロジェクト: mittwinter/znc-modules
		virtual EModRet OnUserMsg( CString &target, CString &message ) {
			CUser *user = GetUser();
			if( user != NULL ) {
				bool targetIsChannel = false;
				for( std::vector< CChan * >::const_iterator it = user->GetChans().begin(); it != user->GetChans().end(); it++ ) {
					if( target == (*it)->GetName() ) {
						targetIsChannel = true;
						break;
					}
				}
				if( !targetIsChannel ) {
					std::vector< CClient * > &clients = user->GetClients();
					for( std::vector< CClient * >::iterator it = clients.begin(); it != clients.end(); it++ ) {
						if( *it != m_pClient ) {
							(*it)->PutClient( ":" + target + " PRIVMSG " + user->GetCurNick() + " :<" + user->GetCurNick() + "> " + message );
						}
					}
				}
			}
			return CONTINUE;
		}