1
0
mirror of https://github.com/anope/anope.git synced 2026-06-25 21:06:38 +02:00
Files
anope/modules/core/os_chanlist.cpp
T
Adam fb551f0d5d Made Anope keep track of channels its clients are in if it splits from its uplink, then burst them back to its uplink once connection is reestablished.
Also made Anope use TS enforcement to change persistant channels creation time to the time they were registered.
2010-08-21 01:40:36 -04:00

102 lines
2.8 KiB
C++

/* OperServ core functions
*
* (C) 2003-2010 Anope Team
* Contact us at team@anope.org
*
* Please read COPYING and README for further details.
*
* Based on the original code of Epona by Lara.
* Based on the original code of Services by Andy Church.
*/
/*************************************************************************/
#include "module.h"
class CommandOSChanList : public Command
{
public:
CommandOSChanList() : Command("CHANLIST", 0, 2)
{
}
CommandReturn Execute(User *u, const std::vector<Anope::string> &params)
{
Anope::string pattern = !params.empty() ? params[0] : "";
Anope::string opt = params.size() > 1 ? params[1] : "";
std::list<ChannelModeName> Modes;
User *u2;
if (!opt.empty() && opt.equals_ci("SECRET"))
{
Modes.push_back(CMODE_SECRET);
Modes.push_back(CMODE_PRIVATE);
}
if (!pattern.empty() && (u2 = finduser(pattern)))
{
notice_lang(Config->s_OperServ, u, OPER_CHANLIST_HEADER_USER, u2->nick.c_str());
for (UChannelList::iterator uit = u2->chans.begin(), uit_end = u2->chans.end(); uit != uit_end; ++uit)
{
ChannelContainer *cc = *uit;
if (!Modes.empty())
for (std::list<ChannelModeName>::iterator it = Modes.begin(), it_end = Modes.end(); it != it_end; ++it)
if (!cc->chan->HasMode(*it))
continue;
notice_lang(Config->s_OperServ, u, OPER_CHANLIST_RECORD, cc->chan->name.c_str(), cc->chan->users.size(), cc->chan->GetModes(true, true).c_str(), !cc->chan->topic.empty() ? cc->chan->topic.c_str() : "");
}
}
else
{
notice_lang(Config->s_OperServ, u, OPER_CHANLIST_HEADER);
for (channel_map::const_iterator cit = ChannelList.begin(), cit_end = ChannelList.end(); cit != cit_end; ++cit)
{
Channel *c = cit->second;
if (!pattern.empty() && !Anope::Match(c->name, pattern))
continue;
if (!Modes.empty())
for (std::list<ChannelModeName>::iterator it = Modes.begin(), it_end = Modes.end(); it != it_end; ++it)
if (!c->HasMode(*it))
continue;
notice_lang(Config->s_OperServ, u, OPER_CHANLIST_RECORD, c->name.c_str(), c->users.size(), c->GetModes(true, true).c_str(), !c->topic.empty() ? c->topic.c_str() : "");
}
}
notice_lang(Config->s_OperServ, u, OPER_CHANLIST_END);
return MOD_CONT;
}
bool OnHelp(User *u, const Anope::string &subcommand)
{
notice_help(Config->s_OperServ, u, OPER_HELP_CHANLIST);
return true;
}
void OnServHelp(User *u)
{
notice_lang(Config->s_OperServ, u, OPER_HELP_CMD_CHANLIST);
}
};
class OSChanList : public Module
{
CommandOSChanList commandoschanlist;
public:
OSChanList(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator)
{
this->SetAuthor("Anope");
this->SetType(CORE);
this->AddCommand(OperServ, &commandoschanlist);
}
};
MODULE_INIT(OSChanList)