本文整理汇总了C++中Channel::IsModeSet方法的典型用法代码示例。如果您正苦于以下问题:C++ Channel::IsModeSet方法的具体用法?C++ Channel::IsModeSet怎么用?C++ Channel::IsModeSet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Channel
的用法示例。
在下文中一共展示了Channel::IsModeSet方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandleLocal
CmdResult CommandTopic::HandleLocal(const std::vector<std::string>& parameters, LocalUser* user)
{
Channel* c = ServerInstance->FindChan(parameters[0]);
if (!c)
{
user->WriteNumeric(ERR_NOSUCHNICK, "%s :No such nick/channel", parameters[0].c_str());
return CMD_FAILURE;
}
if (parameters.size() == 1)
{
if (c)
{
if ((c->IsModeSet(secretmode)) && (!c->HasUser(user)))
{
user->WriteNumeric(ERR_NOSUCHNICK, "%s :No such nick/channel", c->name.c_str());
return CMD_FAILURE;
}
if (c->topic.length())
{
user->WriteNumeric(RPL_TOPIC, "%s :%s", c->name.c_str(), c->topic.c_str());
user->WriteNumeric(RPL_TOPICTIME, "%s %s %lu", c->name.c_str(), c->setby.c_str(), (unsigned long)c->topicset);
}
else
{
user->WriteNumeric(RPL_NOTOPICSET, "%s :No topic is set.", c->name.c_str());
}
}
return CMD_SUCCESS;
}
std::string t = parameters[1]; // needed, in case a module wants to change it
ModResult res;
FIRST_MOD_RESULT(OnPreTopicChange, res, (user,c,t));
if (res == MOD_RES_DENY)
return CMD_FAILURE;
if (res != MOD_RES_ALLOW)
{
if (!c->HasUser(user))
{
user->WriteNumeric(ERR_NOTONCHANNEL, "%s :You're not on that channel!", c->name.c_str());
return CMD_FAILURE;
}
if (c->IsModeSet(topiclockmode) && !ServerInstance->OnCheckExemption(user, c, "topiclock").check(c->GetPrefixValue(user) >= HALFOP_VALUE))
{
user->WriteNumeric(ERR_CHANOPRIVSNEEDED, "%s :You do not have access to change the topic on this channel", c->name.c_str());
return CMD_FAILURE;
}
}
c->SetTopic(user, t);
return CMD_SUCCESS;
}
示例2: Handle
/** Handle /NAMES
*/
CmdResult CommandNames::Handle (const std::vector<std::string>& parameters, User *user)
{
Channel* c;
if (!parameters.size())
{
user->WriteNumeric(366, "%s * :End of /NAMES list.",user->nick.c_str());
return CMD_SUCCESS;
}
if (CommandParser::LoopCall(user, this, parameters, 0))
return CMD_SUCCESS;
c = ServerInstance->FindChan(parameters[0]);
if (c)
{
if ((c->IsModeSet('s')) && (!c->HasUser(user)))
{
user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick.c_str(), c->name.c_str());
return CMD_FAILURE;
}
c->UserList(user);
}
else
{
user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick.c_str(), parameters[0].c_str());
}
return CMD_SUCCESS;
}
示例3: ChannelList
std::string User::ChannelList(User* source, bool spy)
{
std::string list;
for (UCListIter i = this->chans.begin(); i != this->chans.end(); i++)
{
Channel* c = *i;
/* If the target is the sender, neither +p nor +s is set, or
* the channel contains the user, it is not a spy channel
*/
if (spy != (source == this || !(c->IsModeSet('p') || c->IsModeSet('s')) || c->HasUser(source)))
list.append(c->GetPrefixChar(this)).append(c->name).append(" ");
}
return list;
}
示例4: DoMsg
ModResult DoMsg(User *user, void *dest, int target_type, std::string &text, char status, CUList &exempt_list, bool privmsg)
{
if (!IS_LOCAL(user) || target_type != TYPE_CHANNEL || status)
return MOD_RES_PASSTHRU;
Channel* chan = static_cast<Channel*>(dest);
ModResult res = ServerInstance->OnCheckExemption(user,chan,"opmoderated");
if (res == MOD_RES_ALLOW)
return MOD_RES_PASSTHRU;
if (!chan->GetExtBanStatus(user, 'u').check(!chan->IsModeSet(&mh)) && chan->GetPrefixValue(user) < VOICE_VALUE)
{
FOREACH_MOD(I_OnText,OnText(user,chan,TYPE_CHANNEL,text,status,exempt_list));
chan->WriteAllExcept(user, false, '@', exempt_list, "%s @%s :%s",
privmsg ? "PRIVMSG" : "NOTICE", chan->name.c_str(), text.c_str());
if (privmsg)
{
FOREACH_MOD(I_OnUserMessage,OnUserMessage(user,chan,TYPE_CHANNEL,text,'@',exempt_list));
}
else
FOREACH_MOD(I_OnUserNotice,OnUserNotice(user,chan,TYPE_CHANNEL,text,'@',exempt_list));
return MOD_RES_DENY;
}
return MOD_RES_PASSTHRU;
}
示例5: OnUserPreMessage
ModResult OnUserPreMessage(User* user, const MessageTarget& target, MessageDetails& details) override
{
if (!IS_LOCAL(user))
return MOD_RES_PASSTHRU;
std::string ctcpname;
if (!details.IsCTCP(ctcpname) || irc::equals(ctcpname, "ACTION"))
return MOD_RES_PASSTHRU;
if (target.type == MessageTarget::TYPE_CHANNEL)
{
Channel* c = target.Get<Channel>();
ModResult res = CheckExemption::Call(exemptionprov, user, c, "noctcp");
if (res == MOD_RES_ALLOW)
return MOD_RES_PASSTHRU;
if (!c->GetExtBanStatus(user, 'C').check(!c->IsModeSet(nc)))
{
user->WriteNumeric(ERR_CANNOTSENDTOCHAN, c->name, "Can't send CTCP to channel (+C set)");
return MOD_RES_DENY;
}
}
else if (target.type == MessageTarget::TYPE_USER)
{
User* u = target.Get<User>();
if (u->IsModeSet(ncu))
{
user->WriteNumeric(ERR_CANTSENDTOUSER, u->nick, "Can't send CTCP to user (+T set)");
return MOD_RES_PASSTHRU;
}
}
return MOD_RES_PASSTHRU;
}
示例6: OnUserPreMessage
ModResult OnUserPreMessage(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
{
if (!IS_LOCAL(user))
return MOD_RES_PASSTHRU;
std::string *account = accountname.get(user);
bool is_registered = account && !account->empty();
if (target_type == TYPE_CHANNEL)
{
Channel* c = (Channel*)dest;
ModResult res = ServerInstance->OnCheckExemption(user,c,"regmoderated");
if (c->IsModeSet('M') && !is_registered && res != MOD_RES_ALLOW)
{
// user messaging a +M channel and is not registered
user->WriteNumeric(477, user->nick+" "+c->name+" :You need to be identified to a registered account to message this channel");
return MOD_RES_DENY;
}
}
else if (target_type == TYPE_USER)
{
User* u = (User*)dest;
if (u->IsModeSet('R') && !is_registered)
{
// user messaging a +R user and is not registered
user->WriteNumeric(477, ""+ user->nick +" "+ u->nick +" :You need to be identified to a registered account to message this user");
return MOD_RES_DENY;
}
}
return MOD_RES_PASSTHRU;
}
示例7: OnUserPreNick
virtual ModResult OnUserPreNick(User* user, const std::string &newnick)
{
if (!IS_LOCAL(user))
return MOD_RES_PASSTHRU;
// Allow forced nick changes.
if (ServerInstance->NICKForced.get(user))
return MOD_RES_PASSTHRU;
for (UCListIter i = user->chans.begin(); i != user->chans.end(); i++)
{
Channel* curr = *i;
ModResult res = ServerInstance->OnCheckExemption(user,curr,"nonick");
if (res == MOD_RES_ALLOW)
continue;
if (override && IS_OPER(user))
continue;
if (!curr->GetExtBanStatus(user, 'N').check(!curr->IsModeSet('N')))
{
user->WriteNumeric(ERR_CANTCHANGENICK, "%s :Can't change nickname while on %s (+N is set)",
user->nick.c_str(), curr->name.c_str());
return MOD_RES_DENY;
}
}
return MOD_RES_PASSTHRU;
}
示例8: ChannelList
std::string CommandWhois::ChannelList(User* source, User* dest, bool spy)
{
std::string list;
for (UCListIter i = dest->chans.begin(); i != dest->chans.end(); i++)
{
Channel* c = *i;
/* If the target is the sender, neither +p nor +s is set, or
* the channel contains the user, it is not a spy channel
*/
if (spy != (source == dest || !(c->IsModeSet(privatemode) || c->IsModeSet(secretmode)) || c->HasUser(source)))
list.append(c->GetPrefixChar(dest)).append(c->name).append(" ");
}
return list;
}
示例9: get_first_visible_channel
Channel* get_first_visible_channel(User *u)
{
UCListIter i = u->chans.begin();
while (i != u->chans.end())
{
Channel* c = *i++;
if (!c->IsModeSet(secretmode))
return c;
}
return NULL;
}
示例10: ChannelList
std::string CommandWhois::ChannelList(User* source, User* dest, bool spy)
{
std::string list;
for (User::ChanList::iterator i = dest->chans.begin(); i != dest->chans.end(); i++)
{
Membership* memb = *i;
Channel* c = memb->chan;
/* If the target is the sender, neither +p nor +s is set, or
* the channel contains the user, it is not a spy channel
*/
if (spy != (source == dest || !(c->IsModeSet(privatemode) || c->IsModeSet(secretmode)) || c->HasUser(source)))
{
char prefix = memb->GetPrefixChar();
if (prefix)
list.push_back(prefix);
list.append(c->name).push_back(' ');
}
}
return list;
}
示例11: Handle
CmdResult Handle (const std::vector<std::string> ¶meters, User *user)
{
Channel* c = ServerInstance->FindChan(parameters[0]);
if (!c)
{
user->WriteNumeric(Numerics::NoSuchNick(parameters[0]));
return CMD_FAILURE;
}
if (c->HasUser(user))
{
user->WriteNumeric(ERR_KNOCKONCHAN, c->name, InspIRCd::Format("Can't KNOCK on %s, you are already on that channel.", c->name.c_str()));
return CMD_FAILURE;
}
if (c->IsModeSet(noknockmode))
{
user->WriteNumeric(480, InspIRCd::Format("Can't KNOCK on %s, +K is set.", c->name.c_str()));
return CMD_FAILURE;
}
if (!c->IsModeSet(inviteonlymode))
{
user->WriteNumeric(ERR_CHANOPEN, c->name, InspIRCd::Format("Can't KNOCK on %s, channel is not invite only so knocking is pointless!", c->name.c_str()));
return CMD_FAILURE;
}
if (sendnotice)
c->WriteNotice(InspIRCd::Format("User %s is KNOCKing on %s (%s)", user->nick.c_str(), c->name.c_str(), parameters[1].c_str()));
if (sendnumeric)
c->WriteChannelWithServ(ServerInstance->Config->ServerName, "710 %s %s %s :is KNOCKing: %s", c->name.c_str(), c->name.c_str(), user->GetFullHost().c_str(), parameters[1].c_str());
user->WriteNotice("KNOCKing on " + c->name);
return CMD_SUCCESS;
}
示例12: Handle
CmdResult Handle (const std::vector<std::string> ¶meters, User *user)
{
Channel* c = ServerInstance->FindChan(parameters[0]);
if (!c)
{
user->WriteNumeric(401, "%s %s :No such channel",user->nick.c_str(), parameters[0].c_str());
return CMD_FAILURE;
}
if (c->HasUser(user))
{
user->WriteNumeric(480, "%s :Can't KNOCK on %s, you are already on that channel.", user->nick.c_str(), c->name.c_str());
return CMD_FAILURE;
}
if (c->IsModeSet('K'))
{
user->WriteNumeric(480, "%s :Can't KNOCK on %s, +K is set.",user->nick.c_str(), c->name.c_str());
return CMD_FAILURE;
}
if (!c->IsModeSet('i'))
{
user->WriteNumeric(480, "%s :Can't KNOCK on %s, channel is not invite only so knocking is pointless!",user->nick.c_str(), c->name.c_str());
return CMD_FAILURE;
}
if (sendnotice)
c->WriteChannelWithServ(ServerInstance->Config->ServerName, "NOTICE %s :User %s is KNOCKing on %s (%s)", c->name.c_str(), user->nick.c_str(), c->name.c_str(), parameters[1].c_str());
if (sendnumeric)
c->WriteChannelWithServ(ServerInstance->Config->ServerName, "710 %s %s %s :is KNOCKing: %s", c->name.c_str(), c->name.c_str(), user->GetFullHost().c_str(), parameters[1].c_str());
user->WriteNotice("KNOCKing on " + c->name);
return CMD_SUCCESS;
}
示例13: OnUserPreNotice
virtual ModResult OnUserPreNotice(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
{
ModResult res;
if ((target_type == TYPE_CHANNEL) && (IS_LOCAL(user)))
{
Channel* c = (Channel*)dest;
if (!c->GetExtBanStatus(user, 'T').check(!c->IsModeSet('T')))
{
res = ServerInstance->OnCheckExemption(user,c,"nonotice");
if (res == MOD_RES_ALLOW)
return MOD_RES_PASSTHRU;
else
{
user->WriteNumeric(ERR_CANNOTSENDTOCHAN, "%s %s :Can't send NOTICE to channel (+T set)",user->nick.c_str(), c->name.c_str());
return MOD_RES_DENY;
}
}
}
return MOD_RES_PASSTHRU;
}
示例14: OnUserPreMessage
virtual ModResult OnUserPreMessage(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
{
if (target_type == TYPE_CHANNEL)
{
if ((!IS_LOCAL(user)) || (text.length() < minlen))
return MOD_RES_PASSTHRU;
Channel* c = (Channel*)dest;
ModResult res = ServerInstance->OnCheckExemption(user,c,"blockcaps");
if (res == MOD_RES_ALLOW)
return MOD_RES_PASSTHRU;
if (!c->GetExtBanStatus(user, 'B').check(!c->IsModeSet('B')))
{
int caps = 0;
const char* actstr = "\1ACTION ";
int act = 0;
for (std::string::iterator i = text.begin(); i != text.end(); i++)
{
/* Smart fix for suggestion from Jobe, ignore CTCP ACTION (part of /ME) */
if (*actstr && *i == *actstr++ && act != -1)
{
act++;
continue;
}
else
act = -1;
caps += capsmap[(unsigned char)*i];
}
if ( ((caps*100)/(int)text.length()) >= percent )
{
user->WriteNumeric(ERR_CANNOTSENDTOCHAN, "%s %s :Your message cannot contain more than %d%% capital letters if it's longer than %d characters", user->nick.c_str(), c->name.c_str(), percent, minlen);
return MOD_RES_DENY;
}
}
}
return MOD_RES_PASSTHRU;
}
示例15: ValidateChans
void ValidateChans()
{
Modes::ChangeList removepermchan;
badchan = true;
const chan_hash& chans = ServerInstance->GetChans();
for (chan_hash::const_iterator i = chans.begin(); i != chans.end(); )
{
Channel* c = i->second;
// Move iterator before we begin kicking
++i;
if (ServerInstance->IsChannel(c->name))
continue; // The name of this channel is still valid
if (c->IsModeSet(permchannelmode) && c->GetUserCounter())
{
removepermchan.clear();
removepermchan.push_remove(*permchannelmode);
ServerInstance->Modes.Process(ServerInstance->FakeClient, c, NULL, removepermchan);
}
Channel::MemberMap& users = c->userlist;
for (Channel::MemberMap::iterator j = users.begin(); j != users.end(); )
{
if (IS_LOCAL(j->first))
{
// KickUser invalidates the iterator
Channel::MemberMap::iterator it = j++;
c->KickUser(ServerInstance->FakeClient, it, "Channel name no longer valid");
}
else
++j;
}
}
badchan = false;
}