本文整理汇总了C++中anope::string::trim方法的典型用法代码示例。如果您正苦于以下问题:C++ string::trim方法的具体用法?C++ string::trim怎么用?C++ string::trim使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类anope::string
的用法示例。
在下文中一共展示了string::trim方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Execute
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override
{
if (!this->fs)
return;
const Anope::string &command = params[0];
const Anope::string &subcommand = params.size() > 1 ? params[1] : "";
ForbidType ftype = FT_SIZE;
if (subcommand.equals_ci("NICK"))
ftype = FT_NICK;
else if (subcommand.equals_ci("CHAN"))
ftype = FT_CHAN;
else if (subcommand.equals_ci("EMAIL"))
ftype = FT_EMAIL;
else if (subcommand.equals_ci("REGISTER"))
ftype = FT_REGISTER;
if (command.equals_ci("ADD") && params.size() > 3 && ftype != FT_SIZE)
{
const Anope::string &expiry = params[2][0] == '+' ? params[2] : "";
const Anope::string &entry = !expiry.empty() ? params[3] : params[2];
Anope::string reason;
if (expiry.empty())
reason = params[3] + " ";
if (params.size() > 4)
reason += params[4];
reason.trim();
if (entry.replace_all_cs("?*", "").empty())
{
source.Reply(_("The mask must contain at least one non wildcard character."));
return;
}
time_t expiryt = 0;
if (!expiry.empty())
{
expiryt = Anope::DoTime(expiry);
if (expiryt == -1)
{
source.Reply(_("Invalid expiry time \002{0}\002."), expiry);
return;
}
else if (expiryt)
expiryt += Anope::CurTime;
}
NickServ::Nick *target = NickServ::FindNick(entry);
if (target != NULL && Config->GetModule("nickserv")->Get<bool>("secureadmins", "yes") && target->GetAccount()->IsServicesOper())
{
source.Reply(_("Access denied."));
return;
}
ForbidData *d = this->fs->FindForbid(entry, ftype);
bool created = false;
if (d == NULL)
{
d = Serialize::New<ForbidData *>();
created = true;
}
d->SetMask(entry);
d->SetCreator(source.GetNick());
d->SetReason(reason);
d->SetCreated(Anope::CurTime);
d->SetExpires(expiryt);
d->SetType(ftype);
if (Anope::ReadOnly)
source.Reply(_("Services are in read-only mode. Any changes made may not persist."));
Log(LOG_ADMIN, source, this) << "to add a forbid on " << entry << " of type " << subcommand;
source.Reply(_("Added a forbid on \002{0}\002 of type \002{1}\002 to expire on \002{2}\002."), entry, subcommand.lower(), expiryt ? Anope::strftime(expiryt, source.GetAccount()) : "never");
/* apply forbid */
switch (ftype)
{
case FT_NICK:
{
int na_matches = 0;
for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it)
this->OnUserNickChange(it->second);
for (auto it = NickServ::service->GetNickList().begin(); it != NickServ::service->GetNickList().end();)
{
NickServ::Nick *na = *it;
++it;
d = this->fs->FindForbid(na->GetNick(), FT_NICK);
if (d == NULL)
continue;
++na_matches;
delete na;
}
//.........这里部分代码省略.........