1
0
mirror of https://github.com/anope/anope.git synced 2026-06-29 16:56:37 +02:00

Allow /os mode clear [all] to unset modes, similar to old clearmodes

This commit is contained in:
Adam
2013-02-19 03:58:54 -05:00
parent a1f92638e3
commit 32592987c8
3 changed files with 73 additions and 34 deletions
+31 -26
View File
@@ -277,6 +277,37 @@ size_t Channel::HasMode(const Anope::string &mname, const Anope::string &param)
return 0;
}
Anope::string Channel::GetModes(bool complete, bool plus)
{
Anope::string res, params;
for (std::multimap<Anope::string, Anope::string>::const_iterator it = this->modes.begin(), it_end = this->modes.end(); it != it_end; ++it)
{
ChannelMode *cm = ModeManager::FindChannelModeByName(it->first);
if (!cm || cm->type == MODE_LIST)
continue;
res += cm->mchar;
if (complete && !it->second.empty())
{
ChannelModeParam *cmp = NULL;
if (cm->type == MODE_PARAM)
cmp = anope_dynamic_static_cast<ChannelModeParam *>(cm);
if (plus || !cmp || !cmp->minus_no_arg)
params += " " + it->second;
}
}
return res + params;
}
const Channel::ModeList &Channel::GetModes() const
{
return this->modes;
}
std::pair<Channel::ModeList::iterator, Channel::ModeList::iterator> Channel::GetModeList(const Anope::string &mname)
{
Channel::ModeList::iterator it = this->modes.find(mname), it_end = it;
@@ -827,32 +858,6 @@ bool Channel::Kick(BotInfo *bi, User *u, const char *reason, ...)
return true;
}
Anope::string Channel::GetModes(bool complete, bool plus)
{
Anope::string res, params;
for (std::multimap<Anope::string, Anope::string>::const_iterator it = this->modes.begin(), it_end = this->modes.end(); it != it_end; ++it)
{
ChannelMode *cm = ModeManager::FindChannelModeByName(it->first);
if (!cm || cm->type == MODE_LIST)
continue;
res += cm->mchar;
if (complete && !it->second.empty())
{
ChannelModeParam *cmp = NULL;
if (cm->type == MODE_PARAM)
cmp = anope_dynamic_static_cast<ChannelModeParam *>(cm);
if (plus || !cmp || !cmp->minus_no_arg)
params += " " + it->second;
}
}
return res + params;
}
void Channel::ChangeTopicInternal(const Anope::string &user, const Anope::string &newtopic, time_t ts)
{
User *u = User::Find(user);