本文整理汇总了C++中Channel::FindUserStatus方法的典型用法代码示例。如果您正苦于以下问题:C++ Channel::FindUserStatus方法的具体用法?C++ Channel::FindUserStatus怎么用?C++ Channel::FindUserStatus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Channel
的用法示例。
在下文中一共展示了Channel::FindUserStatus方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Execute
void Execute(IRCServer *server, User *u, const std::vector<std::string> ¶ms)
{
const std::string &target = params[0];
Channel *c = server->FindChannel(target);
if (c == NULL)
u->WriteNumeric(403, target + " :No such channel");
else if (params.size() == 1)
{
u->WriteNumeric(332, c->GetName() + " :" + c->GetTopic());
u->WriteNumeric(333, c->GetName() + " " + u->GetNick() + " " + Sinkhole::stringify(c->topic_time));
}
else
{
user_status *status = c->FindUserStatus(u);
if (c->HasMode(CMODE_PROTECTEDTOPIC) && (status == NULL || !status->HasMode(CMODE_OP)))
u->WriteNumeric(482, c->GetName() + " :You're not a channel operator");
else
{
std::string topic = params[1];
if (topic.length() > IRCServer::topiclen)
topic = topic.substr(0, IRCServer::topiclen);
c->SetTopic(topic);
c->Send(u->GetMask(), "TOPIC " + c->GetName() + " :" + topic);
}
}
}
示例2: Execute
void Execute(IRCServer *server, User *u, const std::vector<std::string> ¶ms)
{
const std::string &channel = params[0];
const std::string &targnick = params[1];
std::string reason = params.size() > 2 ? params[2] : "";
Channel *c = server->FindChannel(channel);
User *target = server->FindUser(targnick);
if (c == NULL)
u->WriteNumeric(403, channel + " :No such channel");
else if (target == NULL)
u->WriteNumeric(401, targnick + " :No such nick/channel");
else if (!target->IsOnChannel(c))
u->WriteNumeric(441, target->GetNick() + " " + c->GetName() + " :They aren't on that channel");
else
{
user_status *status = c->FindUserStatus(u);
if (status == NULL || !status->HasMode(CMODE_OP))
u->WriteNumeric(482, c->GetName() + " :You're not a channel operator");
else
{
if (reason.length() > IRCServer::kicklen)
reason = reason.substr(0, IRCServer::kicklen);
c->Send(u->GetMask(), "KICK " + c->GetName() + " " + target->GetNick() + " :" + reason);
u->Part(c);
c->Part(u);
}
}
}