本文整理汇总了C++中CNick::NickEquals方法的典型用法代码示例。如果您正苦于以下问题:C++ CNick::NickEquals方法的具体用法?C++ CNick::NickEquals怎么用?C++ CNick::NickEquals使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CNick
的用法示例。
在下文中一共展示了CNick::NickEquals方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandleMessage
void HandleMessage(CNick& Nick, const CString& sMessage) {
CString sNickServName = (!GetNV("NickServName").empty())
? GetNV("NickServName")
: "NickServ";
if (!GetNV("Password").empty() && Nick.NickEquals(sNickServName) &&
(sMessage.find("msg") != CString::npos ||
sMessage.find("authenticate") != CString::npos ||
sMessage.find("choose a different nickname") != CString::npos ||
sMessage.find("please choose a different nick") != CString::npos ||
sMessage.find("If this is your nick, identify yourself with") !=
CString::npos ||
sMessage.find("If this is your nick, type") != CString::npos ||
sMessage.find("This is a registered nickname, please identify") !=
CString::npos ||
sMessage.StripControls_n().find(
"type /NickServ IDENTIFY password") != CString::npos ||
sMessage.StripControls_n().find(
"type /msg NickServ IDENTIFY password") != CString::npos) &&
sMessage.AsUpper().find("IDENTIFY") != CString::npos &&
sMessage.find("help") == CString::npos) {
MCString msValues;
msValues["password"] = GetNV("Password");
PutIRC(CString::NamedFormat(GetNV("IdentifyCmd"), msValues));
} else if(Nick.NickEquals(sNickServName) && m_bJoinAfterIdentified &&
(sMessage.find("Password accepted") != CString::npos ||
sMessage.find("now recognized") != CString::npos ||
sMessage.find("now identified") != CString::npos ||
sMessage.find("now logged in as") != CString::npos)) {
m_bIdentified = true;
GetNetwork()->JoinChans();
}
}
示例2: OnQuit
void OnQuit(const CNick& Nick, const CString& sMessage,
const vector<CChan*>& vChans) override {
// If someone with the nick we want quits, be fast and get the nick
if (Nick.NickEquals(GetNick())) {
KeepNick();
}
}
示例3: OnInvite
EModRet OnInvite(const CNick& Nick, const CString& sChan) override {
if (!Nick.NickEquals("Q") ||
!Nick.GetHost().Equals("CServe.quakenet.org"))
return CONTINUE;
if (m_bJoinOnInvite) GetNetwork()->AddChan(sChan, false);
return CONTINUE;
}
示例4:
void OnOp2(const CNick* pOpNick, const CNick& Nick, CChan& Channel, bool bNoChange) override {
if (Nick.NickEquals(GetNetwork()->GetNick())) {
const map<CString,CNick>& msNicks = Channel.GetNicks();
for (const auto& it : msNicks) {
if (!it.second.HasPerm(CChan::Voice)) {
CheckAutoVoice(it.second, Channel);
}
}
}
}
示例5: OnNick
void OnNick(const CNick& Nick, const CString& sNewNick,
const vector<CChan*>& vChans) override {
if (sNewNick == GetNetwork()->GetIRCSock()->GetNick()) {
// We are changing our own nick
if (Nick.NickEquals(GetNick())) {
// We are changing our nick away from the conf setting.
// Let's assume the user wants this and disable
// this module (to avoid fighting nickserv).
Disable();
} else if (sNewNick.Equals(GetNick())) {
// We are changing our nick to the conf setting,
// so we don't need that timer anymore.
Disable();
}
return;
}
// If the nick we want is free now, be fast and get the nick
if (Nick.NickEquals(GetNick())) {
KeepNick();
}
}
示例6: AddNick
bool CChan::AddNick(const CString& sNick) {
const char* p = sNick.c_str();
CString sPrefix, sTmp, sIdent, sHost;
while (m_pNetwork->GetIRCSock()->IsPermChar(*p)) {
sPrefix += *p;
if (!*++p) {
return false;
}
}
sTmp = p;
// The UHNames extension gets us [email protected] instead of just plain nick
sIdent = sTmp.Token(1, true, "!");
sHost = sIdent.Token(1, true, "@");
sIdent = sIdent.Token(0, false, "@");
// Get the nick
sTmp = sTmp.Token(0, false, "!");
CNick tmpNick(sTmp);
CNick* pNick = FindNick(sTmp);
if (!pNick) {
pNick = &tmpNick;
pNick->SetNetwork(m_pNetwork);
}
if (!sIdent.empty())
pNick->SetIdent(sIdent);
if (!sHost.empty())
pNick->SetHost(sHost);
for (CString::size_type i = 0; i < sPrefix.length(); i++) {
pNick->AddPerm(sPrefix[i]);
}
if (pNick->NickEquals(m_pNetwork->GetCurNick())) {
for (CString::size_type i = 0; i < sPrefix.length(); i++) {
AddPerm(sPrefix[i]);
}
}
m_msNicks[pNick->GetNick()] = *pNick;
return true;
}
示例7: HandleMessage
void HandleMessage(CNick& Nick, const CString& sMessage) {
CString sNickServName = (!GetNV("NickServName").empty()) ? GetNV("NickServName") : "NickServ";
if (!GetNV("Password").empty()
&& Nick.NickEquals(sNickServName)
&& (sMessage.find("msg") != CString::npos
|| sMessage.find("authenticate") != CString::npos
|| sMessage.find("choose a different nickname") != CString::npos
|| sMessage.find("please choose a different nick") != CString::npos
|| sMessage.find("If this is your nick, identify yourself with") != CString::npos
|| sMessage.find("If this is your nick, type") != CString::npos
|| sMessage.find("This is a registered nickname, please identify") != CString::npos
|| sMessage.StripControls_n().find("type /NickServ IDENTIFY password") != CString::npos)
&& sMessage.AsUpper().find("IDENTIFY") != CString::npos
&& sMessage.find("help") == CString::npos) {
MCString msValues;
msValues["password"] = GetNV("Password");
PutIRC(CString::NamedFormat(GetNV("IdentifyCmd"), msValues));
}
}
示例8: IsSelf
bool IsSelf(const CNick& Nick) {
return Nick.NickEquals(GetNetwork()->GetCurNick());
}
示例9: HandleMessage
EModRet HandleMessage(const CNick& Nick, CString sMessage) {
if (!Nick.NickEquals("Q") ||
!Nick.GetHost().Equals("CServe.quakenet.org"))
return CONTINUE;
sMessage.Trim();
#if Q_DEBUG_COMMUNICATION
PutModule("[ZNC <-- Q] " + sMessage);
#endif
// WHOAMI
if (sMessage.find("WHOAMI is only available to authed users") !=
CString::npos) {
m_bAuthed = false;
Auth();
m_bCatchResponse = m_bRequestedWhoami;
} else if (sMessage.find("Information for user") != CString::npos) {
m_bAuthed = true;
m_msChanModes.clear();
m_bCatchResponse = m_bRequestedWhoami;
m_bRequestedWhoami = true;
} else if (m_bRequestedWhoami && sMessage.WildCmp("#*")) {
CString sChannel = sMessage.Token(0);
CString sFlags = sMessage.Token(1, true).Trim_n().TrimLeft_n("+");
m_msChanModes[sChannel] = sFlags;
} else if (m_bRequestedWhoami && m_bCatchResponse &&
(sMessage.Equals("End of list.") ||
sMessage.Equals(
"account, or HELLO to create an account."))) {
m_bRequestedWhoami = m_bCatchResponse = false;
return HALT;
}
// AUTH
else if (sMessage.Equals("Username or password incorrect.")) {
m_bAuthed = false;
PutModule("Auth failed: " + sMessage);
return HALT;
} else if (sMessage.WildCmp("You are now logged in as *.")) {
m_bAuthed = true;
PutModule("Auth successful: " + sMessage);
WhoAmI();
return HALT;
} else if (m_bRequestedChallenge &&
sMessage.Token(0).Equals("CHALLENGE")) {
m_bRequestedChallenge = false;
if (sMessage.find("not available once you have authed") !=
CString::npos) {
m_bAuthed = true;
} else {
if (sMessage.find("HMAC-SHA-256") != CString::npos) {
ChallengeAuth(sMessage.Token(1));
} else {
PutModule(
"Auth failed: Q does not support HMAC-SHA-256 for "
"CHALLENGEAUTH, falling back to standard AUTH.");
SetUseChallenge(false);
Auth();
}
}
return HALT;
}
// prevent buffering of Q's responses
return !m_bCatchResponse && GetUser()->IsUserAttached() ? CONTINUE
: HALT;
}
示例10: ModeChange
void CChan::ModeChange(const CString& sModes, const CNick* pOpNick) {
CString sModeArg = sModes.Token(0);
CString sArgs = sModes.Token(1, true);
bool bAdd = true;
/* Try to find a CNick* from this channel so that pOpNick->HasPerm()
* works as expected. */
if (pOpNick) {
CNick* OpNick = FindNick(pOpNick->GetNick());
/* If nothing was found, use the original pOpNick, else use the
* CNick* from FindNick() */
if (OpNick)
pOpNick = OpNick;
}
if (pOpNick) {
NETWORKMODULECALL(OnRawMode(*pOpNick, *this, sModeArg, sArgs), m_pNetwork->GetUser(), m_pNetwork, NULL, NOTHING);
}
for (unsigned int a = 0; a < sModeArg.size(); a++) {
const unsigned char& uMode = sModeArg[a];
if (uMode == '+') {
bAdd = true;
} else if (uMode == '-') {
bAdd = false;
} else if (m_pNetwork->GetIRCSock()->IsPermMode(uMode)) {
CString sArg = GetModeArg(sArgs);
CNick* pNick = FindNick(sArg);
if (pNick) {
unsigned char uPerm = m_pNetwork->GetIRCSock()->GetPermFromMode(uMode);
if (uPerm) {
bool bNoChange = (pNick->HasPerm(uPerm) == bAdd);
if (bAdd) {
pNick->AddPerm(uPerm);
if (pNick->NickEquals(m_pNetwork->GetCurNick())) {
AddPerm(uPerm);
}
} else {
pNick->RemPerm(uPerm);
if (pNick->NickEquals(m_pNetwork->GetCurNick())) {
RemPerm(uPerm);
}
}
if (uMode && pOpNick) {
NETWORKMODULECALL(OnChanPermission(*pOpNick, *pNick, *this, uMode, bAdd, bNoChange), m_pNetwork->GetUser(), m_pNetwork, NULL, NOTHING);
if (uMode == CChan::M_Op) {
if (bAdd) {
NETWORKMODULECALL(OnOp(*pOpNick, *pNick, *this, bNoChange), m_pNetwork->GetUser(), m_pNetwork, NULL, NOTHING);
} else {
NETWORKMODULECALL(OnDeop(*pOpNick, *pNick, *this, bNoChange), m_pNetwork->GetUser(), m_pNetwork, NULL, NOTHING);
}
} else if (uMode == CChan::M_Voice) {
if (bAdd) {
NETWORKMODULECALL(OnVoice(*pOpNick, *pNick, *this, bNoChange), m_pNetwork->GetUser(), m_pNetwork, NULL, NOTHING);
} else {
NETWORKMODULECALL(OnDevoice(*pOpNick, *pNick, *this, bNoChange), m_pNetwork->GetUser(), m_pNetwork, NULL, NOTHING);
}
}
}
}
}
} else {
bool bList = false;
CString sArg;
switch (m_pNetwork->GetIRCSock()->GetModeType(uMode)) {
case CIRCSock::ListArg:
bList = true;
sArg = GetModeArg(sArgs);
break;
case CIRCSock::HasArg:
sArg = GetModeArg(sArgs);
break;
case CIRCSock::NoArg:
break;
case CIRCSock::ArgWhenSet:
if (bAdd) {
sArg = GetModeArg(sArgs);
}
break;
}
if (pOpNick) {
bool bNoChange;
if (bList) {
bNoChange = false;
} else if (bAdd) {
bNoChange = HasMode(uMode) && GetModeArg(uMode) == sArg;
} else {
bNoChange = !HasMode(uMode);
}
NETWORKMODULECALL(OnMode(*pOpNick, *this, uMode, sArg, bAdd, bNoChange), m_pNetwork->GetUser(), m_pNetwork, NULL, NOTHING);
//.........这里部分代码省略.........
示例11: ModeChange
void CChan::ModeChange(const CString& sModes, const CNick* pOpNick) {
CString sModeArg = sModes.Token(0);
CString sArgs = sModes.Token(1, true);
bool bAdd = true;
/* Try to find a CNick* from this channel so that pOpNick->HasPerm()
* works as expected. */
if (pOpNick) {
CNick* OpNick = FindNick(pOpNick->GetNick());
/* If nothing was found, use the original pOpNick, else use the
* CNick* from FindNick() */
if (OpNick) pOpNick = OpNick;
}
NETWORKMODULECALL(OnRawMode2(pOpNick, *this, sModeArg, sArgs),
m_pNetwork->GetUser(), m_pNetwork, nullptr, NOTHING);
for (unsigned int a = 0; a < sModeArg.size(); a++) {
const char& cMode = sModeArg[a];
if (cMode == '+') {
bAdd = true;
} else if (cMode == '-') {
bAdd = false;
} else if (m_pNetwork->GetIRCSock()->IsPermMode(cMode)) {
CString sArg = GetModeArg(sArgs);
CNick* pNick = FindNick(sArg);
if (pNick) {
char cPerm =
m_pNetwork->GetIRCSock()->GetPermFromMode(cMode);
if (cPerm) {
bool bNoChange = (pNick->HasPerm(cPerm) == bAdd);
if (bAdd) {
pNick->AddPerm(cPerm);
if (pNick->NickEquals(m_pNetwork->GetCurNick())) {
AddPerm(cPerm);
}
} else {
pNick->RemPerm(cPerm);
if (pNick->NickEquals(m_pNetwork->GetCurNick())) {
RemPerm(cPerm);
}
}
NETWORKMODULECALL(OnChanPermission3(pOpNick, *pNick, *this,
cMode, bAdd, bNoChange),
m_pNetwork->GetUser(), m_pNetwork,
nullptr, NOTHING);
if (cMode == CChan::M_Op) {
if (bAdd) {
NETWORKMODULECALL(
OnOp2(pOpNick, *pNick, *this, bNoChange),
m_pNetwork->GetUser(), m_pNetwork, nullptr,
NOTHING);
} else {
NETWORKMODULECALL(
OnDeop2(pOpNick, *pNick, *this, bNoChange),
m_pNetwork->GetUser(), m_pNetwork, nullptr,
NOTHING);
}
} else if (cMode == CChan::M_Voice) {
if (bAdd) {
NETWORKMODULECALL(
OnVoice2(pOpNick, *pNick, *this, bNoChange),
m_pNetwork->GetUser(), m_pNetwork, nullptr,
NOTHING);
} else {
NETWORKMODULECALL(
OnDevoice2(pOpNick, *pNick, *this, bNoChange),
m_pNetwork->GetUser(), m_pNetwork, nullptr,
NOTHING);
}
}
}
}
} else {
bool bList = false;
CString sArg;
switch (m_pNetwork->GetIRCSock()->GetModeType(cMode)) {
case CIRCSock::ListArg:
bList = true;
sArg = GetModeArg(sArgs);
break;
case CIRCSock::HasArg:
sArg = GetModeArg(sArgs);
break;
case CIRCSock::NoArg:
break;
case CIRCSock::ArgWhenSet:
if (bAdd) {
sArg = GetModeArg(sArgs);
}
break;
//.........这里部分代码省略.........