本文整理汇总了C++中modes::ChangeList类的典型用法代码示例。如果您正苦于以下问题:C++ ChangeList类的具体用法?C++ ChangeList怎么用?C++ ChangeList使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ChangeList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
}
}
示例2: DoRestoreChans
void DataKeeper::DoRestoreChans()
{
ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "Restoring channel data");
Modes::ChangeList modechange;
for (std::vector<ChanData>::const_iterator i = chandatalist.begin(); i != chandatalist.end(); ++i)
{
const ChanData& chandata = *i;
Channel* const chan = ServerInstance->FindChan(chandata.owner);
if (!chan)
{
ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "Channel %s not found", chandata.owner.c_str());
continue;
}
RestoreObj(chandata, chan, MODETYPE_CHANNEL, modechange);
// Process the mode change before applying any prefix modes
ServerInstance->Modes.Process(ServerInstance->FakeClient, chan, NULL, modechange, ModeParser::MODE_LOCALONLY);
modechange.clear();
// Restore all member data
RestoreMemberData(chan, chandata.memberdatalist, modechange);
ServerInstance->Modes.Process(ServerInstance->FakeClient, chan, NULL, modechange, ModeParser::MODE_LOCALONLY);
modechange.clear();
}
}
示例3: OnMode
void ModuleSpanningTree::OnMode(User* source, User* u, Channel* c, const Modes::ChangeList& modes, ModeParser::ModeProcessFlag processflags)
{
if (processflags & ModeParser::MODE_LOCALONLY)
return;
if (u)
{
if (u->registered != REG_ALL)
return;
CmdBuilder params(source, "MODE");
params.push(u->uuid);
params.push(ClientProtocol::Messages::Mode::ToModeLetters(modes));
params.push_raw(Translate::ModeChangeListToParams(modes.getlist()));
params.Broadcast();
}
else
{
CmdBuilder params(source, "FMODE");
params.push(c->name);
params.push_int(c->age);
params.push(ClientProtocol::Messages::Mode::ToModeLetters(modes));
params.push_raw(Translate::ModeChangeListToParams(modes.getlist()));
params.Broadcast();
}
}
示例4: SetOperPrefix
void SetOperPrefix(User* user, bool add)
{
Modes::ChangeList changelist;
changelist.push(&opm, add, user->nick);
for (User::ChanList::iterator v = user->chans.begin(); v != user->chans.end(); v++)
ServerInstance->Modes->Process(ServerInstance->FakeClient, (*v)->chan, NULL, changelist);
}
示例5: 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);
}
示例6: Handle
CmdResult Handle(User* user, const Params& parameters) override
{
Channel* channel = ServerInstance->FindChan(parameters[0]);
if (!channel)
{
user->WriteNumeric(Numerics::NoSuchChannel(parameters[0]));
return CMD_FAILURE;
}
unsigned int cm = channel->GetPrefixValue(user);
if (cm < HALFOP_VALUE)
{
user->WriteNumeric(ERR_CHANOPRIVSNEEDED, channel->name, "You do not have permission to set bans on this channel");
return CMD_FAILURE;
}
TimedBan T;
unsigned long duration;
if (!InspIRCd::Duration(parameters[1], duration))
{
user->WriteNotice("Invalid ban time");
return CMD_FAILURE;
}
unsigned long expire = duration + ServerInstance->Time();
std::string mask = parameters[2];
bool isextban = ((mask.size() > 2) && (mask[1] == ':'));
if (!isextban && !InspIRCd::IsValidMask(mask))
mask.append("!*@*");
if (IsBanSet(channel, mask))
{
user->WriteNotice("Ban already set");
return CMD_FAILURE;
}
Modes::ChangeList setban;
setban.push_add(ServerInstance->Modes.FindMode('b', MODETYPE_CHANNEL), mask);
// Pass the user (instead of ServerInstance->FakeClient) to ModeHandler::Process() to
// make it so that the user sets the mode themselves
ServerInstance->Modes.Process(user, channel, NULL, setban);
if (ServerInstance->Modes.GetLastChangeList().empty())
{
user->WriteNotice("Invalid ban mask");
return CMD_FAILURE;
}
T.mask = mask;
T.expire = expire + (IS_REMOTE(user) ? 5 : 0);
T.chan = channel;
TimedBanList.push_back(T);
const std::string addban = user->nick + " added a timed ban on " + mask + " lasting for " + InspIRCd::DurationString(duration) + ".";
// 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(ServerInstance->FakeClient, channel, addban, MSG_NOTICE);
channel->Write(ServerInstance->GetRFCEvents().privmsg, notice, pfxchar);
ServerInstance->PI->SendChannelNotice(channel, pfxchar, addban);
return CMD_SUCCESS;
}
示例7: Handle
CmdResult Handle (const std::vector<std::string> ¶meters, User *user)
{
Channel* channel = ServerInstance->FindChan(parameters[0]);
if (!channel)
{
user->WriteNumeric(Numerics::NoSuchNick(parameters[0]));
return CMD_FAILURE;
}
int cm = channel->GetPrefixValue(user);
if (cm < HALFOP_VALUE)
{
user->WriteNumeric(ERR_CHANOPRIVSNEEDED, channel->name, "You do not have permission to set bans on this channel");
return CMD_FAILURE;
}
TimedBan T;
unsigned long duration = InspIRCd::Duration(parameters[1]);
unsigned long expire = duration + ServerInstance->Time();
if (duration < 1)
{
user->WriteNotice("Invalid ban time");
return CMD_FAILURE;
}
std::string mask = parameters[2];
bool isextban = ((mask.size() > 2) && (mask[1] == ':'));
if (!isextban && !InspIRCd::IsValidMask(mask))
mask.append("!*@*");
if (IsBanSet(channel, mask))
{
user->WriteNotice("Ban already set");
return CMD_FAILURE;
}
Modes::ChangeList setban;
setban.push_add(ServerInstance->Modes->FindMode('b', MODETYPE_CHANNEL), mask);
// Pass the user (instead of ServerInstance->FakeClient) to ModeHandler::Process() to
// make it so that the user sets the mode themselves
ServerInstance->Modes->Process(user, channel, NULL, setban);
if (ServerInstance->Modes->GetLastParse().empty())
{
user->WriteNotice("Invalid ban mask");
return CMD_FAILURE;
}
CUList tmp;
T.mask = mask;
T.expire = expire + (IS_REMOTE(user) ? 5 : 0);
T.chan = channel;
TimedBanList.push_back(T);
// If halfop is loaded, send notice to halfops and above, otherwise send to ops and above
ModeHandler* mh = ServerInstance->Modes->FindMode('h', MODETYPE_CHANNEL);
char pfxchar = (mh && mh->name == "halfop") ? '%' : '@';
channel->WriteAllExcept(ServerInstance->FakeClient, true, pfxchar, tmp, "NOTICE %s :%s added a timed ban on %s lasting for %ld seconds.", channel->name.c_str(), user->nick.c_str(), mask.c_str(), duration);
return CMD_SUCCESS;
}
示例8: RemoveMode
void ModeHandler::RemoveMode(User* user)
{
// Remove the mode if it's set on the user
if (user->IsModeSet(this->GetModeChar()))
{
Modes::ChangeList changelist;
changelist.push_remove(this);
ServerInstance->Modes->Process(ServerInstance->FakeClient, NULL, user, changelist, ModeParser::MODE_LOCALONLY);
}
}
示例9: OnPostJoin
void OnPostJoin(Membership* memb)
{
if ((!IS_LOCAL(memb->user)) || (!memb->user->IsOper()) || (memb->user->IsModeSet(hideopermode)))
return;
if (memb->HasMode(&opm))
return;
// The user was force joined and OnUserPreJoin() did not run. Set the operprefix now.
Modes::ChangeList changelist;
changelist.push_add(&opm, memb->user->nick);
ServerInstance->Modes.Process(ServerInstance->FakeClient, memb->chan, NULL, changelist);
}
示例10: ModeParamsToChangeList
void ModeParser::ModeParamsToChangeList(User* user, ModeType type, const std::vector<std::string>& parameters, Modes::ChangeList& changelist, unsigned int beginindex, unsigned int endindex)
{
if (endindex > parameters.size())
endindex = parameters.size();
const std::string& mode_sequence = parameters[beginindex];
bool adding = true;
unsigned int param_at = beginindex+1;
for (std::string::const_iterator letter = mode_sequence.begin(); letter != mode_sequence.end(); letter++)
{
unsigned char modechar = *letter;
if (modechar == '+' || modechar == '-')
{
adding = (modechar == '+');
continue;
}
ModeHandler *mh = this->FindMode(modechar, type);
if (!mh)
{
/* No mode handler? Unknown mode character then. */
user->WriteNumeric(type == MODETYPE_CHANNEL ? ERR_UNKNOWNMODE : ERR_UNKNOWNSNOMASK, "%c :is unknown mode char to me", modechar);
continue;
}
std::string parameter;
if (mh->GetNumParams(adding) && param_at < endindex)
parameter = parameters[param_at++];
changelist.push(mh, adding, parameter);
}
}
示例11: RestoreModes
void DataKeeper::RestoreModes(const std::vector<InstanceData>& list, ModeType modetype, Modes::ChangeList& modechange)
{
for (std::vector<InstanceData>::const_iterator i = list.begin(); i != list.end(); ++i)
{
const InstanceData& id = *i;
modechange.push_add(handledmodes[modetype][id.index].mh, id.serialized);
}
}
示例12: DoRestoreUsers
void DataKeeper::DoRestoreUsers()
{
ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "Restoring user data");
Modes::ChangeList modechange;
for (std::vector<UserData>::const_iterator i = userdatalist.begin(); i != userdatalist.end(); ++i)
{
const UserData& userdata = *i;
User* const user = ServerInstance->FindUUID(userdata.owner);
if (!user)
{
ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "User %s is gone", userdata.owner.c_str());
continue;
}
RestoreObj(userdata, user, MODETYPE_USER, modechange);
ServerInstance->Modes.Process(ServerInstance->FakeClient, NULL, user, modechange, ModeParser::MODE_LOCALONLY);
modechange.clear();
}
}
示例13: HandleLocal
CmdResult HandleLocal(const std::vector<std::string>& parameters, LocalUser* user)
{
// Make sure the channel name is allowable.
if (!ServerInstance->IsChannel(parameters[0]))
{
user->WriteNotice("*** Invalid characters in channel name or name too long");
return CMD_FAILURE;
}
active = true;
// override is false because we want OnUserPreJoin to run
Channel* channel = Channel::JoinUser(user, parameters[0], false);
active = false;
if (channel)
{
ServerInstance->SNO->WriteGlobalSno('a', user->nick+" used OJOIN to join "+channel->name);
if (notice)
{
channel->WriteChannelWithServ(ServerInstance->Config->ServerName, "NOTICE %s :%s joined on official network business.",
parameters[0].c_str(), user->nick.c_str());
ServerInstance->PI->SendChannelNotice(channel, 0, user->nick + " joined on official network business.");
}
}
else
{
channel = ServerInstance->FindChan(parameters[0]);
if (!channel)
return CMD_FAILURE;
ServerInstance->SNO->WriteGlobalSno('a', user->nick+" used OJOIN in "+parameters[0]);
// they're already in the channel
Modes::ChangeList changelist;
changelist.push_add(npmh, user->nick);
if (op)
changelist.push_add(ServerInstance->Modes->FindMode('o', MODETYPE_CHANNEL), user->nick);
ServerInstance->Modes->Process(ServerInstance->FakeClient, channel, NULL, changelist);
}
return CMD_SUCCESS;
}
示例14: Process
void ModeParser::Process(User* user, Channel* targetchannel, User* targetuser, Modes::ChangeList& changelist, ModeProcessFlag flags)
{
// Call ProcessSingle until the entire list is processed, but at least once to ensure
// LastParse and LastChangeList are cleared
unsigned int processed = 0;
do
{
unsigned int n = ProcessSingle(user, targetchannel, targetuser, changelist, flags, processed);
processed += n;
}
while (processed < changelist.size());
}
示例15: HandleLocal
CmdResult HandleLocal(const std::vector<std::string>& parameters, LocalUser* src)
{
Channel* const chan = ServerInstance->FindChan(parameters[0]);
if (!chan)
{
src->WriteNumeric(Numerics::NoSuchNick(parameters[0]));
return CMD_FAILURE;
}
if (parameters.size() == 1)
{
DisplayList(src, chan);
return CMD_SUCCESS;
}
unsigned int i = 1;
Modes::ChangeList modes;
while (i < parameters.size())
{
std::string prop = parameters[i++];
if (prop.empty())
continue;
bool plus = prop[0] != '-';
if (prop[0] == '+' || prop[0] == '-')
prop.erase(prop.begin());
ModeHandler* mh = ServerInstance->Modes->FindMode(prop, MODETYPE_CHANNEL);
if (mh)
{
if (mh->NeedsParam(plus))
{
if (i != parameters.size())
modes.push(mh, plus, parameters[i++]);
}
else
modes.push(mh, plus);
}
}
ServerInstance->Modes->ProcessSingle(src, chan, NULL, modes, ModeParser::MODE_CHECKACCESS);
return CMD_SUCCESS;
}