本文整理汇总了C++中chanserv::Channel::AccessFor方法的典型用法代码示例。如果您正苦于以下问题:C++ Channel::AccessFor方法的具体用法?C++ Channel::AccessFor怎么用?C++ Channel::AccessFor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类chanserv::Channel
的用法示例。
在下文中一共展示了Channel::AccessFor方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnUserLogin
void OnUserLogin(User *u) override
{
ServiceBot *NickServ = Config->GetClient("NickServ");
if (!NickServ)
return;
std::vector<AutoJoin *> channels = u->Account()->GetRefs<AutoJoin *>();
if (channels.empty())
return;
/* Set +r now, so we can ajoin users into +R channels */
ModeManager::ProcessModes();
for (AutoJoin *entry : channels)
{
Channel *c = Channel::Find(entry->GetChannel());
ChanServ::Channel *ci;
if (c)
ci = c->ci;
else
ci = ChanServ::Find(entry->GetChannel());
bool need_invite = false;
Anope::string key = entry->GetKey();
ChanServ::AccessGroup u_access;
if (ci != NULL)
{
if (ci->HasFieldS("CS_SUSPENDED"))
continue;
u_access = ci->AccessFor(u);
}
if (c != NULL)
{
if (c->FindUser(u) != NULL)
continue;
else if (c->HasMode("OPERONLY") && !u->HasMode("OPER"))
continue;
else if (c->HasMode("ADMINONLY") && !u->HasMode("ADMIN"))
continue;
else if (c->HasMode("SSL") && !(u->HasMode("SSL") || u->HasExtOK("ssl")))
continue;
else if (c->MatchesList(u, "BAN") == true && c->MatchesList(u, "EXCEPT") == false)
need_invite = true;
else if (c->HasMode("INVITE") && c->MatchesList(u, "INVITEOVERRIDE") == false)
need_invite = true;
if (c->HasMode("KEY"))
{
Anope::string k;
if (c->GetParam("KEY", k))
{
if (u_access.HasPriv("GETKEY"))
key = k;
else if (key != k)
need_invite = true;
}
}
if (c->HasMode("LIMIT"))
{
Anope::string l;
if (c->GetParam("LIMIT", l))
{
try
{
unsigned limit = convertTo<unsigned>(l);
if (c->users.size() >= limit)
need_invite = true;
}
catch (const ConvertException &) { }
}
}
}
if (need_invite && c != NULL)
{
if (!u_access.HasPriv("INVITE"))
continue;
IRCD->SendInvite(NickServ, c, u);
}
IRCD->SendSVSJoin(NickServ, u, entry->GetChannel(), key);
}
}
示例2: Send
MemoResult Send(const Anope::string &source, const Anope::string &target, const Anope::string &message, bool force) override
{
bool ischan, isregistered;
MemoServ::MemoInfo *mi = GetMemoInfo(target, ischan, isregistered, true);
if (mi == NULL)
return MEMO_INVALID_TARGET;
User *sender = User::Find(source);
if (sender != NULL && !sender->HasPriv("memoserv/no-limit") && !force)
{
time_t send_delay = Config->GetModule("memoserv")->Get<time_t>("senddelay");
if (send_delay > 0 && sender->lastmemosend + send_delay > Anope::CurTime)
return MEMO_TOO_FAST;
else if (!mi->GetMemoMax())
return MEMO_TARGET_FULL;
else if (mi->GetMemoMax() > 0 && mi->GetMemos().size() >= static_cast<unsigned>(mi->GetMemoMax()))
return MEMO_TARGET_FULL;
else if (mi->HasIgnore(sender))
return MEMO_SUCCESS;
}
if (sender != NULL)
sender->lastmemosend = Anope::CurTime;
MemoServ::Memo *m = Serialize::New<MemoServ::Memo *>();
m->SetMemoInfo(mi);
m->SetSender(source);
m->SetTime(Anope::CurTime);
m->SetText(message);
m->SetUnread(true);
EventManager::Get()->Dispatch(&MemoServ::Event::MemoSend::OnMemoSend, source, target, mi, m);
if (ischan)
{
ChanServ::Channel *ci = ChanServ::Find(target);
if (ci->c)
{
for (Channel::ChanUserList::iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it)
{
ChanUserContainer *cu = it->second;
if (ci->AccessFor(cu->user).HasPriv("MEMO"))
{
if (cu->user->Account() && cu->user->Account()->HasFieldS("MEMO_RECEIVE"))
cu->user->SendMessage(*MemoServ, _("There is a new memo on channel \002{0}\002. Type \002{1}{2} READ {3} {4}\002 to read it."), ci->GetName(), Config->StrictPrivmsg, MemoServ->nick, ci->GetName(), mi->GetMemos().size()); // XXX
}
}
}
}
else
{
NickServ::Account *nc = NickServ::FindNick(target)->GetAccount();
if (nc->HasFieldS("MEMO_RECEIVE"))
for (User *u : nc->users)
u->SendMessage(*MemoServ, _("You have a new memo from \002{0}\002. Type \002{1}{2} READ {3}\002 to read it."), source, Config->StrictPrivmsg, MemoServ->nick, mi->GetMemos().size());//XXX
/* let's get out the mail if set in the nickcore - certus */
if (nc->HasFieldS("MEMO_MAIL"))
SendMemoMail(nc, mi, m);
}
return MEMO_SUCCESS;
}