mirror of
https://github.com/znc/znc.git
synced 2026-03-28 17:42:41 +01:00
Added GetCommonChans()
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@159 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
22
Nick.cpp
22
Nick.cpp
@@ -1,4 +1,6 @@
|
||||
#include "Nick.h"
|
||||
#include "Chan.h"
|
||||
#include "User.h"
|
||||
|
||||
CNick::CNick() {
|
||||
m_bIsOp = false;
|
||||
@@ -34,6 +36,26 @@ void CNick::Parse(const string& sNickMask) {
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int CNick::GetCommonChans(vector<CChan*>& vRetChans, CUser* pUser) const {
|
||||
vRetChans.clear();
|
||||
|
||||
const vector<CChan*>& vChans = pUser->GetChans();
|
||||
|
||||
for (unsigned int a = 0; a < vChans.size(); a++) {
|
||||
CChan* pChan = vChans[a];
|
||||
const map<string,CNick*>& msNicks = pChan->GetNicks();
|
||||
|
||||
for (map<string,CNick*>::const_iterator it = msNicks.begin(); it != msNicks.end(); it++) {
|
||||
if (strcasecmp(it->first.c_str(), m_sNick.c_str()) == 0) {
|
||||
vRetChans.push_back(pChan);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return vRetChans.size();
|
||||
}
|
||||
|
||||
void CNick::SetNick(const string& s) { m_sNick = s; }
|
||||
void CNick::SetIdent(const string& s) { m_sIdent = s; }
|
||||
void CNick::SetHost(const string& s) { m_sHost = s; }
|
||||
|
||||
8
Nick.h
8
Nick.h
@@ -1,8 +1,15 @@
|
||||
#ifndef _NICK_H
|
||||
#define _NICK_H
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
using std::string;
|
||||
using std::vector;
|
||||
|
||||
// Forward Decl
|
||||
class CUser;
|
||||
class CChan;
|
||||
// !Forward Decl
|
||||
|
||||
class CNick
|
||||
{
|
||||
@@ -13,6 +20,7 @@ public:
|
||||
|
||||
void Parse(const string& sNickMask);
|
||||
string GetHostMask() const;
|
||||
unsigned int GetCommonChans(vector<CChan*>& vChans, CUser* pUser) const;
|
||||
|
||||
// Setters
|
||||
void SetNick(const string& s);
|
||||
|
||||
Reference in New Issue
Block a user