本文整理汇总了C++中CChan::IsDetached方法的典型用法代码示例。如果您正苦于以下问题:C++ CChan::IsDetached方法的具体用法?C++ CChan::IsDetached怎么用?C++ CChan::IsDetached使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CChan
的用法示例。
在下文中一共展示了CChan::IsDetached方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Cleanup
void Cleanup() {
Limits::iterator it;
time_t now = time(NULL);
for (it = m_chans.begin(); it != m_chans.end(); ++it) {
// The timeout for this channel did not expire yet?
if (it->second.first + (time_t)m_iThresholdSecs >= now)
continue;
CChan *pChan = m_pNetwork->FindChan(it->first);
if (it->second.second >= m_iThresholdMsgs
&& pChan && pChan->IsDetached()) {
// The channel is detached and it is over the
// messages limit. Since we only track those
// limits for non-detached channels or for
// channels which we detached, this means that
// we detached because of a flood.
PutModule("Flood in [" + pChan->GetName() + "] is over, "
"re-attaching...");
// No buffer playback, makes sense, doesn't it?
pChan->ClearBuffer();
pChan->JoinUser();
}
Limits::iterator it2 = it++;
m_chans.erase(it2);
// Without this Bad Things (tm) could happen
if (it == m_chans.end())
break;
}
}
示例2: OnJoinMessage
bool CIRCSock::OnJoinMessage(CJoinMessage& Message) {
const CNick& Nick = Message.GetNick();
CString sChan = Message.GetParam(0);
CChan* pChan = nullptr;
if (Nick.NickEquals(GetNick())) {
m_pNetwork->AddChan(sChan, false);
pChan = m_pNetwork->FindChan(sChan);
if (pChan) {
pChan->Enable();
pChan->SetIsOn(true);
PutIRC("MODE " + sChan);
}
} else {
pChan = m_pNetwork->FindChan(sChan);
}
if (pChan) {
pChan->AddNick(Nick.GetNickMask());
Message.SetChan(pChan);
IRCSOCKMODULECALL(OnJoinMessage(Message), NOTHING);
if (pChan->IsDetached()) {
return true;
}
}
return false;
}
示例3: OnPartMessage
bool CIRCSock::OnPartMessage(CPartMessage& Message) {
const CNick& Nick = Message.GetNick();
CString sChan = Message.GetTarget();
CChan* pChan = m_pNetwork->FindChan(sChan);
bool bDetached = false;
if (pChan) {
pChan->RemNick(Nick.GetNick());
Message.SetChan(pChan);
IRCSOCKMODULECALL(OnPartMessage(Message), NOTHING);
if (pChan->IsDetached()) bDetached = true;
}
if (Nick.NickEquals(GetNick())) {
m_pNetwork->DelChan(sChan);
}
/*
* We use this boolean because
* m_pNetwork->DelChan() will delete this channel
* and thus we would dereference an
* already-freed pointer!
*/
return bDetached;
}
示例4: CheckAttach
void CheckAttach(const CString& sMessage, CChan& Channel) {
if (Channel.IsDetached()) {
if (sMessage.AsLower().find(m_pNetwork->GetCurNick().AsLower()) != CString::npos) {
Channel.JoinUser();
}
}
}
示例5: TryAttach
void TryAttach(CChan& Channel) {
const CString& sChan = Channel.GetName();
if (Channel.IsDetached() && IsAutoAttach(sChan)) {
Channel.JoinUser();
}
}
示例6: OnActionMessage
bool CIRCSock::OnActionMessage(CActionMessage& Message) {
bool bResult = false;
CChan* pChan = nullptr;
CString sTarget = Message.GetTarget();
if (sTarget.Equals(GetNick())) {
IRCSOCKMODULECALL(OnPrivCTCPMessage(Message), &bResult);
if (bResult) return true;
IRCSOCKMODULECALL(OnPrivActionMessage(Message), &bResult);
if (bResult) return true;
if (!m_pNetwork->IsUserOnline() ||
!m_pNetwork->GetUser()->AutoClearQueryBuffer()) {
const CNick& Nick = Message.GetNick();
CQuery* pQuery = m_pNetwork->AddQuery(Nick.GetNick());
if (pQuery) {
CActionMessage Format;
Format.Clone(Message);
Format.SetNick(_NAMEDFMT(Nick.GetNickMask()));
Format.SetTarget("{target}");
Format.SetText("{text}");
pQuery->AddBuffer(Format, Message.GetText());
}
}
} else {
pChan = m_pNetwork->FindChan(sTarget);
if (pChan) {
Message.SetChan(pChan);
FixupChanNick(Message.GetNick(), pChan);
IRCSOCKMODULECALL(OnChanCTCPMessage(Message), &bResult);
if (bResult) return true;
IRCSOCKMODULECALL(OnChanActionMessage(Message), &bResult);
if (bResult) return true;
if (!pChan->AutoClearChanBuffer() || !m_pNetwork->IsUserOnline() ||
pChan->IsDetached()) {
CActionMessage Format;
Format.Clone(Message);
Format.SetNick(_NAMEDFMT(Message.GetNick().GetNickMask()));
Format.SetTarget(_NAMEDFMT(Message.GetTarget()));
Format.SetText("{text}");
pChan->AddBuffer(Format, Message.GetText());
}
}
}
return (pChan && pChan->IsDetached());
}
示例7: OnJoinMessage
bool CClient::OnJoinMessage(CJoinMessage& Message) {
CString sChans = Message.GetTarget();
CString sKeys = Message.GetKey();
VCString vsChans;
sChans.Split(",", vsChans, false);
sChans.clear();
VCString vsKeys;
sKeys.Split(",", vsKeys, true);
sKeys.clear();
for (unsigned int a = 0; a < vsChans.size(); a++) {
Message.SetTarget(vsChans[a]);
Message.SetKey((a < vsKeys.size()) ? vsKeys[a] : "");
if (m_pNetwork) {
// May be nullptr.
Message.SetChan(m_pNetwork->FindChan(vsChans[a]));
}
bool bContinue = false;
NETWORKMODULECALL(OnUserJoinMessage(Message), m_pUser, m_pNetwork, this,
&bContinue);
if (bContinue) continue;
CString sChannel = Message.GetTarget();
CString sKey = Message.GetKey();
if (m_pNetwork) {
CChan* pChan = m_pNetwork->FindChan(sChannel);
if (pChan) {
if (pChan->IsDetached())
pChan->AttachUser(this);
else
pChan->JoinUser(sKey);
continue;
} else if (!sChannel.empty()) {
pChan = new CChan(sChannel, m_pNetwork, false);
if (m_pNetwork->AddChan(pChan)) {
pChan->SetKey(sKey);
}
}
}
if (!sChannel.empty()) {
sChans += (sChans.empty()) ? sChannel : CString("," + sChannel);
if (!vsKeys.empty()) {
sKeys += (sKeys.empty()) ? sKey : CString("," + sKey);
}
}
}
Message.SetTarget(sChans);
Message.SetKey(sKeys);
return sChans.empty();
}
示例8: OnNoticeMessage
bool CIRCSock::OnNoticeMessage(CNoticeMessage& Message) {
CString sTarget = Message.GetTarget();
bool bResult = false;
if (sTarget.Equals(GetNick())) {
IRCSOCKMODULECALL(OnPrivNoticeMessage(Message), &bResult);
if (bResult) return true;
if (!m_pNetwork->IsUserOnline()) {
// If the user is detached, add to the buffer
CNoticeMessage Format;
Format.Clone(Message);
Format.SetNick(CNick(_NAMEDFMT(Message.GetNick().GetNickMask())));
Format.SetTarget("{target}");
Format.SetText("{text}");
m_pNetwork->AddNoticeBuffer(Format, Message.GetText());
}
return false;
} else {
CChan* pChan = m_pNetwork->FindChan(sTarget);
if (pChan) {
Message.SetChan(pChan);
FixupChanNick(Message.GetNick(), pChan);
IRCSOCKMODULECALL(OnChanNoticeMessage(Message), &bResult);
if (bResult) return true;
if (!pChan->AutoClearChanBuffer() || !m_pNetwork->IsUserOnline() ||
pChan->IsDetached()) {
CNoticeMessage Format;
Format.Clone(Message);
Format.SetNick(_NAMEDFMT(Message.GetNick().GetNickMask()));
Format.SetTarget(_NAMEDFMT(Message.GetTarget()));
Format.SetText("{text}");
pChan->AddBuffer(Format, Message.GetText());
}
}
return (pChan && pChan->IsDetached());
}
}
示例9: Clone
void CChan::Clone(CChan& chan) {
// We assume that m_sName and m_pNetwork are equal
SetBufferCount(chan.GetBufferCount(), true);
SetKeepBuffer(chan.KeepBuffer());
SetKey(chan.GetKey());
SetDefaultModes(chan.GetDefaultModes());
if (IsDetached() != chan.IsDetached()) {
// Only send something if it makes sense
// (= Only detach if client is on the channel
// and only attach if we are on the channel)
if (IsOn()) {
if (IsDetached()) {
JoinUser(false, "");
} else {
DetachUser();
}
}
SetDetached(chan.IsDetached());
}
}
示例10: SetChan
void SetChan(const CString& sLine) {
const CString var = sLine.Token(1).AsLower();
CString username = sLine.Token(2);
CString chan = sLine.Token(3);
CString value = sLine.Token(4, true);
if (value.empty()) {
PutModule("Usage: setchan <variable> <username> <chan> <value>");
return;
}
CUser* user = GetUser(username);
if (!user)
return;
CChan* pChan = user->FindChan(chan);
if (!pChan) {
PutModule("Error: Channel not found: " + chan);
return;
}
if (var == "defmodes") {
pChan->SetDefaultModes(value);
PutModule("DefModes = " + value);
} else if (var == "buffer") {
unsigned int i = value.ToUInt();
pChan->SetBufferCount(i);
PutModule("Buffer = " + CString(i));
} else if (var == "inconfig") {
bool b = value.ToBool();
pChan->SetInConfig(b);
PutModule("InConfig = " + CString(b));
} else if (var == "keepbuffer") {
bool b = value.ToBool();
pChan->SetKeepBuffer(b);
PutModule("KeepBuffer = " + CString(b));
} else if (var == "detached") {
bool b = value.ToBool();
if (pChan->IsDetached() != b) {
if (b)
pChan->DetachUser();
else
pChan->AttachUser();
}
PutModule("Detached = " + CString(b));
} else
PutModule("Error: Unknown variable");
}
示例11: Message
void Message(CChan& Channel) {
Limits::iterator it;
time_t now = time(NULL);
// First: Clean up old entries and reattach where necessary
Cleanup();
it = m_chans.find(Channel.GetName());
if (it == m_chans.end()) {
// We don't track detached channels
if (Channel.IsDetached())
return;
// This is the first message for this channel, start a
// new timeout.
std::pair<time_t, unsigned int> tmp(now, 1);
m_chans[Channel.GetName()] = tmp;
return;
}
// No need to check it->second.first (expiry time), since
// Cleanup() would have removed it if it was expired.
if (it->second.second >= m_iThresholdMsgs) {
// The channel already hit the limit and we detached the
// user, but it is still being flooded, reset the timeout
it->second.first = now;
it->second.second++;
return;
}
it->second.second++;
if (it->second.second < m_iThresholdMsgs)
return;
// The channel hit the limit, reset the timeout so that we keep
// it detached for longer.
it->second.first = now;
Channel.DetachUser();
if (!GetNV("silent").ToBool()) {
PutModule("Channel [" + Channel.GetName() + "] was "
"flooded, you've been detached");
}
}
示例12: OnTopicMessage
bool CIRCSock::OnTopicMessage(CTopicMessage& Message) {
const CNick& Nick = Message.GetNick();
CChan* pChan = m_pNetwork->FindChan(Message.GetParam(0));
if (pChan) {
Message.SetChan(pChan);
bool bReturn = false;
IRCSOCKMODULECALL(OnTopicMessage(Message), &bReturn);
if (bReturn) return true;
pChan->SetTopicOwner(Nick.GetNick());
pChan->SetTopicDate((unsigned long)time(nullptr));
pChan->SetTopic(Message.GetTopic());
}
return (pChan && pChan->IsDetached());
}
示例13: TryAttach
void TryAttach(const CNick& Nick, CChan& Channel, CString& Message) {
const CString& sChan = Channel.GetName();
const CString& sHost = Nick.GetHostMask();
const CString& sMessage = Message;
VAttachIter it;
if (!Channel.IsDetached()) return;
// Any negated match?
for (it = m_vMatches.begin(); it != m_vMatches.end(); ++it) {
if (it->IsNegated() && it->IsMatch(sChan, sHost, sMessage)) return;
}
// Now check for a positive match
for (it = m_vMatches.begin(); it != m_vMatches.end(); ++it) {
if (!it->IsNegated() && it->IsMatch(sChan, sHost, sMessage)) {
Channel.AttachUser();
return;
}
}
}
示例14: GetChan
void GetChan(const CString& sLine) {
const CString var = sLine.Token(1).AsLower();
CString username = sLine.Token(2);
CString chan = sLine.Token(3, true);
if (var.empty()) {
PutModule("Usage: getchan <variable> [username] <chan>");
return;
}
if (chan.empty()) {
chan = username;
username = "";
}
if (username.empty()) {
username = m_pUser->GetUserName();
}
CUser* user = GetUser(username);
if (!user)
return;
CChan* pChan = user->FindChan(chan);
if (!pChan) {
PutModule("Error: Channel not found: " + chan);
return;
}
if (var == "defmodes")
PutModule("DefModes = " + pChan->GetDefaultModes());
else if (var == "buffer")
PutModule("Buffer = " + CString(pChan->GetBufferCount()));
else if (var == "inconfig")
PutModule("InConfig = " + pChan->InConfig());
else if (var == "keepbuffer")
PutModule("KeepBuffer = " + pChan->KeepBuffer());
else if (var == "detached")
PutModule("Detached = " + pChan->IsDetached());
else
PutModule("Error: Unknown variable");
}
示例15: OnKickMessage
bool CIRCSock::OnKickMessage(CKickMessage& Message) {
CString sChan = Message.GetParam(0);
CString sKickedNick = Message.GetKickedNick();
CChan* pChan = m_pNetwork->FindChan(sChan);
if (pChan) {
Message.SetChan(pChan);
IRCSOCKMODULECALL(OnKickMessage(Message), NOTHING);
// do not remove the nick till after the OnKick call, so modules
// can do Chan.FindNick or something to get more info.
pChan->RemNick(sKickedNick);
}
if (GetNick().Equals(sKickedNick) && pChan) {
pChan->SetIsOn(false);
// Don't try to rejoin!
pChan->Disable();
}
return (pChan && pChan->IsDetached());
}