mirror of
https://github.com/anope/anope.git
synced 2026-06-26 13:36:38 +02:00
Add "virtual mode" support
This allows fully tracking extbans and other modes set by a different underlying mode, such as InspIRCd's namedmodes Add two configuration options to cs_ban to configure which mode is set and whether or not to kick banned users. Add default "mute" fantasy command to botserv.example.conf
This commit is contained in:
+25
-13
@@ -248,11 +248,14 @@ std::pair<Channel::ModeList::iterator, Channel::ModeList::iterator> Channel::Get
|
||||
return std::make_pair(it, it_end);
|
||||
}
|
||||
|
||||
void Channel::SetModeInternal(MessageSource &setter, ChannelMode *cm, const Anope::string ¶m, bool enforce_mlock)
|
||||
void Channel::SetModeInternal(MessageSource &setter, ChannelMode *ocm, const Anope::string &oparam, bool enforce_mlock)
|
||||
{
|
||||
if (!cm)
|
||||
if (!ocm)
|
||||
return;
|
||||
|
||||
Anope::string param = oparam;
|
||||
ChannelMode *cm = ocm->Unwrap(param);
|
||||
|
||||
EventReturn MOD_RESULT;
|
||||
|
||||
/* Setting v/h/o/a/q etc */
|
||||
@@ -315,11 +318,14 @@ void Channel::SetModeInternal(MessageSource &setter, ChannelMode *cm, const Anop
|
||||
this->CheckModes();
|
||||
}
|
||||
|
||||
void Channel::RemoveModeInternal(MessageSource &setter, ChannelMode *cm, const Anope::string ¶m, bool enforce_mlock)
|
||||
void Channel::RemoveModeInternal(MessageSource &setter, ChannelMode *ocm, const Anope::string &oparam, bool enforce_mlock)
|
||||
{
|
||||
if (!cm)
|
||||
if (!ocm)
|
||||
return;
|
||||
|
||||
Anope::string param = oparam;
|
||||
ChannelMode *cm = ocm->Unwrap(param);
|
||||
|
||||
EventReturn MOD_RESULT;
|
||||
|
||||
/* Setting v/h/o/a/q etc */
|
||||
@@ -433,9 +439,12 @@ void Channel::SetMode(BotInfo *bi, ChannelMode *cm, const Anope::string ¶m,
|
||||
this->chanserv_modecount++;
|
||||
}
|
||||
|
||||
ModeManager::StackerAdd(bi, this, cm, true, param);
|
||||
Anope::string wparam = param;
|
||||
ChannelMode *wcm = cm->Wrap(wparam);
|
||||
|
||||
ModeManager::StackerAdd(bi, this, wcm, true, wparam);
|
||||
MessageSource ms(bi);
|
||||
SetModeInternal(ms, cm, param, enforce_mlock);
|
||||
SetModeInternal(ms, wcm, wparam, enforce_mlock);
|
||||
}
|
||||
|
||||
void Channel::SetMode(BotInfo *bi, const Anope::string &mname, const Anope::string ¶m, bool enforce_mlock)
|
||||
@@ -484,9 +493,12 @@ void Channel::RemoveMode(BotInfo *bi, ChannelMode *cm, const Anope::string ¶
|
||||
this->chanserv_modecount++;
|
||||
}
|
||||
|
||||
ModeManager::StackerAdd(bi, this, cm, false, realparam);
|
||||
Anope::string wparam = realparam;
|
||||
ChannelMode *wcm = cm->Wrap(wparam);
|
||||
|
||||
ModeManager::StackerAdd(bi, this, wcm, false, wparam);
|
||||
MessageSource ms(bi);
|
||||
RemoveModeInternal(ms, cm, realparam, enforce_mlock);
|
||||
RemoveModeInternal(ms, wcm, wparam, enforce_mlock);
|
||||
}
|
||||
|
||||
void Channel::RemoveMode(BotInfo *bi, const Anope::string &mname, const Anope::string ¶m, bool enforce_mlock)
|
||||
@@ -849,21 +861,21 @@ void Channel::SetCorrectModes(User *user, bool give_modes)
|
||||
}
|
||||
}
|
||||
|
||||
bool Channel::Unban(User *u, bool full)
|
||||
bool Channel::Unban(User *u, const Anope::string &mode, bool full)
|
||||
{
|
||||
if (!this->HasMode("BAN"))
|
||||
if (!this->HasMode(mode))
|
||||
return false;
|
||||
|
||||
bool ret = false;
|
||||
|
||||
std::pair<Channel::ModeList::iterator, Channel::ModeList::iterator> bans = this->GetModeList("BAN");
|
||||
std::pair<Channel::ModeList::iterator, Channel::ModeList::iterator> bans = this->GetModeList(mode);
|
||||
for (; bans.first != bans.second;)
|
||||
{
|
||||
Entry ban("BAN", bans.first->second);
|
||||
Entry ban(mode, bans.first->second);
|
||||
++bans.first;
|
||||
if (ban.Matches(u, full))
|
||||
{
|
||||
this->RemoveMode(NULL, "BAN", ban.GetMask());
|
||||
this->RemoveMode(NULL, mode, ban.GetMask());
|
||||
ret = true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user