From 6302f980fe6dad83aab7d2dc1046dadea5ffd939 Mon Sep 17 00:00:00 2001 From: Adam Date: Mon, 14 Dec 2015 16:52:24 -0500 Subject: New source tree structure for modules. From commands/cs_access => chanserv/access etc. --- modules/pseudoclients/botserv/CMakeLists.txt | 1 - modules/pseudoclients/botserv/botserv.cpp | 228 ------- modules/pseudoclients/chanserv/CMakeLists.txt | 1 - modules/pseudoclients/chanserv/chanaccess.cpp | 127 ---- modules/pseudoclients/chanserv/chanaccess.h | 30 - modules/pseudoclients/chanserv/chanaccesstype.h | 21 - modules/pseudoclients/chanserv/channel.cpp | 429 ------------- modules/pseudoclients/chanserv/channel.h | 68 -- modules/pseudoclients/chanserv/channeltype.cpp | 45 -- modules/pseudoclients/chanserv/channeltype.h | 34 - modules/pseudoclients/chanserv/chanserv.cpp | 587 ------------------ modules/pseudoclients/chanserv/level.cpp | 33 - modules/pseudoclients/chanserv/level.h | 16 - modules/pseudoclients/chanserv/leveltype.h | 16 - modules/pseudoclients/chanserv/mode.cpp | 33 - modules/pseudoclients/chanserv/mode.h | 17 - modules/pseudoclients/chanserv/modetype.h | 15 - modules/pseudoclients/global.cpp | 107 ---- modules/pseudoclients/hostserv.cpp | 135 ---- modules/pseudoclients/memoserv/CMakeLists.txt | 1 - modules/pseudoclients/memoserv/ignore.cpp | 27 - modules/pseudoclients/memoserv/ignore.h | 15 - modules/pseudoclients/memoserv/ignoretype.cpp | 10 - modules/pseudoclients/memoserv/ignoretype.h | 10 - modules/pseudoclients/memoserv/memo.cpp | 72 --- modules/pseudoclients/memoserv/memo.h | 29 - modules/pseudoclients/memoserv/memoinfo.cpp | 63 -- modules/pseudoclients/memoserv/memoinfo.h | 23 - modules/pseudoclients/memoserv/memoinfotype.cpp | 10 - modules/pseudoclients/memoserv/memoinfotype.h | 10 - modules/pseudoclients/memoserv/memoserv.cpp | 298 --------- modules/pseudoclients/memoserv/memotype.cpp | 14 - modules/pseudoclients/memoserv/memotype.h | 13 - modules/pseudoclients/nickserv/CMakeLists.txt | 1 - modules/pseudoclients/nickserv/account.cpp | 129 ---- modules/pseudoclients/nickserv/account.h | 35 -- modules/pseudoclients/nickserv/accounttype.cpp | 42 -- modules/pseudoclients/nickserv/accounttype.h | 23 - modules/pseudoclients/nickserv/identifyrequest.cpp | 51 -- modules/pseudoclients/nickserv/identifyrequest.h | 13 - modules/pseudoclients/nickserv/mode.cpp | 23 - modules/pseudoclients/nickserv/mode.h | 14 - modules/pseudoclients/nickserv/modetype.h | 14 - modules/pseudoclients/nickserv/nick.cpp | 192 ------ modules/pseudoclients/nickserv/nick.h | 46 -- modules/pseudoclients/nickserv/nickserv.cpp | 686 --------------------- modules/pseudoclients/nickserv/nicktype.cpp | 45 -- modules/pseudoclients/nickserv/nicktype.h | 32 - modules/pseudoclients/operserv.cpp | 337 ---------- 49 files changed, 4221 deletions(-) delete mode 100644 modules/pseudoclients/botserv/CMakeLists.txt delete mode 100644 modules/pseudoclients/botserv/botserv.cpp delete mode 100644 modules/pseudoclients/chanserv/CMakeLists.txt delete mode 100644 modules/pseudoclients/chanserv/chanaccess.cpp delete mode 100644 modules/pseudoclients/chanserv/chanaccess.h delete mode 100644 modules/pseudoclients/chanserv/chanaccesstype.h delete mode 100644 modules/pseudoclients/chanserv/channel.cpp delete mode 100644 modules/pseudoclients/chanserv/channel.h delete mode 100644 modules/pseudoclients/chanserv/channeltype.cpp delete mode 100644 modules/pseudoclients/chanserv/channeltype.h delete mode 100644 modules/pseudoclients/chanserv/chanserv.cpp delete mode 100644 modules/pseudoclients/chanserv/level.cpp delete mode 100644 modules/pseudoclients/chanserv/level.h delete mode 100644 modules/pseudoclients/chanserv/leveltype.h delete mode 100644 modules/pseudoclients/chanserv/mode.cpp delete mode 100644 modules/pseudoclients/chanserv/mode.h delete mode 100644 modules/pseudoclients/chanserv/modetype.h delete mode 100644 modules/pseudoclients/global.cpp delete mode 100644 modules/pseudoclients/hostserv.cpp delete mode 100644 modules/pseudoclients/memoserv/CMakeLists.txt delete mode 100644 modules/pseudoclients/memoserv/ignore.cpp delete mode 100644 modules/pseudoclients/memoserv/ignore.h delete mode 100644 modules/pseudoclients/memoserv/ignoretype.cpp delete mode 100644 modules/pseudoclients/memoserv/ignoretype.h delete mode 100644 modules/pseudoclients/memoserv/memo.cpp delete mode 100644 modules/pseudoclients/memoserv/memo.h delete mode 100644 modules/pseudoclients/memoserv/memoinfo.cpp delete mode 100644 modules/pseudoclients/memoserv/memoinfo.h delete mode 100644 modules/pseudoclients/memoserv/memoinfotype.cpp delete mode 100644 modules/pseudoclients/memoserv/memoinfotype.h delete mode 100644 modules/pseudoclients/memoserv/memoserv.cpp delete mode 100644 modules/pseudoclients/memoserv/memotype.cpp delete mode 100644 modules/pseudoclients/memoserv/memotype.h delete mode 100644 modules/pseudoclients/nickserv/CMakeLists.txt delete mode 100644 modules/pseudoclients/nickserv/account.cpp delete mode 100644 modules/pseudoclients/nickserv/account.h delete mode 100644 modules/pseudoclients/nickserv/accounttype.cpp delete mode 100644 modules/pseudoclients/nickserv/accounttype.h delete mode 100644 modules/pseudoclients/nickserv/identifyrequest.cpp delete mode 100644 modules/pseudoclients/nickserv/identifyrequest.h delete mode 100644 modules/pseudoclients/nickserv/mode.cpp delete mode 100644 modules/pseudoclients/nickserv/mode.h delete mode 100644 modules/pseudoclients/nickserv/modetype.h delete mode 100644 modules/pseudoclients/nickserv/nick.cpp delete mode 100644 modules/pseudoclients/nickserv/nick.h delete mode 100644 modules/pseudoclients/nickserv/nickserv.cpp delete mode 100644 modules/pseudoclients/nickserv/nicktype.cpp delete mode 100644 modules/pseudoclients/nickserv/nicktype.h delete mode 100644 modules/pseudoclients/operserv.cpp (limited to 'modules/pseudoclients') diff --git a/modules/pseudoclients/botserv/CMakeLists.txt b/modules/pseudoclients/botserv/CMakeLists.txt deleted file mode 100644 index 781f0ef1f..000000000 --- a/modules/pseudoclients/botserv/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -build_subdir(${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/modules/pseudoclients/botserv/botserv.cpp b/modules/pseudoclients/botserv/botserv.cpp deleted file mode 100644 index 0b51691fc..000000000 --- a/modules/pseudoclients/botserv/botserv.cpp +++ /dev/null @@ -1,228 +0,0 @@ -/* BotServ core functions - * - * (C) 2003-2014 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" -#include "modules/botserv.h" -#include "modules/help.h" - -class BotServCore : public Module, public BotServ::BotServService - , public EventHook - , public EventHook - , public EventHook - , public EventHook - , public EventHook - , public EventHook - , public EventHook - , public EventHook - , public EventHook -{ - Reference BotServ; - ExtensibleRef persist, inhabit;//XXX? - - public: - BotServCore(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PSEUDOCLIENT | VENDOR) - , BotServ::BotServService(this) - , persist("PERSIST") - , inhabit("inhabit") - { - } - - void OnReload(Configuration::Conf *conf) override - { - const Anope::string &bsnick = conf->GetModule(this)->Get("client"); - BotServ = ServiceBot::Find(bsnick, true); - } - - void OnSetCorrectModes(User *user, Channel *chan, ChanServ::AccessGroup &access, bool &give_modes, bool &take_modes) override - { - /* Do not allow removing bot modes on our service bots */ - if (chan->ci && chan->ci->GetBot() == user) - { - const Anope::string &botmodes = Config->GetModule(this)->Get("botmodes"); - for (unsigned i = 0; i < botmodes.length(); ++i) - chan->SetMode(chan->ci->GetBot(), ModeManager::FindChannelModeByChar(botmodes[i]), chan->ci->GetBot()->GetUID()); - } - } - - void OnBotAssign(User *sender, ChanServ::Channel *ci, ServiceBot *bi) override - { - if (ci->c && ci->c->users.size() >= Config->GetModule(this)->Get("minusers")) - { - ChannelStatus status(Config->GetModule(this)->Get("botmodes")); - bi->Join(ci->c, &status); - } - } - - void OnJoinChannel(User *user, Channel *c) override - { - if (!Config || !IRCD) - return; - - ServiceBot *bi = user->server == Me ? dynamic_cast(user) : NULL; - if (bi && Config->GetModule(this)->Get("smartjoin")) - { - std::vector bans = c->GetModeList("BAN"); - - /* We check for bans */ - for (unsigned int i = 0; i < bans.size(); ++i) - { - Entry ban("BAN", bans[i]); - if (ban.Matches(user)) - c->RemoveMode(NULL, "BAN", ban.GetMask()); - } - - Anope::string Limit; - unsigned limit = 0; - try - { - if (c->GetParam("LIMIT", Limit)) - limit = convertTo(Limit); - } - catch (const ConvertException &) { } - - /* Should we be invited? */ - if (c->HasMode("INVITE") || (limit && c->users.size() >= limit)) - { - ChannelMode *cm = ModeManager::FindChannelModeByName("OP"); - char symbol = cm ? anope_dynamic_static_cast(cm)->symbol : 0; - IRCD->SendNotice(bi, (symbol ? Anope::string(symbol) : "") + c->name, "%s invited %s into the channel.", user->nick.c_str(), user->nick.c_str()); - } - - ModeManager::ProcessModes(); - } - - if (user->server != Me && c->ci && c->ci->GetBot()) - { - /** - * We let the bot join even if it was an ignored user, as if we don't, - * and the ignored user doesn't just leave, the bot will never - * make it into the channel, leaving the channel botless even for - * legit users - Rob - **/ - /* This is before the user has joined the channel, so check usercount + 1 */ - if (c->users.size() + 1 >= Config->GetModule(this)->Get("minusers") && !c->FindUser(c->ci->GetBot())) - { - ChannelStatus status(Config->GetModule(this)->Get("botmodes")); - c->ci->GetBot()->Join(c, &status); - } - } - } - - void OnLeaveChannel(User *u, Channel *c) override - { - /* Channel is persistent, it shouldn't be deleted and the service bot should stay */ - if (c->ci && persist && persist->HasExt(c->ci)) - return; - - /* Channel is syncing from a netburst, don't destroy it as more users are probably wanting to join immediately - * We also don't part the bot here either, if necessary we will part it after the sync - */ - if (c->syncing) - return; - - /* Additionally, do not delete this channel if ChanServ/a BotServ bot is inhabiting it */ - if (inhabit && inhabit->HasExt(c)) - return; - - /* This is called prior to removing the user from the channnel, so c->users.size() - 1 should be safe */ - if (c->ci && c->ci->GetBot() && u != c->ci->GetBot() && c->users.size() - 1 <= Config->GetModule(this)->Get("minusers") && c->FindUser(c->ci->GetBot())) - c->ci->GetBot()->Part(c->ci->c); - } - - EventReturn OnPreHelp(CommandSource &source, const std::vector ¶ms) override - { - if (!params.empty()) - return EVENT_CONTINUE; - - if (source.c) - { - source.Reply(_("\002%s\002 allows you to execute \"fantasy\" commands in the channel.\n" - "Fantasy commands are commands that can be executed from messaging a\n" - "channel, and provide a more convenient way to execute commands. Commands that\n" - "require a channel as a parameter will automatically have that parameter\n" - "given.\n"), source.service->nick.c_str()); - const Anope::string &fantasycharacters = Config->GetModule("fantasy")->Get("fantasycharacter", "!"); - if (!fantasycharacters.empty()) - source.Reply(_(" \n" - "Fantasy commands may be prefixed with one of the following characters: %s\n"), fantasycharacters.c_str()); - source.Reply(_(" \n" - "Available commands are:")); - } - else if (*source.service == BotServ) - { - source.Reply(_("\002%s\002 allows you to have a bot on your own channel.\n" - "It has been created for users that can't host or\n" - "configure a bot, or for use on networks that don't\n" - "allow user bots. Available commands are listed\n" - "below; to use them, type \002%s%s \037command\037\002. For\n" - "more information on a specific command, type\n" - "\002%s%s %s \037command\037\002.\n"), - BotServ->nick.c_str(), Config->StrictPrivmsg.c_str(), BotServ->nick.c_str(), - Config->StrictPrivmsg.c_str(), BotServ->nick.c_str(), source.command.c_str()); - } - - return EVENT_CONTINUE; - } - - void OnPostHelp(CommandSource &source, const std::vector ¶ms) override - { - if (!params.empty() || source.c || source.service != *BotServ) - return; - - source.Reply(_(" \n" - "Bot will join a channel whenever there is at least\n" - "\002%d\002 user(s) on it."), Config->GetModule(this)->Get("minusers")); - const Anope::string &fantasycharacters = Config->GetModule("fantasy")->Get("fantasycharacter", "!"); - if (!fantasycharacters.empty()) - source.Reply(_("Additionally, if fantasy is enabled fantasy commands\n" - "can be executed by prefixing the command name with\n" - "one of the following characters: %s"), fantasycharacters.c_str()); - } - - EventReturn OnChannelModeSet(Channel *c, const MessageSource &source, ChannelMode *mode, const Anope::string ¶m) override - { - if (source.GetUser() && !source.GetBot() && Config->GetModule(this)->Get("smartjoin") && mode->name == "BAN" && c->ci && c->ci->GetBot() && c->FindUser(c->ci->GetBot())) - { - ServiceBot *bi = c->ci->GetBot(); - - Entry ban("BAN", param); - if (ban.Matches(bi)) - c->RemoveMode(bi, "BAN", param); - } - - return EVENT_CONTINUE; - } - - void OnCreateChan(ChanServ::Channel *ci) override - { - /* Set default bot flags */ - spacesepstream sep(Config->GetModule(this)->Get("defaults", "greet fantasy")); - for (Anope::string token; sep.GetToken(token);) - ci->SetS("BS_" + token.upper(), true); - } - - void OnUserKicked(const MessageSource &source, User *target, const Anope::string &channel, ChannelStatus &status, const Anope::string &kickmsg) override - { - ServiceBot *bi = ServiceBot::Find(target->GetUID()); - if (bi) - /* Bots get rejoined */ - bi->Join(channel, &status); - } - - void OnCreateBot(ServiceBot *bi) override - { - if (bi->botmodes.empty()) - bi->botmodes = Config->GetModule(this)->Get("botumodes"); - } -}; - -MODULE_INIT(BotServCore) - diff --git a/modules/pseudoclients/chanserv/CMakeLists.txt b/modules/pseudoclients/chanserv/CMakeLists.txt deleted file mode 100644 index 781f0ef1f..000000000 --- a/modules/pseudoclients/chanserv/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -build_subdir(${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/modules/pseudoclients/chanserv/chanaccess.cpp b/modules/pseudoclients/chanserv/chanaccess.cpp deleted file mode 100644 index 1601260c2..000000000 --- a/modules/pseudoclients/chanserv/chanaccess.cpp +++ /dev/null @@ -1,127 +0,0 @@ -#include "module.h" -#include "chanaccess.h" -#include "chanaccesstype.h" - -ChanServ::Channel *ChanAccessImpl::GetChannel() -{ - return Get(&ChanAccessType::ci); -} - -void ChanAccessImpl::SetChannel(ChanServ::Channel *ci) -{ - Object::Set(&ChanAccessType::ci, ci); -} - -Anope::string ChanAccessImpl::GetCreator() -{ - return Get(&ChanAccessType::creator); -} - -void ChanAccessImpl::SetCreator(const Anope::string &c) -{ - Object::Set(&ChanAccessType::creator, c); -} - -time_t ChanAccessImpl::GetLastSeen() -{ - return Get(&ChanAccessType::last_seen); -} - -void ChanAccessImpl::SetLastSeen(const time_t &t) -{ - Object::Set(&ChanAccessType::last_seen, t); -} - -time_t ChanAccessImpl::GetCreated() -{ - return Get(&ChanAccessType::created); -} - -void ChanAccessImpl::SetCreated(const time_t &t) -{ - Object::Set(&ChanAccessType::created, t); -} - -Anope::string ChanAccessImpl::GetMask() -{ - return Get(&ChanAccessType::mask); -} - -void ChanAccessImpl::SetMask(const Anope::string &n) -{ - Object::Set(&ChanAccessType::mask, n); -} - -Serialize::Object *ChanAccessImpl::GetObj() -{ - return Get(&ChanAccessType::obj); -} - -void ChanAccessImpl::SetObj(Serialize::Object *o) -{ - Object::Set(&ChanAccessType::obj, o); -} - -Anope::string ChanAccessImpl::Mask() -{ - if (NickServ::Account *acc = GetAccount()) - return acc->GetDisplay(); - - return GetMask(); -} - -NickServ::Account *ChanAccessImpl::GetAccount() -{ - if (!GetObj() || GetObj()->GetSerializableType() != NickServ::account) - return nullptr; - - return anope_dynamic_static_cast(GetObj()); -} - -bool ChanAccessImpl::Matches(const User *u, NickServ::Account *acc, Path &p) -{ - if (this->GetAccount()) - return this->GetAccount() == acc; - - if (u) - { - bool is_mask = this->Mask().find_first_of("!@?*") != Anope::string::npos; - if (is_mask && Anope::Match(u->nick, this->Mask())) - return true; - else if (Anope::Match(u->GetDisplayedMask(), this->Mask())) - return true; - } - - if (acc) - for (NickServ::Nick *na : acc->GetRefs(NickServ::nick)) - if (Anope::Match(na->GetNick(), this->Mask())) - return true; - - if (IRCD->IsChannelValid(this->Mask())) - { - ChanServ::Channel *tci = ChanServ::Find(this->Mask()); - if (tci) - { - for (unsigned i = 0; i < tci->GetAccessCount(); ++i) - { - ChanServ::ChanAccess *a = tci->GetAccess(i); - std::pair pair = std::make_pair(this, a); - - std::pair range = p.first.equal_range(this); - for (; range.first != range.second; ++range.first) - if (range.first->first == pair.first && range.first->second == pair.second) - goto cont; - - p.first.insert(pair); - if (a->Matches(u, acc, p)) - p.second.insert(pair); - - cont:; - } - - return p.second.count(this) > 0; - } - } - - return false; -} diff --git a/modules/pseudoclients/chanserv/chanaccess.h b/modules/pseudoclients/chanserv/chanaccess.h deleted file mode 100644 index bb65f79c5..000000000 --- a/modules/pseudoclients/chanserv/chanaccess.h +++ /dev/null @@ -1,30 +0,0 @@ - -class ChanAccessImpl : public ChanServ::ChanAccess -{ - public: - ChanAccessImpl(Serialize::TypeBase *type) : ChanServ::ChanAccess(type) { } - ChanAccessImpl(Serialize::TypeBase *type, Serialize::ID id) : ChanServ::ChanAccess(type, id) { } - - ChanServ::Channel *GetChannel() override; - void SetChannel(ChanServ::Channel *ci) override; - - Anope::string GetCreator() override; - void SetCreator(const Anope::string &c) override; - - time_t GetLastSeen() override; - void SetLastSeen(const time_t &t) override; - - time_t GetCreated() override; - void SetCreated(const time_t &t) override; - - Anope::string GetMask() override; - void SetMask(const Anope::string &) override; - - Serialize::Object *GetObj() override; - void SetObj(Serialize::Object *) override; - - Anope::string Mask() override; - NickServ::Account *GetAccount() override; - - bool Matches(const User *u, NickServ::Account *acc, Path &p) override; -}; diff --git a/modules/pseudoclients/chanserv/chanaccesstype.h b/modules/pseudoclients/chanserv/chanaccesstype.h deleted file mode 100644 index ca8dc1b79..000000000 --- a/modules/pseudoclients/chanserv/chanaccesstype.h +++ /dev/null @@ -1,21 +0,0 @@ - -class ChanAccessType : public Serialize::AbstractType -{ - public: - Serialize::ObjectField ci; - Serialize::Field mask; - Serialize::ObjectField obj; - Serialize::Field creator; - Serialize::Field last_seen; - Serialize::Field created; - - ChanAccessType(Module *me, const Anope::string &name) : Serialize::AbstractType(me, name) - , ci(this, "ci", true) - , mask(this, "mask") - , obj(this, "obj", true) - , creator(this, "creator") - , last_seen(this, "last_seen") - , created(this, "created") - { - } -}; diff --git a/modules/pseudoclients/chanserv/channel.cpp b/modules/pseudoclients/chanserv/channel.cpp deleted file mode 100644 index b24edcc0c..000000000 --- a/modules/pseudoclients/chanserv/channel.cpp +++ /dev/null @@ -1,429 +0,0 @@ -/* Registered channel functions - * - * (C) 2003-2014 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" -#include "channeltype.h" -#include "modules/cs_akick.h" - -ChannelImpl::ChannelImpl(Serialize::TypeBase *type, const Anope::string &chname) : ChanServ::Channel(type) -{ - SetName(chname); - SetTimeRegistered(Anope::CurTime); - SetLastUsed(Anope::CurTime); -} - -ChannelImpl::~ChannelImpl() -{ - ChanServ::registered_channel_map& map = ChanServ::service->GetChannels(); - map.erase(this->GetName()); -} - -void ChannelImpl::Delete() -{ - Event::OnDelChan(&Event::DelChan::OnDelChan, this); - - Log(LOG_DEBUG) << "Deleting channel " << this->GetName(); - - if (this->c) - { - if (this->GetBot() && this->c->FindUser(this->GetBot())) - this->GetBot()->Part(this->c); - - /* Parting the service bot can cause the channel to go away */ - - if (this->c) - { - if (this->c && this->c->CheckDelete()) - delete this->c; - - this->c = NULL; - } - } - - return Serialize::Object::Delete(); -} - -Anope::string ChannelImpl::GetName() -{ - return Get(&ChannelType::name); -} - -void ChannelImpl::SetName(const Anope::string &name) -{ - Set(&ChannelType::name, name); -} - -Anope::string ChannelImpl::GetDesc() -{ - return Get(&ChannelType::desc); -} - -void ChannelImpl::SetDesc(const Anope::string &desc) -{ - Set(&ChannelType::desc, desc); -} - -time_t ChannelImpl::GetTimeRegistered() -{ - return Get(&ChannelType::time_registered); -} - -void ChannelImpl::SetTimeRegistered(const time_t &t) -{ - Set(&ChannelType::time_registered, t); -} - -time_t ChannelImpl::GetLastUsed() -{ - return Get(&ChannelType::last_used); -} - -void ChannelImpl::SetLastUsed(const time_t &t) -{ - Set(&ChannelType::last_used, t); -} - -Anope::string ChannelImpl::GetLastTopic() -{ - return Get(&ChannelType::last_topic); -} - -void ChannelImpl::SetLastTopic(const Anope::string &topic) -{ - Set(&ChannelType::last_topic, topic); -} - -Anope::string ChannelImpl::GetLastTopicSetter() -{ - return Get(&ChannelType::last_topic_setter); -} - -void ChannelImpl::SetLastTopicSetter(const Anope::string &setter) -{ - Set(&ChannelType::last_topic_setter, setter); -} - -time_t ChannelImpl::GetLastTopicTime() -{ - return Get(&ChannelType::last_topic_time); -} - -void ChannelImpl::SetLastTopicTime(const time_t &t) -{ - Set(&ChannelType::last_topic_time, t); -} - -int16_t ChannelImpl::GetBanType() -{ - return Get(&ChannelType::bantype); -} - -void ChannelImpl::SetBanType(const int16_t &i) -{ - Set(&ChannelType::bantype, i); -} - -time_t ChannelImpl::GetBanExpire() -{ - return Get(&ChannelType::banexpire); -} - -void ChannelImpl::SetBanExpire(const time_t &t) -{ - Set(&ChannelType::banexpire, t); -} - -BotInfo *ChannelImpl::GetBI() -{ - return Get(&ChannelType::bi); -} - -void ChannelImpl::SetBI(BotInfo *bi) -{ - Set(&ChannelType::bi, bi); -} - -ServiceBot *ChannelImpl::GetBot() -{ - BotInfo *bi = GetBI(); - return bi ? bi->bot : nullptr; -} - -void ChannelImpl::SetBot(ServiceBot *bi) -{ - SetBI(bi->bi); -} - -MemoServ::MemoInfo *ChannelImpl::GetMemos() -{ - return GetRef(MemoServ::memoinfo); -} - -void ChannelImpl::SetFounder(NickServ::Account *nc) -{ - Set(&ChannelType::founder, nc); -} - -NickServ::Account *ChannelImpl::GetFounder() -{ - return Get(&ChannelType::founder); -} - -void ChannelImpl::SetSuccessor(NickServ::Account *nc) -{ - Set(&ChannelType::successor, nc); -} - -NickServ::Account *ChannelImpl::GetSuccessor() -{ - return Get(&ChannelType::successor); -} - -ChanServ::ChanAccess *ChannelImpl::GetAccess(unsigned index) -{ - std::vector a = GetRefs(ChanServ::chanaccess); - return a.size() > index ? a[index] : nullptr; -} - -ChanServ::AccessGroup ChannelImpl::AccessFor(const User *u, bool updateLastUsed) -{ - ChanServ::AccessGroup group; - - if (u == NULL) - return group; - - const NickServ::Account *nc = u->Account(); - if (nc == NULL && !this->HasFieldS("NS_SECURE") && u->IsRecognized()) - { - NickServ::Nick *na = NickServ::FindNick(u->nick); - if (na != NULL) - nc = na->GetAccount(); - } - - group.super_admin = u->super_admin; - group.founder = IsFounder(u); - group.ci = this; - group.nc = nc; - - for (unsigned i = 0, end = this->GetAccessCount(); i < end; ++i) - { - ChanServ::ChanAccess *a = this->GetAccess(i); - if (a->Matches(u, u->Account(), group.path)) - group.push_back(a); - } - - if (group.founder || !group.empty()) - { - if (updateLastUsed) - this->SetLastUsed(Anope::CurTime); - - for (unsigned i = 0; i < group.size(); ++i) - group[i]->SetLastSeen(Anope::CurTime); - } - - return group; -} - -ChanServ::AccessGroup ChannelImpl::AccessFor(NickServ::Account *nc, bool updateLastUsed) -{ - ChanServ::AccessGroup group; - - group.founder = GetFounder() && GetFounder() == nc; - group.ci = this; - group.nc = nc; - - for (unsigned i = 0, end = this->GetAccessCount(); i < end; ++i) - { - ChanServ::ChanAccess *a = this->GetAccess(i); - if (a->Matches(NULL, nc, group.path)) - group.push_back(a); - } - - if (group.founder || !group.empty()) - if (updateLastUsed) - this->SetLastUsed(Anope::CurTime); - - /* don't update access last seen here, this isn't the user requesting access */ - - return group; -} - -unsigned ChannelImpl::GetAccessCount() -{ - return GetRefs(ChanServ::chanaccess).size(); -} - -unsigned ChannelImpl::GetDeepAccessCount() const -{ - return 0; -#if 0 - ChanServ::ChanAccess::Path path; - for (unsigned i = 0, end = this->GetAccessCount(); i < end; ++i) - { - ChanServ::ChanAccess *a = this->GetAccess(i); - a->Matches(NULL, NULL, path); - } - - unsigned count = this->GetAccessCount(); - std::set channels; - channels.insert(this); - for (ChanServ::ChanAccess::Set::iterator it = path.first.begin(); it != path.first.end(); ++it) - { - const ChanServ::Channel *ci = it->first->GetChannel(); - if (!channels.count(ci)) - { - channels.count(ci); - count += ci->GetAccessCount(); - } - } - return count; -#endif -} - -void ChannelImpl::ClearAccess() -{ - for (ChanServ::ChanAccess *a : GetRefs(ChanServ::chanaccess)) - a->Delete(); -} - -AutoKick *ChannelImpl::AddAkick(const Anope::string &user, NickServ::Account *akicknc, const Anope::string &reason, time_t t, time_t lu) -{ - AutoKick *ak = ::autokick.Create(); - ak->SetChannel(this); - ak->SetAccount(akicknc); - ak->SetReason(reason); - ak->SetCreator(user); - ak->SetAddTime(t); - ak->SetLastUsed(lu); - - return ak; -} - -AutoKick *ChannelImpl::AddAkick(const Anope::string &user, const Anope::string &mask, const Anope::string &reason, time_t t, time_t lu) -{ - AutoKick *ak = ::autokick.Create(); - ak->SetChannel(this); - ak->SetMask(mask); - ak->SetReason(reason); - ak->SetCreator(user); - ak->SetAddTime(t); - ak->SetLastUsed(lu); - - return ak; -} - -AutoKick *ChannelImpl::GetAkick(unsigned index) -{ - std::vector a = GetRefs(autokick); - return a.size() > index ? a[index] : nullptr; -} - -unsigned ChannelImpl::GetAkickCount() -{ - std::vector t = GetRefs(autokick); - return t.size(); -} - -void ChannelImpl::ClearAkick() -{ - for (AutoKick *ak : GetRefs(autokick)) - ak->Delete(); -} - -int16_t ChannelImpl::GetLevel(const Anope::string &priv) -{ - for (ChanServ::Level *l : this->GetRefs(ChanServ::level)) - if (l->GetName() == priv) - return l->GetLevel(); - - ChanServ::Privilege *p = ChanServ::service ? ChanServ::service->FindPrivilege(priv) : nullptr; - if (!p) - { - Log(LOG_DEBUG) << "Unknown privilege " + priv; - return ChanServ::ACCESS_INVALID; - } - - return p->level; -} - -void ChannelImpl::SetLevel(const Anope::string &priv, int16_t level) -{ - for (ChanServ::Level *l : this->GetRefs(ChanServ::level)) - if (l->GetName() == priv) - { - l->SetLevel(level); - return; - } - - ChanServ::Privilege *p = ChanServ::service ? ChanServ::service->FindPrivilege(priv) : nullptr; - if (!p) - { - Log(LOG_DEBUG) << "Unknown privilege " + priv; - return; - } - - ChanServ::Level *l = ChanServ::level.Create(); - l->SetChannel(this); - l->SetName(priv); - l->SetLevel(level); -} - -void ChannelImpl::RemoveLevel(const Anope::string &priv) -{ - for (ChanServ::Level *l : this->GetRefs(ChanServ::level)) - if (l->GetName() == priv) - { - l->Delete(); - return; - } -} - -void ChannelImpl::ClearLevels() -{ - for (ChanServ::Level *l : this->GetRefs(ChanServ::level)) - l->Delete(); -} - -Anope::string ChannelImpl::GetIdealBan(User *u) -{ - int bt = this->GetBanType(); - switch (bt) - { - case 0: - return "*!" + u->GetVIdent() + "@" + u->GetDisplayedHost(); - case 1: - if (u->GetVIdent()[0] == '~') - return "*!*" + u->GetVIdent() + "@" + u->GetDisplayedHost(); - else - return "*!" + u->GetVIdent() + "@" + u->GetDisplayedHost(); - case 3: - return "*!" + u->Mask(); - case 2: - default: - return "*!*@" + u->GetDisplayedHost(); - } -} - -bool ChannelImpl::IsFounder(const User *user) -{ - if (!user) - return false; - - if (user->super_admin) - return true; - - if (user->Account() && user->Account() == this->GetFounder()) - return true; - - return false; -} - diff --git a/modules/pseudoclients/chanserv/channel.h b/modules/pseudoclients/chanserv/channel.h deleted file mode 100644 index 86e42a8f9..000000000 --- a/modules/pseudoclients/chanserv/channel.h +++ /dev/null @@ -1,68 +0,0 @@ - - -class ChannelImpl : public ChanServ::Channel -{ - public: - ChannelImpl(Serialize::TypeBase *type) : ChanServ::Channel(type) { } - ChannelImpl(Serialize::TypeBase *type, Serialize::ID id) : ChanServ::Channel(type, id) { } - ChannelImpl(Serialize::TypeBase *type, const Anope::string &chname); - ~ChannelImpl(); - void Delete() override; - - Anope::string GetName() override; - void SetName(const Anope::string &) override; - - Anope::string GetDesc() override; - void SetDesc(const Anope::string &) override; - - time_t GetTimeRegistered() override; - void SetTimeRegistered(const time_t &) override; - - time_t GetLastUsed() override; - void SetLastUsed(const time_t &) override; - - Anope::string GetLastTopic() override; - void SetLastTopic(const Anope::string &) override; - - Anope::string GetLastTopicSetter() override; - void SetLastTopicSetter(const Anope::string &) override; - - time_t GetLastTopicTime() override; - void SetLastTopicTime(const time_t &) override; - - int16_t GetBanType() override; - void SetBanType(const int16_t &) override; - - time_t GetBanExpire() override; - void SetBanExpire(const time_t &) override; - - BotInfo *GetBI() override; - void SetBI(BotInfo *) override; - - ServiceBot *GetBot() override; - void SetBot(ServiceBot *) override; - - MemoServ::MemoInfo *GetMemos() override; - - bool IsFounder(const User *user) override; - void SetFounder(NickServ::Account *nc) override; - NickServ::Account *GetFounder() override; - void SetSuccessor(NickServ::Account *nc) override; - NickServ::Account *GetSuccessor() override; - ChanServ::ChanAccess *GetAccess(unsigned index) /*const*/ override; - ChanServ::AccessGroup AccessFor(const User *u, bool = true) override; - ChanServ::AccessGroup AccessFor(NickServ::Account *nc, bool = true) override; - unsigned GetAccessCount()/* const*/ override; - unsigned GetDeepAccessCount() const override; - void ClearAccess() override; - AutoKick* AddAkick(const Anope::string &user, NickServ::Account *akicknc, const Anope::string &reason, time_t t = Anope::CurTime, time_t lu = 0) override; - AutoKick* AddAkick(const Anope::string &user, const Anope::string &mask, const Anope::string &reason, time_t t = Anope::CurTime, time_t lu = 0) override; - AutoKick* GetAkick(unsigned index) override; - unsigned GetAkickCount() override; - void ClearAkick() override; - int16_t GetLevel(const Anope::string &priv) override; - void SetLevel(const Anope::string &priv, int16_t level) override; - void RemoveLevel(const Anope::string &priv) override; - void ClearLevels() override; - Anope::string GetIdealBan(User *u) override; -}; diff --git a/modules/pseudoclients/chanserv/channeltype.cpp b/modules/pseudoclients/chanserv/channeltype.cpp deleted file mode 100644 index 4143285a8..000000000 --- a/modules/pseudoclients/chanserv/channeltype.cpp +++ /dev/null @@ -1,45 +0,0 @@ -#include "module.h" -#include "channeltype.h" - -ChannelType::ChannelType(Module *me) : Serialize::Type(me, "ChannelInfo") - , name(this, "name") - , desc(this, "desc") - , time_registered(this, "time_registered") - , last_used(this, "last_used") - , last_topic(this, "last_topic") - , last_topic_setter(this, "last_topic_setter") - , last_topic_time(this, "last_topic_time") - , bantype(this, "bantype") - , banexpire(this, "banexpire") - , founder(this, "founder") - , successor(this, "successor") - , bi(this, "bi") -{ - -} - -void ChannelType::Name::SetField(ChanServ::Channel *c, const Anope::string &value) -{ - ChanServ::registered_channel_map& map = ChanServ::service->GetChannels(); - map.erase(GetField(c)); - - Serialize::Field::SetField(c, value); - - map[value] = c; -} - -ChanServ::Channel *ChannelType::FindChannel(const Anope::string &chan) -{ - Serialize::ID id; - EventReturn result = Event::OnSerialize(&Event::SerializeEvents::OnSerializeFind, this, &this->name, chan, id); - if (result == EVENT_ALLOW) - return RequireID(id); - - // fall back - ChanServ::registered_channel_map& map = ChanServ::service->GetChannels(); - auto it = map.find(chan); - if (it != map.end()) - return it->second; - return nullptr; -} - diff --git a/modules/pseudoclients/chanserv/channeltype.h b/modules/pseudoclients/chanserv/channeltype.h deleted file mode 100644 index 7bc22a8f6..000000000 --- a/modules/pseudoclients/chanserv/channeltype.h +++ /dev/null @@ -1,34 +0,0 @@ -#include "channel.h" - -class ChannelType : public Serialize::Type -{ - public: - /* Channel name */ - struct Name : Serialize::Field - { - using Serialize::Field::Field; - - void SetField(ChanServ::Channel *c, const Anope::string &value) override; - } name; - Serialize::Field desc; - Serialize::Field time_registered; - Serialize::Field last_used; - - Serialize::Field last_topic; - Serialize::Field last_topic_setter; - Serialize::Field last_topic_time; - - Serialize::Field bantype; - Serialize::Field banexpire; - - /* Channel founder */ - Serialize::ObjectField founder; - /* Who gets the channel if the founder nick is dropped or expires */ - Serialize::ObjectField successor; - - Serialize::ObjectField bi; - - ChannelType(Module *); - - ChanServ::Channel *FindChannel(const Anope::string &); -}; diff --git a/modules/pseudoclients/chanserv/chanserv.cpp b/modules/pseudoclients/chanserv/chanserv.cpp deleted file mode 100644 index 420051252..000000000 --- a/modules/pseudoclients/chanserv/chanserv.cpp +++ /dev/null @@ -1,587 +0,0 @@ -/* ChanServ core functions - * - * (C) 2003-2014 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" -#include "modules/cs_mode.h" -#include "modules/help.h" -#include "modules/bs_bot.h" -#include "modules/chanserv.h" -#include "modules/cs_info.h" -#include "modules/cs_akick.h" -#include "channeltype.h" -#include "leveltype.h" -#include "modetype.h" -#include "chanaccesstype.h" -#include "chanaccess.h" - -class ChanServCore : public Module - , public ChanServ::ChanServService - , public EventHook - , public EventHook - , public EventHook - , public EventHook - , public EventHook - , public EventHook - , public EventHook - , public EventHook - , public EventHook - , public EventHook - , public EventHook - , public EventHook - , public EventHook - , public EventHook - , public EventHook - , public EventHook - , public EventHook - , public EventHook - , public EventHook -{ - Reference ChanServ; - std::vector defaults; - ExtensibleItem inhabit; - ExtensibleRef persist;//XXX? - bool always_lower; - EventHandlers OnPreChanExpire; - EventHandlers OnChanExpire; - std::vector Privileges; - ChanServ::registered_channel_map registered_channels; - ChannelType channel_type; - ChanAccessType chanaccess_type; - LevelType level_type; - CSModeType mode_type; - - public: - ChanServCore(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PSEUDOCLIENT | VENDOR) - , ChanServService(this) - , inhabit(this, "inhabit") - , persist("PERSIST") - , always_lower(false) - , OnPreChanExpire(this) - , OnChanExpire(this) - , channel_type(this) - , chanaccess_type(this, "ChanAccess") - , level_type(this) - , mode_type(this) - { - } - - ChanServ::Channel *Find(const Anope::string &name) override - { - return channel_type.FindChannel(name); - } - - ChanServ::registered_channel_map& GetChannels() override - { - return registered_channels; - } - - void Hold(Channel *c) override - { - /** A timer used to keep the BotServ bot/ChanServ in the channel - * after kicking the last user in a channel - */ - class ChanServTimer : public Timer - { - Reference &ChanServ; - ExtensibleItem &inhabit; - Reference c; - - public: - /** Constructor - * @param chan The channel - */ - ChanServTimer(Reference &cs, ExtensibleItem &i, Module *m, Channel *chan) : Timer(m, Config->GetModule(m)->Get("inhabit", "15s")), ChanServ(cs), inhabit(i), c(chan) - { - if (!ChanServ || !c) - return; - inhabit.Set(c, true); - if (!c->ci || !c->ci->GetBot()) - ChanServ->Join(c); - else if (!c->FindUser(c->ci->GetBot())) - c->ci->GetBot()->Join(c); - - /* Set +ntsi to prevent rejoin */ - c->SetMode(NULL, "NOEXTERNAL"); - c->SetMode(NULL, "TOPIC"); - c->SetMode(NULL, "SECRET"); - c->SetMode(NULL, "INVITE"); - } - - /** Called when the delay is up - * @param The current time - */ - void Tick(time_t) override - { - if (!c) - return; - - inhabit.Unset(c); - - /* In the event we don't part */ - c->RemoveMode(NULL, "SECRET"); - c->RemoveMode(NULL, "INVITE"); - - if (!c->ci || !c->ci->GetBot()) - { - if (ChanServ) - ChanServ->Part(c); - } - /* If someone has rejoined this channel in the meantime, don't part the bot */ - else if (c->users.size() <= 1) - c->ci->GetBot()->Part(c); - } - }; - - if (inhabit.HasExt(c)) - return; - - new ChanServTimer(ChanServ, inhabit, this->owner, c); - } - - void AddPrivilege(ChanServ::Privilege p) override - { - unsigned i; - for (i = 0; i < Privileges.size(); ++i) - { - ChanServ::Privilege &priv = Privileges[i]; - - if (priv.rank > p.rank) - break; - } - - Privileges.insert(Privileges.begin() + i, p); - } - - void RemovePrivilege(ChanServ::Privilege &p) override - { - std::vector::iterator it = std::find(Privileges.begin(), Privileges.end(), p); - if (it != Privileges.end()) - Privileges.erase(it); - - for (auto& cit : GetChannels()) - { - ChanServ::Channel *ci = cit.second; - ci->RemoveLevel(p.name); - } - } - - ChanServ::Privilege *FindPrivilege(const Anope::string &name) override - { - for (unsigned i = Privileges.size(); i > 0; --i) - if (Privileges[i - 1].name.equals_ci(name)) - return &Privileges[i - 1]; - return NULL; - } - - std::vector &GetPrivileges() override - { - return Privileges; - } - - void ClearPrivileges() override - { - Privileges.clear(); - } - - void OnReload(Configuration::Conf *conf) override - { - const Anope::string &channick = conf->GetModule(this)->Get("client"); - - if (channick.empty()) - throw ConfigException(Module::name + ": must be defined"); - - ServiceBot *bi = ServiceBot::Find(channick, true); - if (!bi) - throw ConfigException(Module::name + ": no bot named " + channick); - - ChanServ = bi; - - ClearPrivileges(); - for (int i = 0; i < conf->CountBlock("privilege"); ++i) - { - Configuration::Block *privilege = conf->GetBlock("privilege", i); - - const Anope::string &nname = privilege->Get("name"), - &desc = privilege->Get("desc"); - int rank = privilege->Get("rank"); - Anope::string value = privilege->Get("level"); - int level; - if (value.equals_ci("founder")) - level = ChanServ::ACCESS_FOUNDER; - else if (value.equals_ci("disabled")) - level = ChanServ::ACCESS_INVALID; - else - level = privilege->Get("level"); - - AddPrivilege(ChanServ::Privilege(nname, desc, rank, level)); - } - - spacesepstream(conf->GetModule(this)->Get("defaults", "greet fantasy")).GetTokens(defaults); - if (defaults.empty()) - { - defaults.push_back("KEEPTOPIC"); - defaults.push_back("CS_SECURE"); - defaults.push_back("SECUREFOUNDER"); - defaults.push_back("SIGNKICK"); - } - else if (defaults[0].equals_ci("none")) - defaults.clear(); - - always_lower = conf->GetModule(this)->Get("always_lower_ts"); - } - - void OnChannelCreate(Channel *c) override - { - c->ci = Find(c->name); - if (c->ci) - c->ci->c = c; - } - - void OnBotDelete(ServiceBot *bi) override - { - if (bi == ChanServ) - ChanServ = NULL; - } - - EventReturn OnBotPrivmsg(User *u, ServiceBot *bi, Anope::string &message) override - { - if (bi == ChanServ && Config->GetModule(this)->Get("opersonly") && !u->HasMode("OPER")) - { - u->SendMessage(bi, _("Access denied.")); - return EVENT_STOP; - } - - return EVENT_CONTINUE; - } - - void OnDelCore(NickServ::Account *nc) override - { - unsigned int max_reg = Config->GetModule(this)->Get("maxregistered"); - for (ChanServ::Channel *ci : nc->GetRefs(ChanServ::channel)) - { - if (ci->GetFounder() == nc) - { - NickServ::Account *newowner = NULL; - if (ci->GetSuccessor() && ci->GetSuccessor() != nc && (ci->GetSuccessor()->IsServicesOper() || !max_reg || ci->GetSuccessor()->GetChannelCount() < max_reg)) - newowner = ci->GetSuccessor(); - else - { - ChanServ::ChanAccess *highest = NULL; - for (unsigned j = 0; j < ci->GetAccessCount(); ++j) - { - ChanServ::ChanAccess *ca = ci->GetAccess(j); - NickServ::Account *anc = ca->GetAccount(); - - if (!anc || (!anc->IsServicesOper() && max_reg && anc->GetChannelCount() >= max_reg) || (anc == nc)) - continue; - if (!highest || *ca > *highest) - highest = ca; - } - if (highest) - newowner = highest->GetAccount(); - } - - if (newowner) - { - ::Log(LOG_NORMAL, "chanserv/drop", ChanServ) << "Transferring foundership of " << ci->GetName() << " from deleted nick " << nc->GetDisplay() << " to " << newowner->GetDisplay(); - ci->SetFounder(newowner); - ci->SetSuccessor(NULL); - } - else - { - ::Log(LOG_NORMAL, "chanserv/drop", ChanServ) << "Deleting channel " << ci->GetName() << " owned by deleted nick " << nc->GetDisplay(); - - delete ci; - continue; - } - } - - if (ci->GetSuccessor() == nc) - ci->SetSuccessor(NULL); - - /* are these necessary? */ - for (unsigned j = 0; j < ci->GetAccessCount(); ++j) - { - ChanServ::ChanAccess *ca = ci->GetAccess(j); - NickServ::Account *anc = ca->GetAccount(); - - if (anc && anc == nc) - { - delete ca; - break; - } - } - - for (unsigned j = 0; j < ci->GetAkickCount(); ++j) - { - AutoKick *ak = ci->GetAkick(j); - if (ak->GetAccount() == nc) - { - delete ak; - break; - } - } - } - } - - void OnDelChan(ChanServ::Channel *ci) override - { - /* remove access entries that are this channel */ - - for (ChanServ::Channel *c : ci->GetRefs(ChanServ::channel)) - { - for (unsigned j = 0; j < c->GetAccessCount(); ++j) - { - ChanServ::ChanAccess *a = c->GetAccess(j); - - if (a->Mask().equals_ci(ci->GetName())) - { - delete a; - break; - } - } - } - - if (ci->c) - { - ci->c->RemoveMode(ci->WhoSends(), "REGISTERED", "", false); - - const Anope::string &require = Config->GetModule(this)->Get("require"); - if (!require.empty()) - ci->c->SetModes(ci->WhoSends(), false, "-%s", require.c_str()); - } - } - - EventReturn OnPreHelp(CommandSource &source, const std::vector ¶ms) override - { - if (!params.empty() || source.c || source.service != *ChanServ) - return EVENT_CONTINUE; - source.Reply(_("\002%s\002 allows you to register and control various\n" - "aspects of channels. %s can often prevent\n" - "malicious users from \"taking over\" channels by limiting\n" - "who is allowed channel operator privileges. Available\n" - "commands are listed below; to use them, type\n" - "\002%s%s \037command\037\002. For more information on a\n" - "specific command, type \002%s%s HELP \037command\037\002.\n"), - ChanServ->nick.c_str(), ChanServ->nick.c_str(), Config->StrictPrivmsg.c_str(), ChanServ->nick.c_str(), Config->StrictPrivmsg.c_str(), ChanServ->nick.c_str(), ChanServ->nick.c_str(), source.command.c_str()); - return EVENT_CONTINUE; - } - - void OnPostHelp(CommandSource &source, const std::vector ¶ms) override - { - if (!params.empty() || source.c || source.service != *ChanServ) - return; - time_t chanserv_expire = Config->GetModule(this)->Get("expire", "14d"); - if (chanserv_expire >= 86400) - source.Reply(_(" \n" - "Note that any channel which is not used for %d days\n" - "(i.e. which no user on the channel's access list enters\n" - "for that period of time) will be automatically dropped."), chanserv_expire / 86400); - if (source.IsServicesOper()) - source.Reply(_(" \n" - "Services Operators can also, depending on their access drop\n" - "any channel, view (and modify) the access, levels and akick\n" - "lists and settings for any channel.")); - } - - void OnCheckModes(Reference &c) override - { - if (!c) - return; - - if (c->ci) - c->SetMode(c->ci->WhoSends(), "REGISTERED", "", false); - else - c->RemoveMode(c->ci->WhoSends(), "REGISTERED", "", false); - - const Anope::string &require = Config->GetModule(this)->Get("require"); - if (!require.empty()) - { - if (c->ci) - c->SetModes(c->ci->WhoSends(), false, "+%s", require.c_str()); - else - c->SetModes(c->ci->WhoSends(), false, "-%s", require.c_str()); - } - } - - void OnCreateChan(ChanServ::Channel *ci) override - { - /* Set default chan flags */ - for (unsigned i = 0; i < defaults.size(); ++i) - ci->SetS(defaults[i].upper(), true); - } - - EventReturn OnCanSet(User *u, const ChannelMode *cm) override - { - if (Config->GetModule(this)->Get("nomlock").find(cm->mchar) != Anope::string::npos - || Config->GetModule(this)->Get("require").find(cm->mchar) != Anope::string::npos) - return EVENT_STOP; - return EVENT_CONTINUE; - } - - void OnChannelSync(Channel *c) override - { - bool perm = c->HasMode("PERM") || (c->ci && persist && persist->HasExt(c->ci)); - if (!perm && !c->botchannel && (c->users.empty() || (c->users.size() == 1 && c->users.begin()->second->user->server == Me))) - { - this->Hold(c); - } - } - - void OnLog(::Log *l) override - { - if (l->type == LOG_CHANNEL) - l->bi = ChanServ; - } - - void OnExpireTick() override - { - time_t chanserv_expire = Config->GetModule(this)->Get("expire", "14d"); - - if (!chanserv_expire || Anope::NoExpire || Anope::ReadOnly) - return; - - for (ChanServ::Channel *ci : channel_type.List()) - { - bool expire = false; - - if (Anope::CurTime - ci->GetLastUsed() >= chanserv_expire) - { - if (ci->c) - { - time_t last_used = ci->GetLastUsed(); - for (Channel::ChanUserList::const_iterator cit = ci->c->users.begin(), cit_end = ci->c->users.end(); cit != cit_end && last_used == ci->GetLastUsed(); ++cit) - ci->AccessFor(cit->second->user); - expire = last_used == ci->GetLastUsed(); - } - else - expire = true; - } - - this->OnPreChanExpire(&ChanServ::Event::PreChanExpire::OnPreChanExpire, ci, expire); - - if (expire) - { - ::Log(LOG_NORMAL, "chanserv/expire", ChanServ) << "Expiring channel " << ci->GetName() << " (founder: " << (ci->GetFounder() ? ci->GetFounder()->GetDisplay() : "(none)") << ")"; - this->OnChanExpire(&ChanServ::Event::ChanExpire::OnChanExpire, ci); - delete ci; - } - } - } - - EventReturn OnCheckDelete(Channel *c) override - { - /* Do not delete this channel if ChanServ/a BotServ bot is inhabiting it */ - if (inhabit.HasExt(c)) - return EVENT_STOP; - - return EVENT_CONTINUE; - } - - void OnPreUplinkSync(Server *serv) override - { - if (!persist) - return; - /* Find all persistent channels and create them, as we are about to finish burst to our uplink */ - for (ChanServ::Channel *ci : channel_type.List()) - { - if (persist->HasExt(ci)) - { - bool c; - ci->c = Channel::FindOrCreate(ci->GetName(), c, ci->GetTimeRegistered()); - - if (ModeManager::FindChannelModeByName("PERM") != NULL) - { - if (c) - IRCD->SendChannel(ci->c); - ci->c->SetMode(NULL, "PERM"); - } - else - { - if (!ci->GetBot()) - ci->WhoSends()->Assign(NULL, ci); - if (ci->c->FindUser(ci->GetBot()) == NULL) - { - ChannelStatus status(Config->GetModule("botserv")->Get("botmodes")); - ci->GetBot()->Join(ci->c, &status); - } - } - } - } - - } - - void OnChanRegistered(ChanServ::Channel *ci) override - { - if (!persist || !ci->c) - return; - /* Mark the channel as persistent */ - if (ci->c->HasMode("PERM")) - persist->Set(ci, true); - /* Persist may be in def cflags, set it here */ - else if (persist->HasExt(ci)) - ci->c->SetMode(NULL, "PERM"); - } - - void OnJoinChannel(User *u, Channel *c) override - { - if (always_lower && c->ci && c->creation_time > c->ci->GetTimeRegistered()) - { - ::Log(LOG_DEBUG) << "Changing TS of " << c->name << " from " << c->creation_time << " to " << c->ci->GetTimeRegistered(); - c->creation_time = c->ci->GetTimeRegistered(); - IRCD->SendChannel(c); - c->Reset(); - } - } - - EventReturn OnChannelModeSet(Channel *c, const MessageSource &setter, ChannelMode *mode, const Anope::string ¶m) override - { - if (!always_lower && Anope::CurTime == c->creation_time && c->ci && setter.GetUser() && !setter.GetUser()->server->IsULined()) - { - ChanUserContainer *cu = c->FindUser(setter.GetUser()); - ChannelMode *cm = ModeManager::FindChannelModeByName("OP"); - if (cu && cm && !cu->status.HasMode(cm->mchar)) - { - /* Our -o and their mode change crossing, bounce their mode */ - c->RemoveMode(c->ci->WhoSends(), mode, param); - /* We don't set mlocks until after the join has finished processing, it will stack with this change, - * so there isn't much for the user to remove except -nt etc which is likely locked anyway. - */ - } - } - - return EVENT_CONTINUE; - } - - void OnChanInfo(CommandSource &source, ChanServ::Channel *ci, InfoFormatter &info, bool show_all) override - { - if (!show_all) - return; - - time_t chanserv_expire = Config->GetModule(this)->Get("expire", "14d"); - if (!ci->HasFieldS("CS_NO_EXPIRE") && chanserv_expire && !Anope::NoExpire && ci->GetLastUsed() != Anope::CurTime) - info[_("Expires")] = Anope::strftime(ci->GetLastUsed() + chanserv_expire, source.GetAccount()); - } - - void OnSetCorrectModes(User *user, Channel *chan, ChanServ::AccessGroup &access, bool &give_modes, bool &take_modes) override - { - if (always_lower) - // Since we always lower the TS, the other side will remove the modes if the channel ts lowers, so we don't - // have to worry about it - take_modes = false; - else if (ModeManager::FindChannelModeByName("REGISTERED")) - // Otherwise if the registered channel mode exists, we should remove modes if the channel is not +r - take_modes = !chan->HasMode("REGISTERED"); - } -}; - -MODULE_INIT(ChanServCore) - diff --git a/modules/pseudoclients/chanserv/level.cpp b/modules/pseudoclients/chanserv/level.cpp deleted file mode 100644 index d31c98d64..000000000 --- a/modules/pseudoclients/chanserv/level.cpp +++ /dev/null @@ -1,33 +0,0 @@ -#include "modules/chanserv.h" -#include "leveltype.h" - -ChanServ::Channel *LevelImpl::GetChannel() -{ - return Get(&LevelType::channel); -} - -void LevelImpl::SetChannel(ChanServ::Channel *c) -{ - Set(&LevelType::channel, c); -} - -Anope::string LevelImpl::GetName() -{ - return Get(&LevelType::name); -} - -void LevelImpl::SetName(const Anope::string &n) -{ - Set(&LevelType::name, n); -} - -int LevelImpl::GetLevel() -{ - return Get(&LevelType::level); -} - -void LevelImpl::SetLevel(const int &i) -{ - Set(&LevelType::level, i); -} - diff --git a/modules/pseudoclients/chanserv/level.h b/modules/pseudoclients/chanserv/level.h deleted file mode 100644 index c9ffd0dfb..000000000 --- a/modules/pseudoclients/chanserv/level.h +++ /dev/null @@ -1,16 +0,0 @@ - -class LevelImpl : public ChanServ::Level -{ - public: - LevelImpl(Serialize::TypeBase *type) : ChanServ::Level(type) { } - LevelImpl(Serialize::TypeBase *type, Serialize::ID id) : ChanServ::Level(type, id) { } - - ChanServ::Channel *GetChannel(); - void SetChannel(ChanServ::Channel *); - - Anope::string GetName(); - void SetName(const Anope::string &); - - int GetLevel(); - void SetLevel(const int &); -}; diff --git a/modules/pseudoclients/chanserv/leveltype.h b/modules/pseudoclients/chanserv/leveltype.h deleted file mode 100644 index 12e4c132f..000000000 --- a/modules/pseudoclients/chanserv/leveltype.h +++ /dev/null @@ -1,16 +0,0 @@ -#include "level.h" - -class LevelType : public Serialize::Type -{ - public: - Serialize::ObjectField channel; - Serialize::Field name; - Serialize::Field level; - - LevelType(Module *creator) : Serialize::Type(creator, "Level") - , channel(this, "channel", true) - , name(this, "name") - , level(this, "level") - { - } -}; diff --git a/modules/pseudoclients/chanserv/mode.cpp b/modules/pseudoclients/chanserv/mode.cpp deleted file mode 100644 index 066e2cfd5..000000000 --- a/modules/pseudoclients/chanserv/mode.cpp +++ /dev/null @@ -1,33 +0,0 @@ -#include "modules/chanserv.h" -#include "modetype.h" - -ChanServ::Channel *ModeImpl::GetChannel() -{ - return Get(&CSModeType::channel); -} - -void ModeImpl::SetChannel(ChanServ::Channel *c) -{ - Set(&CSModeType::channel, c); -} - -Anope::string ModeImpl::GetMode() -{ - return Get(&CSModeType::mode); -} - -void ModeImpl::SetMode(const Anope::string &m) -{ - Set(&CSModeType::mode, m); -} - -Anope::string ModeImpl::GetParam() -{ - return Get(&CSModeType::param); -} - -void ModeImpl::SetParam(const Anope::string &p) -{ - Set(&CSModeType::param, p); -} - diff --git a/modules/pseudoclients/chanserv/mode.h b/modules/pseudoclients/chanserv/mode.h deleted file mode 100644 index cd94e5ad1..000000000 --- a/modules/pseudoclients/chanserv/mode.h +++ /dev/null @@ -1,17 +0,0 @@ - -class ModeImpl : public ChanServ::Mode -{ - public: - ModeImpl(Serialize::TypeBase *type) : ChanServ::Mode(type) { } - ModeImpl(Serialize::TypeBase *type, Serialize::ID id) : ChanServ::Mode(type, id) { } - - ChanServ::Channel *GetChannel() override; - void SetChannel(ChanServ::Channel *) override; - - Anope::string GetMode() override; - void SetMode(const Anope::string &) override; - - Anope::string GetParam() override; - void SetParam(const Anope::string &) override; -}; - diff --git a/modules/pseudoclients/chanserv/modetype.h b/modules/pseudoclients/chanserv/modetype.h deleted file mode 100644 index b30c0491f..000000000 --- a/modules/pseudoclients/chanserv/modetype.h +++ /dev/null @@ -1,15 +0,0 @@ -#include "mode.h" - -class CSModeType : public Serialize::Type -{ - public: - Serialize::ObjectField channel; - Serialize::Field mode, param; - - CSModeType(Module *creator) : Serialize::Type(creator, "CSKeepMode") - , channel(this, "channel", true) - , mode(this, "mode") - , param(this, "param") - { - } -}; diff --git a/modules/pseudoclients/global.cpp b/modules/pseudoclients/global.cpp deleted file mode 100644 index f31605acb..000000000 --- a/modules/pseudoclients/global.cpp +++ /dev/null @@ -1,107 +0,0 @@ -/* Global core functions - * - * (C) 2003-2014 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" -#include "modules/help.h" -#include "modules/global.h" - -class GlobalCore : public Module - , public Global::GlobalService - , public EventHook - , public EventHook - , public EventHook - , public EventHook -{ - Reference Global; - - void ServerGlobal(ServiceBot *sender, Server *s, const Anope::string &message) - { - if (s != Me && !s->IsJuped()) - s->Notice(sender, message); - for (unsigned i = 0, j = s->GetLinks().size(); i < j; ++i) - this->ServerGlobal(sender, s->GetLinks()[i], message); - } - - public: - GlobalCore(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PSEUDOCLIENT | VENDOR) - , GlobalService(this) - { - } - - void SendGlobal(ServiceBot *sender, const Anope::string &source, const Anope::string &message) override - { - if (Me->GetLinks().empty()) - return; - if (!sender) - sender = Global; - if (!sender) - return; - - Anope::string rmessage; - - if (!source.empty() && !Config->GetModule("global")->Get("anonymousglobal")) - rmessage = "[" + source + "] " + message; - else - rmessage = message; - - this->ServerGlobal(sender, Servers::GetUplink(), rmessage); - } - - void OnReload(Configuration::Conf *conf) override - { - const Anope::string &glnick = conf->GetModule(this)->Get("client"); - - if (glnick.empty()) - throw ConfigException(Module::name + ": must be defined"); - - ServiceBot *bi = ServiceBot::Find(glnick, true); - if (!bi) - throw ConfigException(Module::name + ": no bot named " + glnick); - - Global = bi; - } - - void OnRestart() override - { - const Anope::string &gl = Config->GetModule(this)->Get("globaloncycledown"); - if (!gl.empty()) - this->SendGlobal(Global, "", gl); - } - - void OnShutdown() override - { - const Anope::string &gl = Config->GetModule(this)->Get("globaloncycledown"); - if (!gl.empty()) - this->SendGlobal(Global, "", gl); - } - - void OnNewServer(Server *s) override - { - const Anope::string &gl = Config->GetModule(this)->Get("globaloncycleup"); - if (!gl.empty() && !Me->IsSynced()) - s->Notice(Global, gl); - } - - EventReturn OnPreHelp(CommandSource &source, const std::vector ¶ms) override - { - if (!params.empty() || source.c || source.service != *Global) - return EVENT_CONTINUE; - source.Reply(_("%s commands:"), Global->nick.c_str()); - return EVENT_CONTINUE; - } - - void OnPostHelp(CommandSource &source, const std::vector ¶ms) override - { - } -}; - -MODULE_INIT(GlobalCore) - diff --git a/modules/pseudoclients/hostserv.cpp b/modules/pseudoclients/hostserv.cpp deleted file mode 100644 index 285ea893b..000000000 --- a/modules/pseudoclients/hostserv.cpp +++ /dev/null @@ -1,135 +0,0 @@ -/* HostServ core functions - * - * (C) 2003-2014 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" -#include "modules/ns_update.h" -#include "modules/hs_del.h" -#include "modules/help.h" - -class HostServCore : public Module - , public EventHook - , public EventHook - , public EventHook - , public EventHook - , public EventHook -{ - Reference HostServ; - - public: - HostServCore(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PSEUDOCLIENT | VENDOR) - { - if (!IRCD || !IRCD->CanSetVHost) - throw ModuleException("Your IRCd does not support vhosts"); - } - - void OnReload(Configuration::Conf *conf) override - { - const Anope::string &hsnick = conf->GetModule(this)->Get("client"); - - if (hsnick.empty()) - throw ConfigException(Module::name + ": must be defined"); - - ServiceBot *bi = ServiceBot::Find(hsnick, true); - if (!bi) - throw ConfigException(Module::name + ": no bot named " + hsnick); - - HostServ = bi; - } - - void OnUserLogin(User *u) override - { - if (!IRCD->CanSetVHost) - return; - - NickServ::Nick *na = NickServ::FindNick(u->nick); - if (!na || na->GetAccount() != u->Account() || !na->HasVhost()) - na = NickServ::FindNick(u->Account()->GetDisplay()); - if (!na || !na->HasVhost()) - return; - - if (u->vhost.empty() || !u->vhost.equals_cs(na->GetVhostHost()) || (!na->GetVhostIdent().empty() && !u->GetVIdent().equals_cs(na->GetVhostIdent()))) - { - IRCD->SendVhost(u, na->GetVhostIdent(), na->GetVhostHost()); - - u->vhost = na->GetVhostHost(); - u->UpdateHost(); - - if (IRCD->CanSetVIdent && !na->GetVhostIdent().empty()) - u->SetVIdent(na->GetVhostIdent()); - - if (HostServ) - { - if (!na->GetVhostIdent().empty()) - u->SendMessage(*HostServ, _("Your vhost of \002%s\002@\002%s\002 is now activated."), na->GetVhostIdent().c_str(), na->GetVhostHost().c_str()); - else - u->SendMessage(*HostServ, _("Your vhost of \002%s\002 is now activated."), na->GetVhostHost().c_str()); - } - } - } - - void OnNickUpdate(User *u) override - { - this->OnUserLogin(u); - } - - EventReturn OnPreHelp(CommandSource &source, const std::vector ¶ms) override - { - if (!params.empty() || source.c || source.service != *HostServ) - return EVENT_CONTINUE; - source.Reply(_("%s commands:"), HostServ->nick.c_str()); - return EVENT_CONTINUE; - } - - void OnPostHelp(CommandSource &source, const std::vector ¶ms) override - { - } - - void OnSetVhost(NickServ::Nick *na) override - { - if (Config->GetModule(this)->Get("activate_on_set")) - { - User *u = User::Find(na->GetNick()); - - if (u && u->Account() == na->GetAccount()) - { - IRCD->SendVhost(u, na->GetVhostIdent(), na->GetVhostHost()); - - u->vhost = na->GetVhostHost(); - u->UpdateHost(); - - if (IRCD->CanSetVIdent && !na->GetVhostIdent().empty()) - u->SetVIdent(na->GetVhostIden