mirror of
https://github.com/anope/anope.git
synced 2026-07-02 02:46:39 +02:00
Bug #1285 - Fixed setting -P on channels with only a service bot in it
This commit is contained in:
+17
-7
@@ -470,15 +470,19 @@ void Channel::RemoveModeInternal(ChannelMode *cm, const Anope::string ¶m, bo
|
||||
{
|
||||
ci->UnsetFlag(CI_PERSIST);
|
||||
if (!Config->s_BotServ.empty() && ci->bi && this->FindUser(ci->bi) && Config->BSMinUsers && this->users.size() <= Config->BSMinUsers)
|
||||
{
|
||||
bool empty = this->users.size() == 1;
|
||||
this->ci->bi->Part(this);
|
||||
if (empty)
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* We set -P in an empty channel, delete the channel */
|
||||
if (cm->Name == CMODE_PERM && users.empty())
|
||||
{
|
||||
delete this;
|
||||
return;
|
||||
if (this->users.empty())
|
||||
{
|
||||
delete this;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* Check for mlock */
|
||||
@@ -685,6 +689,9 @@ void Channel::SetModes(BotInfo *bi, bool EnforceMLock, const char *cmodes, ...)
|
||||
*/
|
||||
void Channel::SetModesInternal(User *setter, const Anope::string &mode, bool EnforceMLock)
|
||||
{
|
||||
/* Removing channel modes *may* delete this channel */
|
||||
dynamic_reference<Channel> this_reference(this);
|
||||
|
||||
spacesepstream sep_modes(mode);
|
||||
Anope::string m;
|
||||
|
||||
@@ -693,7 +700,7 @@ void Channel::SetModesInternal(User *setter, const Anope::string &mode, bool Enf
|
||||
Anope::string modestring;
|
||||
Anope::string paramstring;
|
||||
int add = -1;
|
||||
for (unsigned int i = 0, end = m.length(); i < end; ++i)
|
||||
for (unsigned int i = 0, end = m.length(); i < end && this_reference; ++i)
|
||||
{
|
||||
ChannelMode *cm;
|
||||
|
||||
@@ -755,6 +762,9 @@ void Channel::SetModesInternal(User *setter, const Anope::string &mode, bool Enf
|
||||
Log() << "warning: Channel::SetModesInternal() recieved more modes requiring params than params, modes: " << mode;
|
||||
}
|
||||
|
||||
if (!this_reference)
|
||||
return;
|
||||
|
||||
if (setter)
|
||||
Log(setter, this, "mode") << modestring << paramstring;
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user