本文整理汇总了C++中CChan::DetachUser方法的典型用法代码示例。如果您正苦于以下问题:C++ CChan::DetachUser方法的具体用法?C++ CChan::DetachUser怎么用?C++ CChan::DetachUser使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CChan
的用法示例。
在下文中一共展示了CChan::DetachUser方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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");
}
示例2: 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");
}
}