本文整理汇总了C++中CommandSource::HasPriv方法的典型用法代码示例。如果您正苦于以下问题:C++ CommandSource::HasPriv方法的具体用法?C++ CommandSource::HasPriv怎么用?C++ CommandSource::HasPriv使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CommandSource
的用法示例。
在下文中一共展示了CommandSource::HasPriv方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Execute
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override
{
const Anope::string &chan = params[0];
const Anope::string &nick = params[1];
if (Anope::ReadOnly)
{
source.Reply(_("Sorry, bot assignment is temporarily disabled."));
return;
}
ChanServ::Channel *ci = ChanServ::Find(chan);
if (ci == NULL)
{
source.Reply(_("Channel \002{0}\002 isn't registered."), chan);
return;
}
ServiceBot *bi = ServiceBot::Find(nick, true);
if (!bi)
{
source.Reply(_("Bot \002{0}\002 does not exist."), nick);
return;
}
ChanServ::AccessGroup access = source.AccessFor(ci);
if (!access.HasPriv("ASSIGN") && !source.HasPriv("botserv/administration"))
{
source.Reply(_("Access denied. You do not have privilege \002{0}\002 on \002{1}\002."), "ASSIGN", ci->GetName());
return;
}
if (ci->HasFieldS("BS_NOBOT"))
{
source.Reply(_("Access denied. \002{0}\002 may not have a bot assigned to it because a Services Operator has disallowed it."), ci->GetName());
return;
}
if (bi->bi->GetOperOnly() && !source.HasPriv("botserv/administration"))
{
source.Reply(_("Access denied. Bot \002{0}\002 is for operators only."), bi->nick);
return;
}
if (ci->GetBot() == bi)
{
source.Reply(_("Bot \002{0}\002 is already assigned to \002{1}\002."), ci->GetBot()->nick, ci->GetName());
return;
}
bool override = !access.HasPriv("ASSIGN");
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "for " << bi->nick;
bi->Assign(source.GetUser(), ci);
source.Reply(_("Bot \002{0}\002 has been assigned to \002{1}\002."), bi->nick, ci->GetName());
}
示例2: Execute
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override
{
ChanServ::Channel *ci = ChanServ::Find(params[0]);
const Anope::string &value = params[1];
if (ci == NULL)
{
source.Reply(_("Channel \002{0}\002 isn't registered."), params[0]);
return;
}
if (!source.HasPriv("botserv/administration") && !source.AccessFor(ci).HasPriv("SET"))
{
source.Reply(_("Access denied. You do not have the \002{0}\002 privilege on \002{1}\002."), "SET", ci->GetName());
return;
}
if (Anope::ReadOnly)
{
source.Reply(_("Sorry, bot option setting is temporarily disabled."));
return;
}
if (value.equals_ci("ON"))
{
bool override = !source.AccessFor(ci).HasPriv("SET");
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to enable fantasy";
ci->SetS<bool>("BS_FANTASY", true);
source.Reply(_("Fantasy mode is now \002on\002 on channel \002{0}\002."), ci->GetName());
}
示例3: Execute
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override
{
unsigned count = 0;
ListFormatter list(source.GetAccount());
list.AddColumn(_("Nick")).AddColumn(_("Mask"));
for (BotInfo *bi : Serialize::GetObjects<BotInfo *>())
{
if (source.HasPriv("botserv/administration") || !bi->GetOperOnly())
{
++count;
ListFormatter::ListEntry entry;
entry["Nick"] = (bi->GetOperOnly() ? "* " : "") + bi->GetNick();
entry["Mask"] = bi->GetUser() + "@" + bi->GetHost();
list.AddEntry(entry);
}
}
std::vector<Anope::string> replies;
list.Process(replies);
if (!count)
{
source.Reply(_("There are no bots available"));
return;
}
source.Reply(_("Bot list:"));
for (unsigned i = 0; i < replies.size(); ++i)
source.Reply(replies[i]);
source.Reply(_("{0} bots available."), count);
}
示例4: Execute
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override
{
const Anope::string &chan = params[0];
const Anope::string &value = params[1];
if (Anope::ReadOnly)
{
source.Reply(_("Services are in read-only mode."));
return;
}
ChanServ::Channel *ci = ChanServ::Find(chan);
if (ci == NULL)
{
source.Reply(_("Channel \002{0}\002 isn't registered."), chan);
return;
}
if (!source.HasPriv("botserv/administration") && !source.AccessFor(ci).HasPriv("SET"))
{
source.Reply(_("Access denied. You do not have privilege \002{0}\002 on \002{1}\002."), "SET", ci->GetName());
return;
}
if (value.equals_ci("ON"))
{
bool override = !source.AccessFor(ci).HasPriv("SET");
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to enable greets";
ci->SetS<bool>("BS_GREET", true);
source.Reply(_("Greet mode for \002{0}\002 is now \002on\002."), ci->GetName());
}
示例5: Execute
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override
{
const Anope::string &cmd = params[0];
Anope::string nick, mask;
if (cmd.equals_ci("LIST"))
nick = params.size() > 1 ? params[1] : "";
else
{
nick = params.size() == 3 ? params[1] : "";
mask = params.size() > 1 ? params[params.size() - 1] : "";
}
NickServ::Account *nc;
if (!nick.empty() && source.HasPriv("nickserv/access"))
{
NickServ::Nick *na = NickServ::FindNick(nick);
if (na == NULL)
{
source.Reply(_("\002{0}\002 isn't registered."), nick);
return;
}
if (Config->GetModule("nickserv")->Get<bool>("secureadmins", "yes") && source.GetAccount() != na->GetAccount() && na->GetAccount()->IsServicesOper() && !cmd.equals_ci("LIST"))
{
source.Reply(_("You may view but not modify the access list of other Services Operators."));
return;
}
nc = na->GetAccount();
}
else
nc = source.nc;
if (!mask.empty() && (mask.find('@') == Anope::string::npos || mask.find('!') != Anope::string::npos))
{
source.Reply(_("Mask must be in the form \037user\[email protected]\037host\037."));
source.Reply(_("\002%s%s HELP %s\002 for more information."), Config->StrictPrivmsg, source.service->nick, source.command); // XXX
}
else if (cmd.equals_ci("LIST"))
return this->DoList(source, nc, mask);
else if (nc->HasFieldS("NS_SUSPENDED"))
source.Reply(_("\002{0}\002 is suspended."), nc->GetDisplay());
else if (cmd.equals_ci("ADD"))
return this->DoAdd(source, nc, mask);
else if (cmd.equals_ci("DEL"))
return this->DoDel(source, nc, mask);
else
this->OnSyntaxError(source, "");
}
示例6: Execute
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override
{
const Anope::string &chan = params[0];
const Anope::string &text = params[1];
ChanServ::Channel *ci = ChanServ::Find(chan);
if (ci == NULL)
{
source.Reply(_("Channel \002{0}\002 isn't registered."), chan);
return;
}
if (!source.AccessFor(ci).HasPriv("SAY") && !source.HasPriv("botserv/administration"))
{
source.Reply(_("Access denied. You do not have privilege \002{0}\002 on \002{1}\002."), "SAY", ci->GetName());
return;
}
if (!ci->GetBot())
{
source.Reply(_("There is no bot assigned to \002{0}\002. One must be assigned to the channel before this command can be used."), ci->GetName());
ServiceBot *bi;
Anope::string name;
Command::FindCommandFromService("botserv/assign", bi, name);
CommandInfo *help = source.service->FindCommand("generic/help");
if (bi && help)
source.Reply(_("See \002{msg}{service} {help} {command}\002 for information on assigning bots."),
"msg"_kw = Config->StrictPrivmsg, "service"_kw = bi->nick, "help"_kw = help->cname, "command"_kw = name);
return;
}
if (!ci->c || !ci->c->FindUser(ci->GetBot()))
{
source.Reply(_("Bot \002{0}\002 is not on channel \002{1}\002."), ci->GetBot()->nick, ci->GetName());
return;
}
if (text[0] == '\001')
{
this->OnSyntaxError(source, "");
return;
}
IRCD->SendPrivmsg(ci->GetBot(), ci->GetName(), "%s", text.c_str());
ci->GetBot()->lastmsg = Anope::CurTime;
bool override = !source.AccessFor(ci).HasPriv("SAY");
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to say: " << text;
}
示例7: Execute
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override
{
const Anope::string &cmd = params[0];
Anope::string nick, certfp;
if (cmd.equals_ci("LIST"))
nick = params.size() > 1 ? params[1] : "";
else
{
nick = params.size() == 3 ? params[1] : "";
certfp = params.size() > 1 ? params[params.size() - 1] : "";
}
NickServ::Account *nc;
if (!nick.empty() && source.HasPriv("nickserv/access"))
{
NickServ::Nick *na = NickServ::FindNick(nick);
if (na == NULL)
{
source.Reply(_("\002{0}\002 isn't registered."), nick);
return;
}
if (Config->GetModule("nickserv")->Get<bool>("secureadmins", "yes") && source.GetAccount() != na->GetAccount() && na->GetAccount()->IsServicesOper() && !cmd.equals_ci("LIST"))
{
source.Reply(_("You may view, but not modify, the certificate list of other Services Operators."));
return;
}
nc = na->GetAccount();
}
else
nc = source.nc;
if (cmd.equals_ci("LIST"))
return this->DoList(source, nc);
else if (nc->HasFieldS("NS_SUSPENDED"))
source.Reply(_("\002{0}\002 is suspended."), nc->GetDisplay());
else if (Anope::ReadOnly)
source.Reply(_("Services are in read-only mode."));
else if (cmd.equals_ci("ADD"))
return this->DoAdd(source, nc, certfp);
else if (cmd.equals_ci("DEL"))
return this->DoDel(source, nc, certfp);
else
this->OnSyntaxError(source, "");
}
示例8: Execute
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override
{
const Anope::string &chan = params[0];
if (Anope::ReadOnly && !source.HasPriv("chanserv/administration"))
{
source.Reply(_("Sorry, channel de-registration is temporarily disabled."));
return;
}
ChanServ::Channel *ci = ChanServ::Find(chan);
if (ci == NULL)
{
source.Reply(_("Channel \002{0}\002 isn't registered."), chan);
return;
}
if (params.size() < 2 || !chan.equals_ci(params[1]))
{
source.Reply(_("You must enter the channel name twice as a confirmation that you wish to drop \002{0}\002."), ci->GetName());
return;
}
if ((ci->HasFieldS("SECUREFOUNDER") ? !source.IsFounder(ci) : !source.AccessFor(ci).HasPriv("FOUNDER")) && !source.HasCommand("chanserv/drop"))
{
source.Reply(_("Access denied. You do not have privilege \002{0}\002 on \002{1}\002."), "FOUNDER", ci->GetName());
return;
}
EventReturn MOD_RESULT = this->onchandrop(&Event::ChanDrop::OnChanDrop, source, ci);
if (MOD_RESULT == EVENT_STOP)
return;
bool override = (ci->HasFieldS("SECUREFOUNDER") ? !source.IsFounder(ci) : !source.AccessFor(ci).HasPriv("FOUNDER"));
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "(founder was: " << (ci->GetFounder() ? ci->GetFounder()->GetDisplay() : "none") << ")";
Reference<Channel> c = ci->c;
ci->Delete();
source.Reply(_("Channel \002{0}\002 has been dropped."), chan);
if (c)
c->CheckModes();
}
示例9: OnHelp
bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
ServiceBot *bi;
Anope::string name;
Command::FindCommandFromService("botserv/assign", bi, name);
if (!bi)
return false;
source.Reply(_("Lists all available bots. You may use the \002{msg}{service} {assign}\002 command to assign a bot to your channel."
"The bot names are vanity; they all proviate the same commands and features."),
"msg"_kw = Config->StrictPrivmsg, "service"_kw = bi->nick, "assign"_kw = name);
if (source.HasPriv("botserv/administration"))
source.Reply(_("Bots prefixed by a * are reserved for Services Operators with the privilege \002{0}\002."),
"botserv/administration");
source.Reply(_("\n"
"Example:\n"
" {command} BOTLIST"),
"command"_kw = source.command);
return true;
}
示例10: Execute
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override
{
const Anope::string &what = params[0];
if (what.equals_ci("MODIFY") && params.size() > 3)
{
if (!source.HasPriv("operserv/config"))
{
source.Reply(_("Access denied. You do not have the operator privilege \002{0}\002."), "operserv/config");
return;
}
Configuration::Block *block = Config->GetBlock(params[1]);
if (!block)
block = Config->GetModule(params[1]);
if (!block)
{
source.Reply(_("There is no such configuration block \002{0}\002."), params[1]);
return;
}
block->Set(params[2], params[3]);
Log(LOG_ADMIN, source, this) << "to change the configuration value of " << params[1] << ":" << params[2] << " to " << params[3];
source.Reply(_("Value of \002{0}:{1}\002 changed to \002{2}\002."), params[1], params[2], params[3]);
}
else if (what.equals_ci("VIEW"))
{
/* Blocks we should show */
const Anope::string show_blocks[] = { "serverinfo", "networkinfo", "options", "" };
Log(LOG_ADMIN, source, this) << "VIEW";
for (unsigned i = 0; !show_blocks[i].empty(); ++i)
{
Configuration::Block *block = Config->GetBlock(show_blocks[i]);
const Configuration::Block::item_map *items = block->GetItems();
if (!items)
continue;
ListFormatter lflist(source.GetAccount());
lflist.AddColumn(_("Name")).AddColumn(_("Value"));
for (Configuration::Block::item_map::const_iterator it = items->begin(), it_end = items->end(); it != it_end; ++it)
{
ListFormatter::ListEntry entry;
entry["Name"] = it->first;
entry["Value"] = it->second;
lflist.AddEntry(entry);
}
std::vector<Anope::string> replies;
lflist.Process(replies);
source.Reply(_("%s settings:"), block->GetName());
for (unsigned j = 0; j < replies.size(); ++j)
source.Reply(replies[j]);
source.Reply(" ");
}
ListFormatter lflist(source.GetAccount());
lflist.AddColumn(_("Module Name")).AddColumn(_("Name")).AddColumn(_("Value"));
for (int i = 0; i < Config->CountBlock("module"); ++i)
{
Configuration::Block *block = Config->GetBlock("module", i);
const Configuration::Block::item_map *items = block->GetItems();
if (!items || items->size() <= 1)
continue;
ListFormatter::ListEntry entry;
entry["Module Name"] = block->Get<Anope::string>("name");
for (Configuration::Block::item_map::const_iterator it = items->begin(), it_end = items->end(); it != it_end; ++it)
{
entry["Name"] = it->first;
entry["Value"] = it->second;
lflist.AddEntry(entry);
}
}
std::vector<Anope::string> replies;
lflist.Process(replies);
source.Reply(_("Module settings:"));
for (unsigned j = 0; j < replies.size(); ++j)
source.Reply(replies[j]);
source.Reply(_("End of configuration."));
}
else
this->OnSyntaxError(source, what);
}
示例11: Execute
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override
{
ChannelMode *cm = ModeManager::FindChannelModeByName("BAN");
if (!cm)
return;
std::vector<ChannelMode *> modes = cm->listeners;
modes.push_back(cm);
if (params.empty())
{
if (!source.GetUser())
return;
unsigned count = 0;
for (ChanServ::Channel *ci : source.GetAccount()->GetRefs<ChanServ::Channel *>())
{
if (!ci->c || !source.AccessFor(ci).HasPriv("UNBAN"))
continue;
for (unsigned j = 0; j < modes.size(); ++j)
if (ci->c->Unban(source.GetUser(), modes[j]->name, true))
++count;
}
Log(LOG_COMMAND, source, this, NULL) << "on all channels";
source.Reply(_("You have been unbanned from %d channels."), count);
return;
}
const Anope::string &chan = params[0];
ChanServ::Channel *ci = ChanServ::Find(chan);
if (ci == NULL)
{
source.Reply(_("Channel \002{0}\002 isn't registered."), chan);
return;
}
if (ci->c == NULL)
{
source.Reply(_("Channel \002{0}\002 doesn't exist."), ci->GetName());
return;
}
if (!source.AccessFor(ci).HasPriv("UNBAN") && !source.HasPriv("chanserv/kick"))
{
source.Reply(_("Access denied. You do not have privilege \002{0}\002 on \002{1}\002."), "UNBAN", ci->GetName());
return;
}
User *u2 = source.GetUser();
if (params.size() > 1)
u2 = User::Find(params[1], true);
if (!u2)
{
if (params.size() > 1)
source.Reply(_("User \002{0}\002 isn't currently online."), params[1]);
return;
}
bool override = !source.AccessFor(ci).HasPriv("UNBAN") && source.HasPriv("chanserv/kick");
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to unban " << u2->nick;
for (unsigned i = 0; i < modes.size(); ++i)
ci->c->Unban(u2, modes[i]->name, source.GetUser() == u2);
if (u2 == source.GetUser())
source.Reply(_("You have been unbanned from \002{0}\002."), ci->c->name);
else
source.Reply(_("\002{0}\002 has been unbanned from \002{1}\002."), u2->nick, ci->c->name);
}
示例12: DoLimit
void DoLimit(CommandSource &source, const std::vector<Anope::string> ¶ms, MemoServ::MemoInfo *mi)
{
Anope::string p1 = params[1];
Anope::string p2 = params.size() > 2 ? params[2] : "";
Anope::string p3 = params.size() > 3 ? params[3] : "";
Anope::string user, chan;
int16_t limit;
NickServ::Account *nc = source.nc;
ChanServ::Channel *ci = NULL;
bool is_servadmin = source.HasPriv("memoserv/set-limit");
if (p1[0] == '#')
{
chan = p1;
p1 = p2;
p2 = p3;
p3 = params.size() > 4 ? params[4] : "";
ci = ChanServ::Find(chan);
if (!ci)
{
source.Reply(_("Channel \002{0}\002 isn't registered."), chan);
return;
}
if (!is_servadmin && !source.AccessFor(ci).HasPriv("MEMO"))
{
source.Reply(_("Access denied. You do not have privilege \002{0}\002 on \002{1}\002."), "MEMO", ci->GetName());
return;
}
mi = ci->GetMemos();
}
if (is_servadmin)
{
if (!p2.empty() && !p2.equals_ci("HARD") && chan.empty())
{
NickServ::Nick *na;
if (!(na = NickServ::FindNick(p1)))
{
source.Reply(_("\002{0}\002 isn't registered."), p1);
return;
}
user = p1;
mi = na->GetAccount()->GetMemos();
nc = na->GetAccount();
p1 = p2;
p2 = p3;
}
else if (p1.empty() || (!p1.is_pos_number_only() && !p1.equals_ci("NONE")) || (!p2.empty() && !p2.equals_ci("HARD")))
{
this->OnSyntaxError(source, "");
return;
}
if (!chan.empty())
{
if (!p2.empty())
ci->SetS<bool>("MEMO_HARDMAX", true);
else
ci->UnsetS<bool>("MEMO_HARDMAX");
}
else
{
if (!p2.empty())
nc->SetS<bool>("MEMO_HARDMAX", true);
else
nc->UnsetS<bool>("MEMO_HARDMAX");
}
limit = -1;
try
{
limit = convertTo<int16_t>(p1);
}
catch (const ConvertException &) { }
}
else
{
if (p1.empty() || !p2.empty() || !isdigit(p1[0]))
{
this->OnSyntaxError(source, "");
return;
}
if (!chan.empty() && ci->HasFieldS("MEMO_HARDMAX"))
{
source.Reply(_("The memo limit for \002{0}\002 may not be changed."), chan);
return;
}
if (chan.empty() && nc->HasFieldS("MEMO_HARDMAX"))
{
source.Reply(_("You are not permitted to change your memo limit."));
return;
}
int max_memos = Config->GetModule("memoserv")->Get<int>("maxmemos");
limit = -1;
try
{
limit = convertTo<int16_t>(p1);
}
catch (const ConvertException &) { }
/* The first character is a digit, but we could still go negative
//.........这里部分代码省略.........
示例13: Execute
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override
{
const Anope::string &channel = params[0];
ChanServ::Channel *ci = ChanServ::Find(channel);
if (ci == NULL)
{
source.Reply(_("Channel \002{0}\002 isn't registered."), channel);
return;
}
if (!source.AccessFor(ci).HasPriv("SET") && !source.HasPriv("chanserv/administration"))
{
source.Reply(_("Access denied. You do not have privilege \002{0}\002 on \002{1}\002."), "SET", ci->GetName());
return;
}
if (params.size() == 1)
{
std::vector<LogSetting *> ls = ci->GetRefs<LogSetting *>(logsetting);
if (ls.empty())
{
source.Reply(_("There currently are no logging configurations for \002{0}\002."), ci->GetName());
return;
}
ListFormatter list(source.GetAccount());
list.AddColumn(_("Number")).AddColumn(_("Service")).AddColumn(_("Command")).AddColumn(_("Method")).AddColumn("");
for (unsigned i = 0; i < ls.size(); ++i)
{
LogSetting *log = ls[i];
ListFormatter::ListEntry entry;
entry["Number"] = stringify(i + 1);
entry["Service"] = log->GetCommandService();
entry["Command"] = !log->GetCommandName().empty() ? log->GetCommandName() : log->GetServiceName();
entry["Method"] = log->GetMethod();
entry[""] = log->GetExtra();
list.AddEntry(entry);
}
source.Reply(_("Log list for \002{0}\002:"), ci->GetName());
std::vector<Anope::string> replies;
list.Process(replies);
for (unsigned i = 0; i < replies.size(); ++i)
source.Reply(replies[i]);
}
else if (params.size() > 2)
{
if (Anope::ReadOnly)
{
source.Reply(_("Services are in read-only mode."));
return;
}
const Anope::string &command = params[1];
const Anope::string &method = params[2];
const Anope::string &extra = params.size() > 3 ? params[3] : "";
size_t sl = command.find('/');
if (sl == Anope::string::npos)
{
source.Reply(_("\002{0}\002 is not a valid command."), command);
return;
}
Anope::string service = command.substr(0, sl),
command_name = command.substr(sl + 1);
ServiceBot *bi = ServiceBot::Find(service, true);
Anope::string service_name;
/* Allow either a command name or a service name. */
if (bi && bi->commands.count(command_name))
{
/* Get service name from command */
service_name = bi->commands[command_name].name;
}
else if (ServiceReference<Command>("Command", command.lower()))
{
/* This is the service name, don't use any specific command */
service_name = command;
bi = NULL;
command_name.clear();
}
else
{
source.Reply(_("\002{0}\002 is not a valid command."), command);
return;
}
if (!method.equals_ci("MESSAGE") && !method.equals_ci("NOTICE") && !method.equals_ci("MEMO"))
{
source.Reply(_("\002%s\002 is not a valid logging method."));
return;
}
//.........这里部分代码省略.........