CIRCSock::OnQuitMessage() handler

This commit is contained in:
J-P Nurmi
2015-09-05 01:43:55 +02:00
parent 41a9b36687
commit a0a2b0fb4e
2 changed files with 32 additions and 28 deletions

View File

@@ -515,34 +515,7 @@ void CIRCSock::ReadLine(const CString& sData) {
}
} else if (Message.GetType() == CMessage::Type::Quit) {
CQuitMessage& QuitMsg = static_cast<CQuitMessage&>(Message);
bool bIsVisible = false;
// :nick!ident@host.com QUIT :message
if (Nick.NickEquals(GetNick())) {
m_pNetwork->PutStatus("You quit [" + QuitMsg.GetReason() + "]");
// We don't call module hooks and we don't
// forward this quit to clients (Some clients
// disconnect if they receive such a QUIT)
return;
}
vector<CChan*> vFoundChans;
const vector<CChan*>& vChans = m_pNetwork->GetChans();
for (CChan* pChan : vChans) {
if (pChan->RemNick(Nick.GetNick())) {
vFoundChans.push_back(pChan);
if (!pChan->IsDetached()) {
bIsVisible = true;
}
}
}
IRCSOCKMODULECALL(OnQuitMessage(QuitMsg, vFoundChans), NOTHING);
if (!bIsVisible) {
if (OnQuitMessage(QuitMsg)) {
return;
}
} else if (Message.GetType() == CMessage::Type::Join) {
@@ -1089,6 +1062,36 @@ bool CIRCSock::OnNickMessage(CNickMessage& Message) {
return !bIsVisible;
}
bool CIRCSock::OnQuitMessage(CQuitMessage& Message) {
const CNick& Nick = Message.GetNick();
bool bIsVisible = false;
if (Nick.NickEquals(GetNick())) {
m_pNetwork->PutStatus("You quit [" + Message.GetReason() + "]");
// We don't call module hooks and we don't
// forward this quit to clients (Some clients
// disconnect if they receive such a QUIT)
return true;
}
vector<CChan*> vFoundChans;
const vector<CChan*>& vChans = m_pNetwork->GetChans();
for (CChan* pChan : vChans) {
if (pChan->RemNick(Nick.GetNick())) {
vFoundChans.push_back(pChan);
if (!pChan->IsDetached()) {
bIsVisible = true;
}
}
}
IRCSOCKMODULECALL(OnQuitMessage(Message, vFoundChans), NOTHING);
return !bIsVisible;
}
void CIRCSock::PutIRC(const CString& sLine) {
// Only print if the line won't get sent immediately (same condition as in TrySend()!)
if (m_bFloodProtection && m_iSendsAllowed <= 0) {