* | Inspire Internet Relay Chat Daemon |
* +------------------------------------+
*
- * InspIRCd: (C) 2002-2009 InspIRCd Development Team
+ * InspIRCd: (C) 2002-2010 InspIRCd Development Team
* See: http://wiki.inspircd.org/Credits
*
* This program is free but copyrighted software; see
modes[mode-65] = mode_on;
}
-void Channel::SetModeParam(char mode, std::string parameter)
+void Channel::SetMode(ModeHandler* mh, bool on)
+{
+ modes[mh->GetModeChar() - 65] = on;
+}
+
+void Channel::SetModeParam(char mode, const std::string& parameter)
{
CustomModeList::iterator n = custom_mode_params.find(mode);
// always erase, even if changing, so that the map gets the new value
}
}
+void Channel::SetModeParam(ModeHandler* mode, const std::string& parameter)
+{
+ SetModeParam(mode->GetModeChar(), parameter);
+}
+
std::string Channel::GetModeParameter(char mode)
{
CustomModeList::iterator n = custom_mode_params.find(mode);
return "";
}
+std::string Channel::GetModeParameter(ModeHandler* mode)
+{
+ CustomModeList::iterator n = custom_mode_params.find(mode->GetModeChar());
+ if (n != custom_mode_params.end())
+ return n->second;
+ return "";
+}
+
int Channel::SetTopic(User *u, std::string &ntopic, bool forceset)
{
if (u)
}
if ((this->IsModeSet('t')) && (this->GetPrefixValue(u) < HALFOP_VALUE))
{
- u->WriteNumeric(482, "%s %s :You must be at least a half-operator to change the topic on this channel", u->nick.c_str(), this->name.c_str());
+ u->WriteNumeric(482, "%s %s :You do not have access to change the topic on this channel", u->nick.c_str(), this->name.c_str());
return CMD_FAILURE;
}
}
delete a->second;
userlist.erase(a);
}
+
+ if (userlist.empty())
+ {
+ ModResult res;
+ FIRST_MOD_RESULT(OnChannelPreDelete, res, (this));
+ if (res == MOD_RES_DENY)
+ return;
+ chan_hash::iterator iter = ServerInstance->chanlist->find(this->name);
+ /* kill the record */
+ if (iter != ServerInstance->chanlist->end())
+ {
+ FOREACH_MOD(I_OnChannelDelete, OnChannelDelete(this));
+ ServerInstance->chanlist->erase(iter);
+ }
+ ServerInstance->GlobalCulls.AddItem(this);
+ }
}
bool Channel::HasUser(User* user)
*/
if (IS_LOCAL(user) && !override)
{
- // Checking MyClass exists because we *may* get here with NULL, not 100% sure.
- if (user->MyClass && user->MyClass->maxchans)
+ if (user->HasPrivPermission("channels/high-join-limit"))
{
- if (user->HasPrivPermission("channels/high-join-limit"))
+ if (user->chans.size() >= ServerInstance->Config->OperMaxChans)
{
- if (user->chans.size() >= ServerInstance->Config->OperMaxChans)
- {
- user->WriteNumeric(ERR_TOOMANYCHANNELS, "%s %s :You are on too many channels",user->nick.c_str(), cn);
- return NULL;
- }
+ user->WriteNumeric(ERR_TOOMANYCHANNELS, "%s %s :You are on too many channels",user->nick.c_str(), cn);
+ return NULL;
}
- else
+ }
+ else
+ {
+ unsigned int maxchans = user->GetClass()->maxchans;
+ if (!maxchans)
+ maxchans = ServerInstance->Config->MaxChans;
+ if (user->chans.size() >= maxchans)
{
- if (user->chans.size() >= user->MyClass->maxchans)
- {
- user->WriteNumeric(ERR_TOOMANYCHANNELS, "%s %s :You are on too many channels",user->nick.c_str(), cn);
- return NULL;
- }
+ user->WriteNumeric(ERR_TOOMANYCHANNELS, "%s %s :You are on too many channels",user->nick.c_str(), cn);
+ return NULL;
}
}
}
else if (MOD_RESULT == MOD_RES_PASSTHRU)
{
std::string ckey = Ptr->GetModeParameter('k');
- bool invited = user->IsInvited(Ptr->name.c_str());
+ bool invited = IS_LOCAL(user)->IsInvited(Ptr->name.c_str());
bool can_bypass = ServerInstance->Config->InvBypassModes && invited;
if (!ckey.empty())
*/
if (invited)
{
- user->RemoveInvite(Ptr->name.c_str());
+ IS_LOCAL(user)->RemoveInvite(Ptr->name.c_str());
}
}
}
Ptr->WriteAllExcept(user, false, 0, except_list, "JOIN :%s", Ptr->name.c_str());
/* Theyre not the first ones in here, make sure everyone else sees the modes we gave the user */
- std::string ms = ServerInstance->Modes->ModeString(user, Ptr);
+ std::string ms = memb->modes;
+ for(unsigned int i=0; i < memb->modes.length(); i++)
+ ms.append(" ").append(user->nick);
if ((Ptr->GetUserCounter() > 1) && (ms.length()))
Ptr->WriteAllExceptSender(user, true, 0, "MODE %s +%s", Ptr->name.c_str(), ms.c_str());
}
this->DelUser(user);
- if (userlist.empty())
- {
- ModResult res;
- FIRST_MOD_RESULT(OnChannelPreDelete, res, (this));
- if (res == MOD_RES_DENY)
- return;
- chan_hash::iterator iter = ServerInstance->chanlist->find(this->name);
- /* kill the record */
- if (iter != ServerInstance->chanlist->end())
- {
- FOREACH_MOD(I_OnChannelDelete, OnChannelDelete(this));
- ServerInstance->chanlist->erase(iter);
- }
- ServerInstance->GlobalCulls.AddItem(this);
- }
-}
-
-void Channel::ServerKickUser(User* user, const char* reason, const std::string& servername)
-{
- if (servername.empty() || !ServerInstance->Config->HideWhoisServer.empty())
- ServerInstance->FakeClient->server = ServerInstance->Config->ServerName;
- else
- ServerInstance->FakeClient->server = servername;
-
- KickUser(ServerInstance->FakeClient, user, reason);
}
void Channel::KickUser(User *src, User *user, const char* reason)
}
this->DelUser(user);
- if (userlist.empty())
- {
- ModResult res;
- FIRST_MOD_RESULT(OnChannelPreDelete, res, (this));
- if (res == MOD_RES_DENY)
- return;
- chan_hash::iterator iter = ServerInstance->chanlist->find(this->name);
- /* kill the record */
- if (iter != ServerInstance->chanlist->end())
- {
- FOREACH_MOD(I_OnChannelDelete, OnChannelDelete(this));
- ServerInstance->chanlist->erase(iter);
- }
- ServerInstance->GlobalCulls.AddItem(this);
- }
}
void Channel::WriteChannel(User* user, const char* text, ...)
void Channel::RawWriteAllExcept(User* user, bool serversource, char status, CUList &except_list, const std::string &out)
{
- char statmode = 0;
+ unsigned int minrank = 0;
if (status)
{
ModeHandler* mh = ServerInstance->Modes->FindPrefix(status);
if (mh)
- statmode = mh->GetModeChar();
+ minrank = mh->GetPrefixRank();
}
for (UserMembIter i = userlist.begin(); i != userlist.end(); i++)
{
- if ((IS_LOCAL(i->first)) && (except_list.find(i->first) == except_list.end()))
+ if (IS_LOCAL(i->first) && (except_list.find(i->first) == except_list.end()))
{
- /* User doesnt have the status we're after */
- if (statmode && !i->second->hasMode(statmode))
+ /* User doesn't have the status we're after */
+ if (minrank && i->second->getRank() < minrank)
continue;
i->first->Write(out);
{
*offset++ = n + 65;
extparam.clear();
- switch (n)
+ if (n == 'k' - 65 && !showkey)
{
- case CM_KEY:
- // Unfortunately this must be special-cased, as we definitely don't want to always display key.
- if (showkey)
- {
- extparam = this->GetModeParameter('k');
- }
- else
- {
- extparam = "<key>";
- }
- break;
- case CM_NOEXTERNAL:
- case CM_TOPICLOCK:
- case CM_INVITEONLY:
- case CM_MODERATED:
- case CM_SECRET:
- case CM_PRIVATE:
- /* We know these have no parameters */
- break;
- default:
- extparam = this->GetModeParameter(n + 65);
- break;
+ extparam = "<key>";
+ }
+ else
+ {
+ extparam = this->GetModeParameter(n + 65);
}
if (!extparam.empty())
{
return m->second->getRank();
}
-void Channel::SetPrefix(User* user, char prefix, bool adding)
+bool Channel::SetPrefix(User* user, char prefix, bool adding)
{
ModeHandler* delta_mh = ServerInstance->Modes->FindMode(prefix, MODETYPE_CHANNEL);
if (!delta_mh)
- return;
+ return false;
UserMembIter m = userlist.find(user);
if (m == userlist.end())
- return;
+ return false;
for(unsigned int i=0; i < m->second->modes.length(); i++)
{
char mchar = m->second->modes[i];
m->second->modes.substr(0,i) +
(adding ? std::string(1, prefix) : "") +
m->second->modes.substr(mchar == prefix ? i+1 : i);
- return;
+ return adding != (mchar == prefix);
}
}
if (adding)
m->second->modes += std::string(1, prefix);
+ return adding;
}
void Channel::RemoveAllPrefixes(User* user)