diff options
| author | Adam <Adam@anope.org> | 2015-12-14 16:52:24 -0500 |
|---|---|---|
| committer | Adam <Adam@anope.org> | 2015-12-14 16:52:24 -0500 |
| commit | 6302f980fe6dad83aab7d2dc1046dadea5ffd939 (patch) | |
| tree | 4c27d33f55fc32ce34827977932dac4b3e5ceedd /modules/pseudoclients | |
| parent | 64dac60071fab652745a6e7a06cf6b7bdbbd3625 (diff) | |
New source tree structure for modules. From commands/cs_access => chanserv/access etc.
Diffstat (limited to 'modules/pseudoclients')
49 files changed, 0 insertions, 4221 deletions
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<Event::SetCorrectModes> - , public EventHook<Event::BotAssign> - , public EventHook<Event::JoinChannel> - , public EventHook<Event::LeaveChannel> - , public EventHook<Event::Help> - , public EventHook<Event::ChannelModeSet> - , public EventHook<Event::CreateChan> - , public EventHook<Event::UserKicked> - , public EventHook<Event::CreateBot> -{ - Reference<ServiceBot> BotServ; - ExtensibleRef<bool> 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<Anope::string>("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<Anope::string>("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<unsigned>("minusers")) - { - ChannelStatus status(Config->GetModule(this)->Get<Anope::string>("botmodes")); - bi->Join(ci->c, &status); - } - } - - void OnJoinChannel(User *user, Channel *c) override - { - if (!Config || !IRCD) - return; - - ServiceBot *bi = user->server == Me ? dynamic_cast<ServiceBot *>(user) : NULL; - if (bi && Config->GetModule(this)->Get<bool>("smartjoin")) - { - std::vector<Anope::string> 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<unsigned>(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<ChannelModeStatus *>(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<unsigned>("minusers") && !c->FindUser(c->ci->GetBot())) - { - ChannelStatus status(Config->GetModule(this)->Get<Anope::string>("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<unsigned>("minusers") && c->FindUser(c->ci->GetBot())) - c->ci->GetBot()->Part(c->ci->c); - } - - EventReturn OnPreHelp(CommandSource &source, const std::vector<Anope::string> ¶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<Anope::string>("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<Anope::string> ¶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<unsigned>("minusers")); - const Anope::string &fantasycharacters = Config->GetModule("fantasy")->Get<Anope::string>("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<bool>("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<Anope::string>("defaults", "greet fantasy")); - for (Anope::string token; sep.GetToken(token);) - ci->SetS<bool>("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<Anope::string>("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<NickServ::Account *>(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 *>(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<ChanServ::ChanAccess *, ChanServ::ChanAccess *> pair = std::make_pair(this, a); - - std::pair<Set::iterator, Set::iterator> 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<ChanServ::ChanAccess, ChanServ::Channel *> ci; - Serialize::Field<ChanServ::ChanAccess, Anope::string> mask; - Serialize::ObjectField<ChanServ::ChanAccess, Serialize::Object *> obj; - Serialize::Field<ChanServ::ChanAccess, Anope::string> creator; - Serialize::Field<ChanServ::ChanAccess, time_t> last_seen; - Serialize::Field<ChanServ::ChanAccess, time_t> 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<Anope::string>(&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 *>(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<ChanServ::ChanAccess *> a = GetRefs<ChanServ::ChanAccess *>(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); - } |
