本文整理汇总了C++中chanserv::Channel::GetBot方法的典型用法代码示例。如果您正苦于以下问题:C++ Channel::GetBot方法的具体用法?C++ Channel::GetBot怎么用?C++ Channel::GetBot使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类chanserv::Channel
的用法示例。
在下文中一共展示了Channel::GetBot方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
{
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;
}