本文整理汇总了C++中LocalUser::IsOper方法的典型用法代码示例。如果您正苦于以下问题:C++ LocalUser::IsOper方法的具体用法?C++ LocalUser::IsOper怎么用?C++ LocalUser::IsOper使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LocalUser
的用法示例。
在下文中一共展示了LocalUser::IsOper方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: WriteCommonQuit
void User::WriteCommonQuit(const std::string &normal_text, const std::string &oper_text)
{
if (this->registered != REG_ALL)
return;
already_sent_t uniq_id = ++LocalUser::already_sent_id;
const std::string normalMessage = ":" + this->GetFullHost() + " QUIT :" + normal_text;
const std::string operMessage = ":" + this->GetFullHost() + " QUIT :" + oper_text;
IncludeChanList include_c(chans.begin(), chans.end());
std::map<User*,bool> exceptions;
FOREACH_MOD(OnBuildNeighborList, (this, include_c, exceptions));
for (std::map<User*,bool>::iterator i = exceptions.begin(); i != exceptions.end(); ++i)
{
LocalUser* u = IS_LOCAL(i->first);
if (u && !u->quitting)
{
u->already_sent = uniq_id;
if (i->second)
u->Write(u->IsOper() ? operMessage : normalMessage);
}
}
for (IncludeChanList::const_iterator v = include_c.begin(); v != include_c.end(); ++v)
{
const UserMembList* ulist = (*v)->chan->GetUsers();
for (UserMembList::const_iterator i = ulist->begin(); i != ulist->end(); i++)
{
LocalUser* u = IS_LOCAL(i->first);
if (u && (u->already_sent != uniq_id))
{
u->already_sent = uniq_id;
u->Write(u->IsOper() ? operMessage : normalMessage);
}
}
}
}
示例2: Handle
CmdResult Handle (const std::vector<std::string> ¶meters, User *user)
{
int n_done = 0;
reason = (parameters.size() < 4) ? "Please use this server/port instead" : parameters[3];
bool redirect_all_immediately = false;
redirect_new_users = true;
bool direction = true;
std::string n_done_s;
/* No parameters: jumpserver disabled */
if (!parameters.size())
{
if (port)
user->WriteNotice("*** Disabled jumpserver (previously set to '" + redirect_to + ":" + ConvToStr(port) + "')");
else
user->WriteNotice("*** Jumpserver was not enabled.");
port = 0;
sslport = 0;
redirect_to.clear();
return CMD_SUCCESS;
}
port = 0;
redirect_to.clear();
if (parameters.size() >= 3)
{
for (std::string::const_iterator n = parameters[2].begin(); n != parameters[2].end(); ++n)
{
switch (*n)
{
case '+':
direction = true;
break;
case '-':
direction = false;
break;
case 'a':
redirect_all_immediately = direction;
break;
case 'n':
redirect_new_users = direction;
break;
default:
user->WriteNotice("*** Invalid JUMPSERVER flag: " + ConvToStr(*n));
return CMD_FAILURE;
break;
}
}
size_t delimpos = parameters[1].find(':');
port = ConvToInt(parameters[1].substr(0, delimpos ? delimpos : std::string::npos));
sslport = (delimpos == std::string::npos ? 0 : ConvToInt(parameters[1].substr(delimpos + 1)));
if (parameters[1].find_first_not_of("0123456789:") != std::string::npos
|| parameters[1].rfind(':') != delimpos
|| port > 65535 || sslport > 65535)
{
user->WriteNotice("*** Invalid port number");
return CMD_FAILURE;
}
if (redirect_all_immediately)
{
/* Redirect everyone but the oper sending the command */
for (LocalUserList::const_iterator i = ServerInstance->Users->local_users.begin(); i != ServerInstance->Users->local_users.end(); ++i)
{
LocalUser* t = *i;
if (!t->IsOper())
{
t->WriteNumeric(10, "%s %s %d :Please use this Server/Port instead", t->nick.c_str(), parameters[0].c_str(), GetPort(t));
ServerInstance->Users->QuitUser(t, reason);
n_done++;
}
}
if (n_done)
{
n_done_s = ConvToStr(n_done);
}
}
if (redirect_new_users)
redirect_to = parameters[0];
user->WriteNotice("*** Set jumpserver to server '" + parameters[0] + "' port '" + (port ? ConvToStr(port) : "Auto") + ", SSL " + (sslport ? ConvToStr(sslport) : "Auto") + "', flags '+" +
(redirect_all_immediately ? "a" : "") + (redirect_new_users ? "n'" : "'") +
(n_done ? " (" + n_done_s + "user(s) redirected): " : ": ") + reason);
}
return CMD_SUCCESS;
}