本文整理汇总了C++中modes::ChangeList::push_remove方法的典型用法代码示例。如果您正苦于以下问题:C++ ChangeList::push_remove方法的具体用法?C++ ChangeList::push_remove怎么用?C++ ChangeList::push_remove使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类modes::ChangeList
的用法示例。
在下文中一共展示了ChangeList::push_remove方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RemoveMode
void ModeHandler::RemoveMode(Channel* channel, Modes::ChangeList& changelist)
{
if (channel->IsModeSet(this))
{
if (this->GetNumParams(false))
// Removing this mode requires a parameter
changelist.push_remove(this, channel->GetModeParameter(this));
else
changelist.push_remove(this);
}
}
示例2: UnOper
void User::UnOper()
{
if (!this->IsOper())
return;
/*
* unset their oper type (what IS_OPER checks).
* note, order is important - this must come before modes as -o attempts
* to call UnOper. -- w00t
*/
oper = NULL;
/* Remove all oper only modes from the user when the deoper - Bug #466*/
Modes::ChangeList changelist;
const ModeParser::ModeHandlerMap& usermodes = ServerInstance->Modes->GetModes(MODETYPE_USER);
for (ModeParser::ModeHandlerMap::const_iterator i = usermodes.begin(); i != usermodes.end(); ++i)
{
ModeHandler* mh = i->second;
if (mh->NeedsOper())
changelist.push_remove(mh);
}
ServerInstance->Modes->Process(this, NULL, this, changelist);
// Remove the user from the oper list
stdalgo::vector::swaperase(ServerInstance->Users->all_opers, this);
ModeHandler* opermh = ServerInstance->Modes->FindMode('o', MODETYPE_USER);
this->SetMode(opermh, false);
}
示例3: OnBackgroundTimer
void OnBackgroundTimer(time_t curtime) override
{
timedbans expired;
for (timedbans::iterator i = TimedBanList.begin(); i != TimedBanList.end();)
{
if (curtime > i->expire)
{
expired.push_back(*i);
i = TimedBanList.erase(i);
}
else
++i;
}
for (timedbans::iterator i = expired.begin(); i != expired.end(); i++)
{
std::string mask = i->mask;
Channel* cr = i->chan;
{
const std::string expiry = "*** Timed ban on " + cr->name + " expired.";
// If halfop is loaded, send notice to halfops and above, otherwise send to ops and above
PrefixMode* mh = ServerInstance->Modes.FindPrefixMode('h');
char pfxchar = (mh && mh->name == "halfop") ? mh->GetPrefix() : '@';
ClientProtocol::Messages::Privmsg notice(ClientProtocol::Messages::Privmsg::nocopy, ServerInstance->FakeClient, cr, expiry, MSG_NOTICE);
cr->Write(ServerInstance->GetRFCEvents().privmsg, notice, pfxchar);
ServerInstance->PI->SendChannelNotice(cr, pfxchar, expiry);
Modes::ChangeList setban;
setban.push_remove(ServerInstance->Modes.FindMode('b', MODETYPE_CHANNEL), mask);
ServerInstance->Modes.Process(ServerInstance->FakeClient, cr, NULL, setban);
}
}
}
示例4: ValidateChans
void ValidateChans()
{
Modes::ChangeList removepermchan;
badchan = true;
const chan_hash& chans = ServerInstance->GetChans();
for (chan_hash::const_iterator i = chans.begin(); i != chans.end(); )
{
Channel* c = i->second;
// Move iterator before we begin kicking
++i;
if (ServerInstance->IsChannel(c->name))
continue; // The name of this channel is still valid
if (c->IsModeSet(permchannelmode) && c->GetUserCounter())
{
removepermchan.clear();
removepermchan.push_remove(*permchannelmode);
ServerInstance->Modes.Process(ServerInstance->FakeClient, c, NULL, removepermchan);
}
Channel::MemberMap& users = c->userlist;
for (Channel::MemberMap::iterator j = users.begin(); j != users.end(); )
{
if (IS_LOCAL(j->first))
{
// KickUser invalidates the iterator
Channel::MemberMap::iterator it = j++;
c->KickUser(ServerInstance->FakeClient, it, "Channel name no longer valid");
}
else
++j;
}
}
badchan = false;
}
示例5: Handle
CmdResult Handle(User* user, const Params& parameters) override
{
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(false))
{
user->WriteNotice("You do not have access to unset " + ConvToStr(modeletter) + " on " + chan->name + ".");
return CMD_FAILURE;
}
std::string pattern = parameters.size() > 2 ? parameters[2] : "*";
PrefixMode* pm;
ListModeBase* lm;
ListModeBase::ModeList* ml;
Modes::ChangeList changelist;
if ((pm = mh->IsPrefixMode()))
{
// As user prefix modes don't have a GetList() method, let's iterate through the channel's users.
const Channel::MemberMap& users = chan->GetUsers();
for (Channel::MemberMap::const_iterator it = users.begin(); it != users.end(); ++it)
{
if (!InspIRCd::Match(it->first->nick, pattern))
continue;
if (it->second->HasMode(pm) && !((it->first == user) && (pm->GetPrefixRank() > VOICE_VALUE)))
changelist.push_remove(mh, it->first->nick);
}
}
else if ((lm = mh->IsListModeBase()) && ((ml = lm->GetList(chan)) != NULL))
{
for (ListModeBase::ModeList::iterator it = ml->begin(); it != ml->end(); ++it)
{
if (!InspIRCd::Match(it->mask, pattern))
continue;
changelist.push_remove(mh, it->mask);
}
}
else
{
if (chan->IsModeSet(mh))
changelist.push_remove(mh);
}
ServerInstance->Modes.Process(user, chan, NULL, changelist);
return CMD_SUCCESS;
}