1
0
mirror of https://github.com/anope/anope.git synced 2026-07-05 02:33:13 +02:00

Added in support for permanet channel modes on non-registered channels

git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@2720 5417fbe8-f217-4b02-8779-1006273d7864
This commit is contained in:
Adam-
2009-12-30 02:07:17 +00:00
parent 7665af27cd
commit 4fd169b184
4 changed files with 57 additions and 45 deletions
+13 -7
View File
@@ -783,15 +783,21 @@ struct c_userlist {
UserData *ud;
};
class CoreExport Channel : public Extensible
enum ChannelFlags
{
private:
/** A map of channel modes with their parameters set on this channel
*/
std::map<ChannelModeName, std::string> Params;
/* Channel still exists when emptied */
CH_PERSIST
};
public:
/** Default constructor
class CoreExport Channel : public Extensible, public Flags<ChannelFlags>
{
private:
/** A map of channel modes with their parameters set on this channel
*/
std::map<ChannelModeName, std::string> Params;
public:
/** Default constructor
* @param name The channel name
* @param ts The time the channel was created
*/
+29 -17
View File
@@ -190,12 +190,6 @@ void Channel::SetModeInternal(ChannelMode *cm, const std::string &param, bool En
modes[cm->Name] = true;
/* Channel mode +P or so was set, mark this channel as persistant */
if (cm->Name == CMODE_PERM && ci)
{
ci->SetFlag(CI_PERSIST);
}
if (!param.empty())
{
if (cm->Type != MODE_PARAM)
@@ -214,6 +208,14 @@ void Channel::SetModeInternal(ChannelMode *cm, const std::string &param, bool En
Params.insert(std::make_pair(cm->Name, param));
}
/* Channel mode +P or so was set, mark this channel as persistant */
if (cm->Name == CMODE_PERM)
{
this->SetFlag(CH_PERSIST);
if (ci)
ci->SetFlag(CI_PERSIST);
}
EventReturn MOD_RESULT;
FOREACH_RESULT(I_OnChannelModeSet, OnChannelModeSet(this, cm->Name));
@@ -305,7 +307,7 @@ void Channel::RemoveModeInternal(ChannelMode *cm, const std::string &param, bool
{
if (param.empty())
{
alog("Channel::SetModeInternal() mode %c with no parameter for channel %s", cm->ModeChar, this->name);
alog("Channel::RemoveModeInternal() mode %c with no parameter for channel %s", cm->ModeChar, this->name);
return;
}
@@ -316,15 +318,6 @@ void Channel::RemoveModeInternal(ChannelMode *cm, const std::string &param, bool
modes[cm->Name] = false;
if (cm->Name == CMODE_PERM && ci)
{
ci->UnsetFlag(CI_PERSIST);
if (Config.s_BotServ && ci->bi && usercount == Config.BSMinUsers - 1)
ircdproto->SendPart(ci->bi, this, NULL);
if (!users)
delete this;
}
if (cm->Type == MODE_PARAM)
{
std::map<ChannelModeName, std::string>::iterator it = Params.find(cm->Name);
@@ -334,9 +327,28 @@ void Channel::RemoveModeInternal(ChannelMode *cm, const std::string &param, bool
}
}
if (cm->Name == CMODE_PERM)
{
this->UnsetFlag(CH_PERSIST);
if (ci)
{
ci->UnsetFlag(CI_PERSIST);
if (Config.s_BotServ && ci->bi && usercount == Config.BSMinUsers - 1)
ircdproto->SendPart(ci->bi, this, NULL);
}
}
EventReturn MOD_RESULT;
FOREACH_RESULT(I_OnChannelModeUnset, OnChannelModeUnset(this, cm->Name));
/* We set -P in an empty channel, delete the channel */
if (cm->Name == CMODE_PERM && !users)
{
delete this;
return;
}
/* Check for mlock */
/* Non registered channel, no mlock */
@@ -733,7 +745,7 @@ void chan_deluser(User * user, Channel * c)
c->usercount--;
/* Channel is persistant, it shouldn't be deleted and the service bot should stay */
if (c->ci && c->ci->HasFlag(CI_PERSIST))
if (c->HasFlag(CH_PERSIST) || (c->ci && c->ci->HasFlag(CI_PERSIST)))
return;
if (Config.s_BotServ && c->ci && c->ci->bi && c->usercount == Config.BSMinUsers - 1)
-1
View File
@@ -93,7 +93,6 @@ class CommandCSRegister : public Command
else if (ci->HasFlag(CI_PERSIST) && (cm = ModeManager::FindChannelModeByName(CMODE_PERM)))
{
c->SetMode(NULL, CMODE_PERM);
ci->SetFlag(CI_PERSIST);
}
FOREACH_MOD(I_OnChanRegistered, OnChanRegistered(ci));
+15 -20
View File
@@ -568,7 +568,7 @@ class CommandCSSet : public Command
/* Set the perm mode */
if (cm && ci->c && !ci->c->HasMode(CMODE_PERM))
{
ci->c->SetMode(NULL, CMODE_PERM);
ci->c->SetMode(NULL, cm);
}
}
@@ -581,27 +581,22 @@ class CommandCSSet : public Command
ci->UnsetFlag(CI_PERSIST);
/* Unset perm mode */
if (ci->c && ci->c->HasMode(CMODE_PERM))
{
ci->c->RemoveMode(NULL, CMODE_PERM);
}
/* Persist is set off... remove the bot and delete the channel if its empty */
else if (ci->c)
{
if (Config.s_BotServ && ci->bi && ci->c->usercount == Config.BSMinUsers - 1)
ircdproto->SendPart(ci->bi, ci->c, NULL);
if (!ci->c->users)
delete ci->c;
if (cm && ci->c && ci->c->HasMode(CMODE_PERM))
ci->c->RemoveMode(NULL, cm);
if (Config.s_BotServ && ci->bi && ci->c->usercount == Config.BSMinUsers - 1)
ircdproto->SendPart(ci->bi, ci->c, NULL);
/* No channel mode, no BotServ, but using ChanServ as the botserv bot
* which was assigned when persist was set on
*/
if (!cm && !Config.s_BotServ && ci->bi)
{
/* Unassign bot */
findbot(Config.s_ChanServ)->UnAssign(NULL, ci);
}
/* No channel mode, no BotServ, but using ChanServ as the botserv bot
* which was assigned when persist was set on
*/
if (!cm && !Config.s_BotServ && ci->bi)
{
/* Unassign bot */
findbot(Config.s_ChanServ)->UnAssign(NULL, ci);
}
if (ci->c && !ci->c->users)
delete ci->c;
}
notice_lang(Config.s_ChanServ, u, CHAN_SET_PERSIST_OFF, ci->name);