本文整理汇总了C++中Channel::GetAllPrefixChars方法的典型用法代码示例。如果您正苦于以下问题:C++ Channel::GetAllPrefixChars方法的具体用法?C++ Channel::GetAllPrefixChars怎么用?C++ Channel::GetAllPrefixChars使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Channel
的用法示例。
在下文中一共展示了Channel::GetAllPrefixChars方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnSendWhoLine
void OnSendWhoLine(User* source, const std::vector<std::string>& params, User* user, std::string& line)
{
if (!cap.ext.get(source))
return;
// Channel names can contain ":", and ":" as a 'start-of-token' delimiter is
// only ever valid after whitespace, so... find the actual delimiter first!
// Thanks to FxChiP for pointing this out.
std::string::size_type pos = line.find(" :");
if (pos == std::string::npos || pos == 0)
return;
pos--;
// Don't do anything if the user has no prefixes
if ((line[pos] == 'H') || (line[pos] == 'G') || (line[pos] == '*'))
return;
// 352 21DAAAAAB #chan ident localhost insp21.test 21DAAAAAB [email protected] :0 a
// a b pos
std::string::size_type a = 4 + source->nick.length() + 1;
std::string::size_type b = line.find(' ', a);
if (b == std::string::npos)
return;
// Try to find this channel
std::string channame = line.substr(a, b-a);
Channel* chan = ServerInstance->FindChan(channame);
if (!chan)
return;
// Don't do anything if the user has only one prefix
std::string prefixes = chan->GetAllPrefixChars(user);
if (prefixes.length() <= 1)
return;
line.erase(pos, 1);
line.insert(pos, prefixes);
}
示例2: Handle
//.........这里部分代码省略.........
for(std::set<std::string>::iterator i = oper->AllowedPrivs.begin(); i != oper->AllowedPrivs.end(); i++)
{
privs.push_back(' ');
privs.append(*i);
}
std::stringstream privdump(privs);
user->SendText(checkstr + " permissions", privdump);
}
}
if (loctarg)
{
user->SendText(checkstr + " clientaddr " + loctarg->client_sa.str());
user->SendText(checkstr + " serveraddr " + loctarg->server_sa.str());
std::string classname = loctarg->GetClass()->name;
if (!classname.empty())
user->SendText(checkstr + " connectclass " + classname);
}
else
user->SendText(checkstr + " onip " + targuser->GetIPString());
for (UCListIter i = targuser->chans.begin(); i != targuser->chans.end(); i++)
{
Channel* c = (*i)->chan;
chliststr.append(c->GetPrefixChar(targuser)).append(c->name).append(" ");
}
std::stringstream dump(chliststr);
user->SendText(checkstr + " onchans", dump);
dumpExt(user, checkstr, targuser);
}
else if (targchan)
{
/* /check on a channel */
user->SendText(checkstr + " timestamp " + timestring(targchan->age));
if (targchan->topic[0] != 0)
{
/* there is a topic, assume topic related information exists */
user->SendText(checkstr + " topic " + targchan->topic);
user->SendText(checkstr + " topic_setby " + targchan->setby);
user->SendText(checkstr + " topic_setat " + timestring(targchan->topicset));
}
user->SendText(checkstr + " modes " + targchan->ChanModes(true));
user->SendText(checkstr + " membercount " + ConvToStr(targchan->GetUserCounter()));
/* now the ugly bit, spool current members of a channel. :| */
const UserMembList *ulist= targchan->GetUsers();
/* note that unlike /names, we do NOT check +i vs in the channel */
for (UserMembCIter i = ulist->begin(); i != ulist->end(); i++)
{
/*
* Unlike Asuka, I define a clone as coming from the same host. --w00t
*/
user->SendText("%s member %-3lu %s%s (%[email protected]%s) %s ",
checkstr.c_str(), ServerInstance->Users->GlobalCloneCount(i->first),
targchan->GetAllPrefixChars(i->first), i->first->nick.c_str(),
i->first->ident.c_str(), i->first->dhost.c_str(), i->first->fullname.c_str());
}
const ModeParser::ListModeList& listmodes = ServerInstance->Modes->GetListModes();
for (ModeParser::ListModeList::const_iterator i = listmodes.begin(); i != listmodes.end(); ++i)
dumpListMode(user, checkstr, (*i)->GetList(targchan));
dumpExt(user, checkstr, targchan);
}
else
{
/* /check on an IP address, or something that doesn't exist */
long x = 0;
/* hostname or other */
for (user_hash::const_iterator a = ServerInstance->Users->clientlist->begin(); a != ServerInstance->Users->clientlist->end(); a++)
{
if (InspIRCd::Match(a->second->host, parameters[0], ascii_case_insensitive_map) || InspIRCd::Match(a->second->dhost, parameters[0], ascii_case_insensitive_map))
{
/* host or vhost matches mask */
user->SendText(checkstr + " match " + ConvToStr(++x) + " " + a->second->GetFullRealHost() + " " + a->second->GetIPString() + " " + a->second->fullname);
}
/* IP address */
else if (InspIRCd::MatchCIDR(a->second->GetIPString(), parameters[0]))
{
/* same IP. */
user->SendText(checkstr + " match " + ConvToStr(++x) + " " + a->second->GetFullRealHost() + " " + a->second->GetIPString() + " " + a->second->fullname);
}
}
user->SendText(checkstr + " matches " + ConvToStr(x));
}
user->SendText(checkstr + " END " + parameters[0]);
return CMD_SUCCESS;
}
示例3: Handle
CmdResult Handle(const std::vector<std::string> ¶meters, User *user)
{
ModeHandler* mh;
Channel* chan = ServerInstance->FindChan(parameters[0]);
char modeletter = parameters[1][0];
if (chan == NULL)
{
user->WriteNotice("The channel " + parameters[0] + " does not exist.");
return CMD_FAILURE;
}
mh = ServerInstance->Modes->FindMode(modeletter, MODETYPE_CHANNEL);
if (mh == NULL || parameters[1].size() > 1)
{
user->WriteNotice(parameters[1] + " is not a valid channel mode.");
return CMD_FAILURE;
}
if (chan->GetPrefixValue(user) < mh->GetLevelRequired())
{
user->WriteNotice("You do not have access to unset " + ConvToStr(modeletter) + " on " + chan->name + ".");
return CMD_FAILURE;
}
unsigned int prefixrank;
char prefixchar;
std::string pattern = parameters.size() > 2 ? parameters[2] : "*";
ListModeBase* lm;
ListModeBase::ModeList* ml;
irc::modestacker modestack(false);
if (!mh->IsListMode())
{
if (chan->IsModeSet(mh))
modestack.Push(modeletter);
}
else if (((prefixrank = mh->GetPrefixRank()) && (prefixchar = mh->GetPrefix())))
{
// As user prefix modes don't have a GetList() method, let's iterate through the channel's users.
for (UserMembIter it = chan->userlist.begin(); it != chan->userlist.end(); ++it)
{
if (!InspIRCd::Match(it->first->nick, pattern))
continue;
if (((strchr(chan->GetAllPrefixChars(user), prefixchar)) != NULL) && !(it->first == user && prefixrank > VOICE_VALUE))
modestack.Push(modeletter, it->first->nick);
}
}
else if (((lm = dynamic_cast<ListModeBase*>(mh)) != NULL) && ((ml = lm->GetList(chan)) != NULL))
{
for (ListModeBase::ModeList::iterator it = ml->begin(); it != ml->end(); ++it)
{
if (!InspIRCd::Match(it->mask, pattern))
continue;
modestack.Push(modeletter, it->mask);
}
}
else
{
user->WriteNotice("Could not remove channel mode " + ConvToStr(modeletter));
return CMD_FAILURE;
}
parameterlist stackresult;
stackresult.push_back(chan->name);
while (modestack.GetStackedLine(stackresult))
{
ServerInstance->Modes->Process(stackresult, user);
stackresult.erase(stackresult.begin() + 1, stackresult.end());
}
return CMD_SUCCESS;
}