本文整理汇总了C++中Channel::HasUser方法的典型用法代码示例。如果您正苦于以下问题:C++ Channel::HasUser方法的具体用法?C++ Channel::HasUser怎么用?C++ Channel::HasUser使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Channel
的用法示例。
在下文中一共展示了Channel::HasUser方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Handle
CmdResult Handle (const std::vector<std::string>& parameters, User *user)
{
User* target = ServerInstance->FindNick(parameters[0]);
Channel* channel = ServerInstance->FindChan(parameters[1]);
std::string message = parameters[2];
if ((target) && (target->registered == REG_ALL) && (channel))
{
if (ServerInstance->ULine(target->server))
{
user->WriteNumeric(ERR_NOPRIVILEGES, "%s :Cannot use an SA command on a u-lined client", user->nick.c_str());
return CMD_FAILURE;
}
if(!channel->HasUser(target))
{
user->WriteServ("NOTICE %s :*** %s is not on the channel %s", user->nick.c_str(), target->nick.c_str(), channel->name.c_str());
return CMD_FAILURE;
}
channel->WriteChannel(target, "PRIVMSG %s :%s", channel->name.c_str(), message.c_str());
ServerInstance->SNO->WriteGlobalSno('a', user->nick + " used SASAY to make " + target->nick.c_str() + " say in " + channel->name.c_str() + ": \"" + message + "\"");
return CMD_SUCCESS;
}
else
{
user->WriteServ("NOTICE %s :*** Invalid nickname or channel", user->nick.c_str());
}
return CMD_FAILURE;
}
示例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(secretmode)) && (!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: Handle
CmdResult Handle (const std::vector<std::string>& parameters, User *user)
{
User* dest = ServerInstance->FindNick(parameters[0]);
if ((dest) && (dest->registered == REG_ALL))
{
if (ServerInstance->ULine(dest->server))
{
user->WriteNumeric(ERR_NOPRIVILEGES, "%s :Cannot use an SA command on a u-lined client",user->nick.c_str());
return CMD_FAILURE;
}
if (IS_LOCAL(user) && !ServerInstance->IsChannel(parameters[1].c_str(), ServerInstance->Config->Limits.ChanMax))
{
/* we didn't need to check this for each character ;) */
user->WriteNotice("*** Invalid characters in channel name or name too long");
return CMD_FAILURE;
}
/* For local users, we call Channel::JoinUser which may create a channel and set its TS.
* For non-local users, we just return CMD_SUCCESS, knowing this will propagate it where it needs to be
* and then that server will handle the command.
*/
LocalUser* localuser = IS_LOCAL(dest);
if (localuser)
{
Channel* n = Channel::JoinUser(localuser, parameters[1], true);
if (n)
{
if (n->HasUser(dest))
{
ServerInstance->SNO->WriteToSnoMask('a', user->nick+" used SAJOIN to make "+dest->nick+" join "+parameters[1]);
return CMD_SUCCESS;
}
else
{
user->WriteNotice("*** Could not join "+dest->nick+" to "+parameters[1]+" (User is probably banned, or blocking modes)");
return CMD_FAILURE;
}
}
else
{
user->WriteNotice("*** Could not join "+dest->nick+" to "+parameters[1]);
return CMD_FAILURE;
}
}
else
{
ServerInstance->SNO->WriteToSnoMask('a', user->nick+" sent remote SAJOIN to make "+dest->nick+" join "+parameters[1]);
return CMD_SUCCESS;
}
}
else
{
user->WriteNotice("*** No such nickname "+parameters[0]);
return CMD_FAILURE;
}
}
示例4: Handle
CmdResult Handle (const std::vector<std::string>& parameters, User *user)
{
User* dest = ServerInstance->FindNick(parameters[1]);
Channel* channel = ServerInstance->FindChan(parameters[0]);
const char* reason = "";
if ((dest) && (dest->registered == REG_ALL) && (channel))
{
if (parameters.size() > 2)
{
reason = parameters[2].c_str();
}
else
{
reason = dest->nick.c_str();
}
if (ServerInstance->ULine(dest->server))
{
user->WriteNumeric(ERR_NOPRIVILEGES, "%s :Cannot use an SA command on a u-lined client", user->nick.c_str());
return CMD_FAILURE;
}
/* For local clients, directly kick them. For remote clients,
* just return CMD_SUCCESS knowing the protocol module will route the SAKICK to the user's
* local server and that will kick them instead.
*/
if (IS_LOCAL(dest))
{
channel->KickUser(ServerInstance->FakeClient, dest, reason);
Channel *n = ServerInstance->FindChan(parameters[1]);
if (n && n->HasUser(dest))
{
/* Sort-of-bug: If the command was issued remotely, this message won't be sent */
user->WriteNotice("*** Unable to kick " + dest->nick + " from " + parameters[0]);
return CMD_FAILURE;
}
}
if (IS_LOCAL(user))
{
/* Locally issued command; send the snomasks */
ServerInstance->SNO->WriteGlobalSno('a', user->nick + " SAKICKed " + dest->nick + " on " + parameters[0]);
}
return CMD_SUCCESS;
}
else
{
user->WriteNotice("*** Invalid nickname or channel");
}
return CMD_FAILURE;
}
示例5: Handle
CmdResult Handle (const std::vector<std::string>& parameters, User *user)
{
User* dest = ServerInstance->FindNick(parameters[0]);
Channel* channel = ServerInstance->FindChan(parameters[1]);
std::string reason;
if ((dest) && (dest->registered == REG_ALL) && (channel))
{
if (parameters.size() > 2)
reason = parameters[2];
if (ServerInstance->ULine(dest->server))
{
user->WriteNumeric(ERR_NOPRIVILEGES, "%s :Cannot use an SA command on a u-lined client",user->nick.c_str());
return CMD_FAILURE;
}
/* For local clients, directly part them generating a PART message. For remote clients,
* just return CMD_SUCCESS knowing the protocol module will route the SAPART to the users
* local server and that will generate the PART instead
*/
if (IS_LOCAL(dest))
{
channel->PartUser(dest, reason);
Channel* n = ServerInstance->FindChan(parameters[1]);
if (!n)
{
ServerInstance->SNO->WriteGlobalSno('a', user->nick+" used SAPART to make "+dest->nick+" part "+parameters[1]);
return CMD_SUCCESS;
}
else
{
if (!n->HasUser(dest))
{
ServerInstance->SNO->WriteGlobalSno('a', user->nick+" used SAPART to make "+dest->nick+" part "+parameters[1]);
return CMD_SUCCESS;
}
else
{
user->WriteServ("NOTICE %s :*** Unable to make %s part %s",user->nick.c_str(), dest->nick.c_str(), parameters[1].c_str());
return CMD_FAILURE;
}
}
}
return CMD_SUCCESS;
}
else
{
user->WriteServ("NOTICE %s :*** Invalid nickname or channel", user->nick.c_str());
}
return CMD_FAILURE;
}
示例6: 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;
}
示例7: Handle
CmdResult Handle (const std::vector<std::string> ¶meters, User *user)
{
Channel* channel = ServerInstance->FindChan(parameters[0]);
std::string reason = ConvToStr("Cycling");
if (parameters.size() > 1)
{
/* reason provided, use it */
reason = reason + ": " + parameters[1];
}
if (!channel)
{
user->WriteNumeric(403, "%s %s :No such channel", user->nick.c_str(), parameters[0].c_str());
return CMD_FAILURE;
}
if (channel->HasUser(user))
{
/*
* technically, this is only ever sent locally, but pays to be safe ;p
*/
if (IS_LOCAL(user))
{
if (channel->GetPrefixValue(user) < VOICE_VALUE && channel->IsBanned(user))
{
/* banned, boned. drop the message. */
user->WriteServ("NOTICE "+user->nick+" :*** You may not cycle, as you are banned on channel " + channel->name);
return CMD_FAILURE;
}
channel->PartUser(user, reason);
Channel::JoinUser(user, parameters[0], true, "", false, ServerInstance->Time());
}
return CMD_SUCCESS;
}
else
{
user->WriteNumeric(442, "%s %s :You're not on that channel", user->nick.c_str(), channel->name.c_str());
}
return CMD_FAILURE;
}
示例8: Handle
CmdResult Handle (const std::vector<std::string>& parameters, User *user)
{
if (CommandParser::LoopCall(user, this, parameters, 1))
return CMD_FAILURE;
User* dest = ServerInstance->FindNick(parameters[0]);
Channel* channel = ServerInstance->FindChan(parameters[1]);
std::string reason;
if ((dest) && (dest->registered == REG_ALL) && (channel))
{
if (parameters.size() > 2)
reason = parameters[2];
if (dest->server->IsULine())
{
user->WriteNumeric(ERR_NOPRIVILEGES, ":Cannot use an SA command on a u-lined client");
return CMD_FAILURE;
}
if (!channel->HasUser(dest))
{
user->WriteNotice("*** " + dest->nick + " is not on " + channel->name);
return CMD_FAILURE;
}
/* For local clients, directly part them generating a PART message. For remote clients,
* just return CMD_SUCCESS knowing the protocol module will route the SAPART to the users
* local server and that will generate the PART instead
*/
if (IS_LOCAL(dest))
{
channel->PartUser(dest, reason);
ServerInstance->SNO->WriteGlobalSno('a', user->nick+" used SAPART to make "+dest->nick+" part "+channel->name);
}
return CMD_SUCCESS;
}
else
{
user->WriteNotice("*** Invalid nickname or channel");
}
return CMD_FAILURE;
}
示例9: Handle
CmdResult Handle(User* user, const Params& parameters) override
{
User* dest = ServerInstance->FindNick(parameters[1]);
Channel* channel = ServerInstance->FindChan(parameters[0]);
if ((dest) && (dest->registered == REG_ALL) && (channel))
{
const std::string& reason = (parameters.size() > 2) ? parameters[2] : dest->nick;
if (dest->server->IsULine())
{
user->WriteNumeric(ERR_NOPRIVILEGES, "Cannot use an SA command on a U-lined client");
return CMD_FAILURE;
}
if (!channel->HasUser(dest))
{
user->WriteNotice("*** " + dest->nick + " is not on " + channel->name);
return CMD_FAILURE;
}
/* For local clients, directly kick them. For remote clients,
* just return CMD_SUCCESS knowing the protocol module will route the SAKICK to the user's
* local server and that will kick them instead.
*/
if (IS_LOCAL(dest))
{
// Target is on this server, kick them and send the snotice
channel->KickUser(ServerInstance->FakeClient, dest, reason);
ServerInstance->SNO.WriteGlobalSno('a', user->nick + " SAKICKed " + dest->nick + " on " + channel->name);
}
return CMD_SUCCESS;
}
else
{
user->WriteNotice("*** Invalid nickname or channel");
}
return CMD_FAILURE;
}
示例10: Handle
/** Handle /KICK
*/
CmdResult CommandKick::Handle (const std::vector<std::string>& parameters, User *user)
{
std::string reason;
Channel* c = ServerInstance->FindChan(parameters[0]);
User* u;
if (ServerInstance->Parser->LoopCall(user, this, parameters, 1))
return CMD_SUCCESS;
if (IS_LOCAL(user))
u = ServerInstance->FindNickOnly(parameters[1]);
else
u = ServerInstance->FindNick(parameters[1]);
if (!u || !c)
{
user->WriteServ( "401 %s %s :No such nick/channel", user->nick.c_str(), u ? parameters[0].c_str() : parameters[1].c_str());
return CMD_FAILURE;
}
if ((IS_LOCAL(user)) && (!c->HasUser(user)) && (!ServerInstance->ULine(user->server)))
{
user->WriteServ( "442 %s %s :You're not on that channel!", user->nick.c_str(), parameters[0].c_str());
return CMD_FAILURE;
}
if (parameters.size() > 2)
{
reason.assign(parameters[2], 0, ServerInstance->Config->Limits.MaxKick);
}
else
{
reason.assign(user->nick, 0, ServerInstance->Config->Limits.MaxKick);
}
c->KickUser(user, u, reason);
return CMD_SUCCESS;
}
示例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: Handle
CmdResult CommandPrivmsg::Handle (const std::vector<std::string>& parameters, User *user)
{
User *dest;
Channel *chan;
CUList except_list;
LocalUser* localuser = IS_LOCAL(user);
if (localuser)
localuser->idle_lastmsg = ServerInstance->Time();
if (ServerInstance->Parser->LoopCall(user, this, parameters, 0))
return CMD_SUCCESS;
if (parameters[0][0] == '$')
{
if (!user->HasPrivPermission("users/mass-message"))
return CMD_SUCCESS;
ModResult MOD_RESULT;
std::string temp = parameters[1];
FIRST_MOD_RESULT(OnUserPreMessage, MOD_RESULT, (user, (void*)parameters[0].c_str(), TYPE_SERVER, temp, 0, except_list, MSG_PRIVMSG));
if (MOD_RESULT == MOD_RES_DENY)
return CMD_FAILURE;
const char* text = temp.c_str();
const char* servermask = (parameters[0].c_str()) + 1;
FOREACH_MOD(I_OnText,OnText(user, (void*)parameters[0].c_str(), TYPE_SERVER, text, 0, except_list));
if (InspIRCd::Match(ServerInstance->Config->ServerName, servermask, NULL))
{
user->SendAll("PRIVMSG", "%s", text);
}
FOREACH_MOD(I_OnUserMessage,OnUserMessage(user, (void*)parameters[0].c_str(), TYPE_SERVER, text, 0, except_list, MSG_PRIVMSG));
return CMD_SUCCESS;
}
char status = 0;
const char* target = parameters[0].c_str();
if (ServerInstance->Modes->FindPrefix(*target))
{
status = *target;
target++;
}
if (*target == '#')
{
chan = ServerInstance->FindChan(target);
except_list.insert(user);
if (chan)
{
if (localuser && chan->GetPrefixValue(user) < VOICE_VALUE)
{
if (chan->IsModeSet('n') && !chan->HasUser(user))
{
user->WriteNumeric(404, "%s %s :Cannot send to channel (no external messages)", user->nick.c_str(), chan->name.c_str());
return CMD_FAILURE;
}
if (chan->IsModeSet('m'))
{
user->WriteNumeric(404, "%s %s :Cannot send to channel (+m)", user->nick.c_str(), chan->name.c_str());
return CMD_FAILURE;
}
if (ServerInstance->Config->RestrictBannedUsers)
{
if (chan->IsBanned(user))
{
user->WriteNumeric(404, "%s %s :Cannot send to channel (you're banned)", user->nick.c_str(), chan->name.c_str());
return CMD_FAILURE;
}
}
}
ModResult MOD_RESULT;
std::string temp = parameters[1];
FIRST_MOD_RESULT(OnUserPreMessage, MOD_RESULT, (user, chan, TYPE_CHANNEL, temp, status, except_list, MSG_PRIVMSG));
if (MOD_RESULT == MOD_RES_DENY)
return CMD_FAILURE;
const char* text = temp.c_str();
/* Check again, a module may have zapped the input string */
if (temp.empty())
{
user->WriteNumeric(412, "%s :No text to send", user->nick.c_str());
return CMD_FAILURE;
}
FOREACH_MOD(I_OnText,OnText(user,chan,TYPE_CHANNEL,text,status,except_list));
if (status)
{
if (ServerInstance->Config->UndernetMsgPrefix)
{
chan->WriteAllExcept(user, false, status, except_list, "PRIVMSG %c%s :%c %s", status, chan->name.c_str(), status, text);
}
else
{
//.........这里部分代码省略.........
示例14: HandleRMB
CmdResult HandleRMB(const std::vector<std::string>& parameters, User *user, bool neworder)
{
User* target;
Channel* channel;
std::string reason;
std::string protectkey;
std::string founderkey;
bool hasnokicks;
/* Set these to the parameters needed, the new version of this module switches it's parameters around
* supplying a new command with the new order while keeping the old /remove with the older order.
* /remove <nick> <channel> [reason ...]
* /fpart <channel> <nick> [reason ...]
*/
const std::string& channame = parameters[neworder ? 0 : 1];
const std::string& username = parameters[neworder ? 1 : 0];
/* Look up the user we're meant to be removing from the channel */
target = ServerInstance->FindNick(username);
/* And the channel we're meant to be removing them from */
channel = ServerInstance->FindChan(channame);
/* Fix by brain - someone needs to learn to validate their input! */
if ((!target) || (target->registered != REG_ALL) || (!channel))
{
user->WriteNumeric(ERR_NOSUCHNICK, "%s %s :No such nick/channel", user->nick.c_str(), !channel ? channame.c_str() : username.c_str());
return CMD_FAILURE;
}
if (!channel->HasUser(target))
{
user->WriteServ( "NOTICE %s :*** The user %s is not on channel %s", user->nick.c_str(), target->nick.c_str(), channel->name.c_str());
return CMD_FAILURE;
}
int ulevel = channel->GetPrefixValue(user);
int tlevel = channel->GetPrefixValue(target);
hasnokicks = (ServerInstance->Modules->Find("m_nokicks.so") && channel->IsModeSet('Q'));
if (ServerInstance->ULine(target->server))
{
user->WriteNumeric(482, "%s %s :Only a u-line may remove a u-line from a channel.", user->nick.c_str(), channame.c_str());
return CMD_FAILURE;
}
/* We support the +Q channel mode via. the m_nokicks module, if the module is loaded and the mode is set then disallow the /remove */
if ((!IS_LOCAL(user)) || (!supportnokicks || !hasnokicks))
{
/* We'll let everyone remove their level and below, eg:
* ops can remove ops, halfops, voices, and those with no mode (no moders actually are set to 1)
* a ulined target will get a higher level than it's possible for a /remover to get..so they're safe.
* Nobody may remove a founder.
*/
if ((!IS_LOCAL(user)) || ((ulevel > VOICE_VALUE) && (ulevel >= tlevel) && (tlevel != 50000)))
{
// REMOVE/FPART will be sent to the target's server and it will reply with a PART (or do nothing if it doesn't understand the command)
if (!IS_LOCAL(target))
return CMD_SUCCESS;
std::string reasonparam;
/* If a reason is given, use it */
if(parameters.size() > 2)
reasonparam = parameters[2];
else
reasonparam = "No reason given";
/* Build up the part reason string. */
reason = "Removed by " + user->nick + ": " + reasonparam;
channel->WriteChannelWithServ(ServerInstance->Config->ServerName, "NOTICE %s :%s removed %s from the channel", channel->name.c_str(), user->nick.c_str(), target->nick.c_str());
target->WriteServ("NOTICE %s :*** %s removed you from %s with the message: %s", target->nick.c_str(), user->nick.c_str(), channel->name.c_str(), reasonparam.c_str());
channel->PartUser(target, reason);
}
else
{
user->WriteServ( "NOTICE %s :*** You do not have access to /remove %s from %s", user->nick.c_str(), target->nick.c_str(), channel->name.c_str());
return CMD_FAILURE;
}
}
else
{
/* m_nokicks.so was loaded and +Q was set, block! */
user->WriteServ( "484 %s %s :Can't remove user %s from channel (+Q set)", user->nick.c_str(), channel->name.c_str(), target->nick.c_str());
return CMD_FAILURE;
}
return CMD_SUCCESS;
}
示例15: Handle
/** Handle /INVITE
*/
CmdResult CommandInvite::Handle (const std::vector<std::string>& parameters, User *user)
{
ModResult MOD_RESULT;
if (parameters.size() == 2 || parameters.size() == 3)
{
User* u;
if (IS_LOCAL(user))
u = ServerInstance->FindNickOnly(parameters[0]);
else
u = ServerInstance->FindNick(parameters[0]);
Channel* c = ServerInstance->FindChan(parameters[1]);
time_t timeout = 0;
if (parameters.size() == 3)
{
if (IS_LOCAL(user))
timeout = ServerInstance->Time() + InspIRCd::Duration(parameters[1]);
else
timeout = ConvToInt(parameters[2]);
}
if ((!c) || (!u) || (u->registered != REG_ALL))
{
user->WriteNumeric(ERR_NOSUCHNICK, "%s %s :No such nick/channel",user->nick.c_str(), c ? parameters[0].c_str() : parameters[1].c_str());
return CMD_FAILURE;
}
if ((IS_LOCAL(user)) && (!c->HasUser(user)))
{
user->WriteNumeric(ERR_NOTONCHANNEL, "%s %s :You're not on that channel!",user->nick.c_str(), c->name.c_str());
return CMD_FAILURE;
}
if (c->HasUser(u))
{
user->WriteNumeric(ERR_USERONCHANNEL, "%s %s %s :is already on channel",user->nick.c_str(),u->nick.c_str(),c->name.c_str());
return CMD_FAILURE;
}
FIRST_MOD_RESULT(OnUserPreInvite, MOD_RESULT, (user,u,c,timeout));
if (MOD_RESULT == MOD_RES_DENY)
{
return CMD_FAILURE;
}
else if (MOD_RESULT == MOD_RES_PASSTHRU)
{
if (IS_LOCAL(user))
{
unsigned int rank = c->GetPrefixValue(user);
if (rank < HALFOP_VALUE)
{
// Check whether halfop mode is available and phrase error message accordingly
ModeHandler* mh = ServerInstance->Modes->FindMode('h', MODETYPE_CHANNEL);
user->WriteNumeric(ERR_CHANOPRIVSNEEDED, "%s %s :You must be a channel %soperator",
user->nick.c_str(), c->name.c_str(), (mh && mh->name == "halfop" ? "half-" : ""));
return CMD_FAILURE;
}
}
}
if (IS_LOCAL(u))
{
Invitation::Create(c, IS_LOCAL(u), timeout);
u->WriteFrom(user,"INVITE %s :%s",u->nick.c_str(),c->name.c_str());
}
if (IS_LOCAL(user))
user->WriteNumeric(RPL_INVITING, "%s %s %s",user->nick.c_str(),u->nick.c_str(),c->name.c_str());
if (ServerInstance->Config->AnnounceInvites != ServerConfig::INVITE_ANNOUNCE_NONE)
{
char prefix;
switch (ServerInstance->Config->AnnounceInvites)
{
case ServerConfig::INVITE_ANNOUNCE_OPS:
{
prefix = '@';
break;
}
case ServerConfig::INVITE_ANNOUNCE_DYNAMIC:
{
PrefixMode* mh = ServerInstance->Modes->FindPrefixMode('h');
prefix = (mh && mh->name == "halfop" ? mh->GetPrefix() : '@');
break;
}
default:
{
prefix = 0;
break;
}
}
c->WriteAllExceptSender(user, true, prefix, "NOTICE %s :*** %s invited %s into the channel", c->name.c_str(), user->nick.c_str(), u->nick.c_str());
}
FOREACH_MOD(OnUserInvite, (user,u,c,timeout));
}
else if (IS_LOCAL(user))
//.........这里部分代码省略.........