From 26ac315192e0d8a04d50e910697ab794eedf0cc1 Mon Sep 17 00:00:00 2001 From: Adam Date: Sun, 20 Apr 2014 14:35:14 -0400 Subject: New event system --- include/base.h | 67 +- include/defs.h | 2 - include/event.h | 1018 ++++++++++++++++++++++++++++++ include/module.h | 7 +- include/modules.h | 928 +-------------------------- include/modules/bs_badwords.h | 18 + include/modules/bs_bot.h | 34 + include/modules/bs_info.h | 20 + include/modules/bs_kick.h | 14 + include/modules/chanserv.h | 46 ++ include/modules/cs_access.h | 22 + include/modules/cs_akick.h | 28 + include/modules/cs_drop.h | 20 + include/modules/cs_info.h | 23 + include/modules/cs_mode.h | 20 + include/modules/cs_set.h | 25 + include/modules/dns.h | 14 + include/modules/fantasy.h | 35 + include/modules/global.h | 29 + include/modules/help.h | 27 + include/modules/hs_del.h | 18 + include/modules/memoserv.h | 66 ++ include/modules/nickserv.h | 68 ++ include/modules/ns_cert.h | 23 + include/modules/ns_drop.h | 21 + include/modules/ns_group.h | 20 + include/modules/ns_info.h | 22 + include/modules/ns_set.h | 24 + include/modules/ns_update.h | 20 + include/modules/os_defcon.h | 20 + include/modules/os_session.h | 18 + include/modules/pseudoclients/chanserv.h | 18 - include/modules/pseudoclients/global.h | 20 - include/modules/pseudoclients/memoserv.h | 34 - include/modules/pseudoclients/nickserv.h | 17 - include/modules/suspend.h | 40 +- include/serialize.h | 69 +- include/service.h | 128 +--- include/services.h | 2 + modules/bs_autoassign.cpp | 2 + modules/commands/bs_assign.cpp | 13 +- modules/commands/bs_badwords.cpp | 15 +- modules/commands/bs_bot.cpp | 22 +- modules/commands/bs_botlist.cpp | 4 +- modules/commands/bs_control.cpp | 4 +- modules/commands/bs_info.cpp | 15 +- modules/commands/bs_kick.cpp | 45 +- modules/commands/bs_set.cpp | 10 +- modules/commands/cs_access.cpp | 32 +- modules/commands/cs_akick.cpp | 23 +- modules/commands/cs_ban.cpp | 3 +- modules/commands/cs_clone.cpp | 5 +- modules/commands/cs_drop.cpp | 13 +- modules/commands/cs_enforce.cpp | 4 +- modules/commands/cs_entrymsg.cpp | 9 +- modules/commands/cs_flags.cpp | 11 +- modules/commands/cs_getkey.cpp | 3 +- modules/commands/cs_info.cpp | 13 +- modules/commands/cs_invite.cpp | 3 +- modules/commands/cs_kick.cpp | 3 +- modules/commands/cs_list.cpp | 13 +- modules/commands/cs_log.cpp | 19 +- modules/commands/cs_mode.cpp | 27 +- modules/commands/cs_register.cpp | 6 +- modules/commands/cs_seen.cpp | 20 +- modules/commands/cs_set.cpp | 94 ++- modules/commands/cs_set_misc.cpp | 11 +- modules/commands/cs_status.cpp | 3 +- modules/commands/cs_suspend.cpp | 36 +- modules/commands/cs_sync.cpp | 5 +- modules/commands/cs_topic.cpp | 21 +- modules/commands/cs_unban.cpp | 4 +- modules/commands/cs_updown.cpp | 5 +- modules/commands/cs_xop.cpp | 13 +- modules/commands/gl_global.cpp | 20 +- modules/commands/greet.cpp | 23 +- modules/commands/help.cpp | 18 +- modules/commands/hs_del.cpp | 20 +- modules/commands/hs_group.cpp | 11 +- modules/commands/hs_list.cpp | 4 +- modules/commands/hs_off.cpp | 4 +- modules/commands/hs_on.cpp | 4 +- modules/commands/hs_request.cpp | 27 +- modules/commands/hs_set.cpp | 8 +- modules/commands/ms_cancel.cpp | 8 +- modules/commands/ms_check.cpp | 4 +- modules/commands/ms_del.cpp | 14 +- modules/commands/ms_ignore.cpp | 4 +- modules/commands/ms_info.cpp | 4 +- modules/commands/ms_list.cpp | 4 +- modules/commands/ms_read.cpp | 11 +- modules/commands/ms_rsend.cpp | 22 +- modules/commands/ms_send.cpp | 24 +- modules/commands/ms_sendall.cpp | 16 +- modules/commands/ms_set.cpp | 9 +- modules/commands/ms_staff.cpp | 16 +- modules/commands/ns_access.cpp | 7 +- modules/commands/ns_ajoin.cpp | 8 +- modules/commands/ns_alist.cpp | 4 +- modules/commands/ns_cert.cpp | 23 +- modules/commands/ns_drop.cpp | 13 +- modules/commands/ns_getemail.cpp | 5 +- modules/commands/ns_getpass.cpp | 4 +- modules/commands/ns_group.cpp | 27 +- modules/commands/ns_identify.cpp | 2 +- modules/commands/ns_info.cpp | 26 +- modules/commands/ns_list.cpp | 15 +- modules/commands/ns_logout.cpp | 13 +- modules/commands/ns_recover.cpp | 22 +- modules/commands/ns_register.cpp | 17 +- modules/commands/ns_resetpass.cpp | 6 +- modules/commands/ns_set.cpp | 85 ++- modules/commands/ns_set_misc.cpp | 13 +- modules/commands/ns_status.cpp | 4 +- modules/commands/ns_suspend.cpp | 38 +- modules/commands/ns_update.cpp | 13 +- modules/commands/os_akill.cpp | 10 +- modules/commands/os_chankill.cpp | 4 +- modules/commands/os_config.cpp | 4 +- modules/commands/os_defcon.cpp | 57 +- modules/commands/os_dns.cpp | 18 +- modules/commands/os_forbid.cpp | 65 +- modules/commands/os_ignore.cpp | 8 +- modules/commands/os_info.cpp | 12 +- modules/commands/os_jupe.cpp | 4 +- modules/commands/os_kick.cpp | 4 +- modules/commands/os_kill.cpp | 4 +- modules/commands/os_list.cpp | 5 +- modules/commands/os_login.cpp | 8 +- modules/commands/os_logsearch.cpp | 4 +- modules/commands/os_mode.cpp | 5 +- modules/commands/os_modinfo.cpp | 5 +- modules/commands/os_module.cpp | 6 +- modules/commands/os_news.cpp | 13 +- modules/commands/os_noop.cpp | 7 +- modules/commands/os_oline.cpp | 4 +- modules/commands/os_oper.cpp | 5 +- modules/commands/os_reload.cpp | 4 +- modules/commands/os_session.cpp | 24 +- modules/commands/os_set.cpp | 4 +- modules/commands/os_stats.cpp | 5 +- modules/commands/os_sxline.cpp | 8 +- modules/commands/os_update.cpp | 4 +- modules/cs_statusupdate.cpp | 4 + modules/database/db_flatfile.cpp | 15 +- modules/database/db_old.cpp | 13 +- modules/database/db_redis.cpp | 13 +- modules/database/db_sql.cpp | 21 +- modules/database/db_sql_live.cpp | 16 +- modules/encryption/enc_bcrypt.cpp | 8 +- modules/encryption/enc_md5.cpp | 8 +- modules/encryption/enc_none.cpp | 6 + modules/encryption/enc_old.cpp | 8 +- modules/encryption/enc_sha1.cpp | 8 +- modules/encryption/enc_sha256.cpp | 8 +- modules/extra/m_ldap.cpp | 2 + modules/extra/m_ldap_authentication.cpp | 23 +- modules/extra/m_ldap_oper.cpp | 9 +- modules/extra/m_mysql.cpp | 5 +- modules/extra/m_sasl_dh-aes.cpp | 6 +- modules/extra/m_sasl_dh-blowfish.cpp | 6 +- modules/extra/m_sql_authentication.cpp | 7 +- modules/extra/m_sql_log.cpp | 2 + modules/extra/m_sql_oper.cpp | 4 +- modules/extra/m_sqlite.cpp | 1 + modules/extra/m_ssl_gnutls.cpp | 6 +- modules/extra/m_ssl_openssl.cpp | 5 +- modules/extra/stats/cs_fantasy_top.cpp | 2 +- modules/extra/stats/m_chanstats.cpp | 4 +- modules/fantasy.cpp | 21 +- modules/m_dns.cpp | 7 +- modules/m_dnsbl.cpp | 2 + modules/m_helpchan.cpp | 2 + modules/m_httpd.cpp | 5 +- modules/m_proxyscan.cpp | 6 +- modules/m_redis.cpp | 2 + modules/m_rewrite.cpp | 3 +- modules/m_sasl.cpp | 8 +- modules/m_xmlrpc.cpp | 5 +- modules/m_xmlrpc_main.cpp | 2 +- modules/ns_maxemail.cpp | 2 + modules/protocol/bahamut.cpp | 39 +- modules/protocol/charybdis.cpp | 60 +- modules/protocol/hybrid.cpp | 49 +- modules/protocol/inspircd20.cpp | 61 +- modules/protocol/ngircd.cpp | 45 +- modules/protocol/plexus.cpp | 51 +- modules/protocol/ratbox.cpp | 48 +- modules/protocol/unreal.cpp | 62 +- modules/pseudoclients/botserv.cpp | 24 +- modules/pseudoclients/chanserv.cpp | 70 +- modules/pseudoclients/global.cpp | 23 +- modules/pseudoclients/hostserv.cpp | 18 + modules/pseudoclients/memoserv.cpp | 34 +- modules/pseudoclients/nickserv.cpp | 68 +- modules/pseudoclients/operserv.cpp | 54 +- modules/webcpanel/pages/index.cpp | 2 +- modules/webcpanel/webcpanel.cpp | 33 +- src/access.cpp | 6 +- src/base.cpp | 24 +- src/bots.cpp | 15 +- src/channels.cpp | 35 +- src/command.cpp | 5 +- src/config.cpp | 4 +- src/event.cpp | 103 +++ src/init.cpp | 3 +- src/logger.cpp | 5 +- src/main.cpp | 9 +- src/messages.cpp | 21 +- src/misc.cpp | 5 +- src/modes.cpp | 7 +- src/module.cpp | 2 - src/modulemanager.cpp | 126 +--- src/nickalias.cpp | 3 +- src/nickcore.cpp | 13 +- src/process.cpp | 3 +- src/regchannel.cpp | 7 +- src/serialize.cpp | 15 +- src/servers.cpp | 11 +- src/service.cpp | 126 ++++ src/uplink.cpp | 7 +- src/users.cpp | 23 +- 222 files changed, 3951 insertions(+), 2138 deletions(-) create mode 100644 include/event.h create mode 100644 include/modules/bs_bot.h create mode 100644 include/modules/bs_info.h create mode 100644 include/modules/chanserv.h create mode 100644 include/modules/cs_access.h create mode 100644 include/modules/cs_akick.h create mode 100644 include/modules/cs_drop.h create mode 100644 include/modules/cs_info.h create mode 100644 include/modules/cs_set.h create mode 100644 include/modules/fantasy.h create mode 100644 include/modules/global.h create mode 100644 include/modules/help.h create mode 100644 include/modules/hs_del.h create mode 100644 include/modules/memoserv.h create mode 100644 include/modules/nickserv.h create mode 100644 include/modules/ns_drop.h create mode 100644 include/modules/ns_group.h create mode 100644 include/modules/ns_info.h create mode 100644 include/modules/ns_set.h create mode 100644 include/modules/ns_update.h create mode 100644 include/modules/os_defcon.h delete mode 100644 include/modules/pseudoclients/chanserv.h delete mode 100644 include/modules/pseudoclients/global.h delete mode 100644 include/modules/pseudoclients/memoserv.h delete mode 100644 include/modules/pseudoclients/nickserv.h create mode 100644 src/event.cpp create mode 100644 src/service.cpp diff --git a/include/base.h b/include/base.h index a28695c5f..ad2b3cee6 100644 --- a/include/base.h +++ b/include/base.h @@ -32,13 +32,14 @@ class CoreExport Base class ReferenceBase { - protected: - bool invalid; + static std::set *references; public: - ReferenceBase() : invalid(false) { } - ReferenceBase(const ReferenceBase &other) : invalid(other.invalid) { } - virtual ~ReferenceBase() { } - inline void Invalidate() { this->invalid = true; } + static void ResetAll(); + + ReferenceBase(); + virtual ~ReferenceBase(); + virtual void Invalidate() anope_abstract; + virtual void Reset() { } }; /** Used to hold pointers to objects that may be deleted. A Reference will @@ -49,8 +50,11 @@ class Reference : public ReferenceBase { protected: T *ref; + + virtual void Check() { } + public: - Reference() : ref(NULL) + Reference() : ref(nullptr) { } @@ -60,19 +64,24 @@ class Reference : public ReferenceBase ref->AddReference(this); } - Reference(const Reference &other) : ReferenceBase(other), ref(other.ref) + Reference(const Reference &other) : ref(other.ref) { - if (operator bool()) + if (ref) ref->AddReference(this); } virtual ~Reference() { - if (operator bool()) - ref->DelReference(this); + if (*this) + this->ref->DelReference(this); } - inline Reference& operator=(const Reference &other) + void Invalidate() override + { + ref = nullptr; + } + + Reference& operator=(const Reference &other) { if (this != &other) { @@ -80,7 +89,6 @@ class Reference : public ReferenceBase this->ref->DelReference(this); this->ref = other.ref; - this->invalid = other.invalid; if (*this) this->ref->AddReference(this); @@ -88,36 +96,31 @@ class Reference : public ReferenceBase return *this; } - /* We explicitly call operator bool here in several places to prevent other - * operators, such operator T*, from being called instead, which will mess - * with any class inheriting from this that overloads this operator. - */ - virtual operator bool() + explicit operator bool() { - if (!this->invalid) - return this->ref != NULL; - return false; + Check(); + return this->ref != nullptr; } - inline operator T*() + operator T*() { - if (operator bool()) + if (*this) return this->ref; - return NULL; + return nullptr; } - inline T* operator->() + T* operator->() { - if (operator bool()) + if (*this) return this->ref; - return NULL; + return nullptr; } - inline T* operator*() + T* operator*() { - if (operator bool()) + if (*this) return this->ref; - return NULL; + return nullptr; } /** Note that we can't have an operator< that returns this->ref < other.ref @@ -132,9 +135,9 @@ class Reference : public ReferenceBase * actually referred to. */ - inline bool operator==(const Reference &other) + bool operator==(const Reference &other) { - if (!this->invalid) + if (*this) return this->ref == other; return false; } diff --git a/include/defs.h b/include/defs.h index 3d8ebf4ff..b53e512d6 100644 --- a/include/defs.h +++ b/include/defs.h @@ -14,7 +14,6 @@ class AccessGroup; class AutoKick; class BotInfo; -class CallBack; class ChanAccess; class Channel; class ChannelInfo; @@ -25,7 +24,6 @@ class Command; class CommandSource; namespace Configuration { struct Conf; } class ConnectionSocket; -namespace DNS { struct Query; } class Entry; class IdentifyRequest; class InfoFormatter; diff --git a/include/event.h b/include/event.h new file mode 100644 index 000000000..b55559b48 --- /dev/null +++ b/include/event.h @@ -0,0 +1,1018 @@ +/* + * + * (C) 2014 Anope Team + * Contact us at team@anope.org + * + * Please read COPYING and README for further details. + * + */ + +#pragma once + +#include "service.h" +#include "modules.h" + +struct Events +{ + virtual ~Events() { } +}; + +/* uninstantiated */ +template +struct Caller; + +/* specialization for void */ +template +struct Caller +{ + void operator()(const std::vector &handlers, Func func, Args&&... args) + { + for (EventHandler *eh : handlers) + (eh->*func)(std::forward(args)...); + } +}; + +/* specialization for EventReturn */ +template +struct Caller +{ + EventReturn operator()(const std::vector &handlers, Func func, Args&&... args) + { + EventReturn ret = EVENT_CONTINUE; + + for (EventHandler *eh : handlers) + { + ret = (eh->*func)(std::forward(args)...); + if (ret != EVENT_CONTINUE) + return ret; + } + + return ret; + } +}; + +template +class EventHook; + +template +class EventHandlers : public Service +{ + std::vector handlers; + friend class EventHook; + + public: + EventHandlers(Module *o, const Anope::string &ename) : Service(o, "EventHandlers", ename) + { + } + + template + auto operator()(Func func, Args&&... args) -> decltype(((static_cast(nullptr))->*func)(args...)) + { + return Caller(nullptr))->*func)(args...)), Args...>()(this->handlers, func, std::forward(args)...); + } +}; + +template +class EventHandlersReference +{ + ServiceReference> ref; + public: + EventHandlersReference(const Anope::string &name) : ref("EventHandlers", name) { } + + explicit operator bool() + { + return !!ref; + } + + template + auto operator()(Func func, Args&&... args) -> decltype(((static_cast(nullptr))->*func)(args...)) + { + return (**ref)(func, std::forward(args)...); + } +}; + +template +class EventHook : public EventHandler +{ + + struct ServiceReferenceListener : ServiceReference> + { + EventHook *eh; + + ServiceReferenceListener(EventHook *t, const Anope::string &sname) : ServiceReference>("EventHandlers", sname), eh(t) + { + } + + void OnAcquire() override + { + if (std::find((*this)->handlers.begin(), (*this)->handlers.end(), eh) == (*this)->handlers.end()) + { + if (eh->priority == Priority::LAST) + (*this)->handlers.push_back(eh); + else + (*this)->handlers.insert((*this)->handlers.begin(), eh); + } + } + } handlers; + + public: + enum class Priority + { + FIRST, + LAST + } + priority; + + EventHook(const Anope::string &name, Priority p = Priority::LAST) : handlers(this, name) + { + handlers.Check(); + } + + ~EventHook() + { + if (!handlers) + return; + + auto it = std::find(handlers->handlers.begin(), handlers->handlers.end(), this); + if (it != handlers->handlers.end()) + handlers->handlers.erase(it); + } +}; + +namespace Event +{ + struct CoreExport PreUserKicked : Events + { + /** Called before a user has been kicked from a channel. + * @param source The kicker + * @param cu The user, channel, and status of the user being kicked + * @param kickmsg The reason for the kick. + */ + virtual void OnPreUserKicked(const MessageSource &source, ChanUserContainer *cu, const Anope::string &kickmsg) anope_abstract; + }; + extern CoreExport EventHandlers OnPreUserKicked; + + struct CoreExport UserKicked : Events + { + /** Called when a user has been kicked from a channel. + * @param source The kicker + * @param target The user being kicked + * @param channel The channel the user was kicked from, which may no longer exist + * @param status The status the kicked user had on the channel before they were kicked + * @param kickmsg The reason for the kick. + */ + virtual void OnUserKicked(const MessageSource &source, User *target, const Anope::string &channel, ChannelStatus &status, const Anope::string &kickmsg) anope_abstract; + }; + extern CoreExport EventHandlers OnUserKicked; + + struct CoreExport PreBotAssign : Events + { + /** Called before a bot is assigned to a channel. + * @param sender The user assigning the bot + * @param ci The channel the bot is to be assigned to. + * @param bi The bot being assigned. + * @return EVENT_CONTINUE to let other modules decide, EVENT_STOP to deny the assign. + */ + virtual EventReturn OnPreBotAssign(User *sender, ChannelInfo *ci, BotInfo *bi) anope_abstract; + }; + extern CoreExport EventHandlers OnPreBotAssign; + + struct CoreExport BotAssign : Events + { + /** Called when a bot is assigned ot a channel + */ + virtual void OnBotAssign(User *sender, ChannelInfo *ci, BotInfo *bi) anope_abstract; + }; + extern CoreExport EventHandlers OnBotAssign; + + struct CoreExport BotUnAssign : Events + { + /** Called before a bot is unassigned from a channel. + * @param sender The user unassigning the bot + * @param ci The channel the bot is being removed from + * @return EVENT_CONTINUE to let other modules decide, EVENT_STOP to deny the unassign. + */ + virtual EventReturn OnBotUnAssign(User *sender, ChannelInfo *ci) anope_abstract; + }; + extern CoreExport EventHandlers OnBotUnAssign; + + struct CoreExport UserConnect : Events + { + /** Called when a new user connects to the network. + * @param u The connecting user. + * @param exempt set to true/is true if the user should be excepted from bans etc + */ + virtual void OnUserConnect(User *u, bool &exempt) anope_abstract; + }; + extern CoreExport EventHandlers OnUserConnect; + + struct CoreExport NewServer : Events + { + /** Called when a new server connects to the network. + * @param s The server that has connected to the network + */ + virtual void OnNewServer(Server *s) anope_abstract; + }; + extern CoreExport EventHandlers OnNewServer; + + struct CoreExport UserNickChange : Events + { + /** Called after a user changed the nick + * @param u The user. + * @param oldnick The old nick of the user + */ + virtual void OnUserNickChange(User *u, const Anope::string &oldnick) anope_abstract; + }; + extern CoreExport EventHandlers OnUserNickChange; + + + struct CoreExport PreCommand : Events + { + /** Called before a command is due to be executed. + * @param source The source of the command + * @param command The command the user is executing + * @param params The parameters the user is sending + * @return EVENT_CONTINUE to let other modules decide, EVENT_STOP to halt the command and not process it + */ + virtual EventReturn OnPreCommand(CommandSource &source, Command *command, std::vector ¶ms) anope_abstract; + }; + extern CoreExport EventHandlers OnPreCommand; + + struct CoreExport PostCommand : Events + { + /** Called after a command has been executed. + * @param source The source of the command + * @param command The command the user executed + * @param params The parameters the user sent + */ + virtual void OnPostCommand(CommandSource &source, Command *command, const std::vector ¶ms) anope_abstract; + }; + extern CoreExport EventHandlers OnPostCommand; + + struct CoreExport SaveDatabase : Events + { + /** Called when the databases are saved + */ + virtual void OnSaveDatabase() anope_abstract; + }; + extern CoreExport EventHandlers OnSaveDatabase; + + struct CoreExport LoadDatabase : Events + { + /** Called when the databases are loaded + * @return EVENT_CONTINUE to let other modules continue loading, EVENT_STOP to stop + */ + virtual EventReturn OnLoadDatabase() anope_abstract; + }; + extern CoreExport EventHandlers OnLoadDatabase; + + struct CoreExport Encrypt : Events + { + /** Called when anope needs to check passwords against encryption + * see src/encrypt.c for detailed informations + */ + virtual EventReturn OnEncrypt(const Anope::string &src, Anope::string &dest) anope_abstract; + }; + extern CoreExport EventHandlers OnEncrypt; + + struct CoreExport Decrypt : Events + { + virtual EventReturn OnDecrypt(const Anope::string &hashm, const Anope::string &src, Anope::string &dest) anope_abstract; + }; + extern CoreExport EventHandlers OnDecrypt; + + + + struct CoreExport CreateBot : Events + { + /** Called when a bot is created or destroyed + */ + virtual void OnCreateBot(BotInfo *bi) anope_abstract; + }; + extern CoreExport EventHandlers OnCreateBot; + + struct CoreExport DelBot : Events + { + virtual void OnDelBot(BotInfo *bi) anope_abstract; + }; + extern CoreExport EventHandlers OnDelBot; + + struct CoreExport BotKick : Events + { + /** Called before a bot kicks a user + * @param bi The bot sending the kick + * @param c The channel the user is being kicked on + * @param u The user being kicked + * @param reason The reason + * @return EVENT_CONTINUE to let other modules decide, EVENT_STOP to halt the command and not process it + */ + virtual EventReturn OnBotKick(BotInfo *bi, Channel *c, User *u, const Anope::string &reason) anope_abstract; + }; + extern CoreExport EventHandlers OnBotKick; + + struct CoreExport PrePartChannel : Events + { + /** Called before a user parts a channel + * @param u The user + * @param c The channel + */ + virtual void OnPrePartChannel(User *u, Channel *c) anope_abstract; + }; + extern CoreExport EventHandlers OnPrePartChannel; + + struct CoreExport PartChannel : Events + { + /** Called when a user parts a channel + * @param u The user + * @param c The channel, may be NULL if the channel no longer exists + * @param channel The channel name + * @param msg The part reason + */ + virtual void OnPartChannel(User *u, Channel *c, const Anope::string &channel, const Anope::string &msg) anope_abstract; + }; + extern CoreExport EventHandlers OnPartChannel; + + struct CoreExport LeaveChannel : Events + { + /** Called when a user leaves a channel. + * From either parting, being kicked, or quitting/killed! + * @param u The user + * @param c The channel + */ + virtual void OnLeaveChannel(User *u, Channel *c) anope_abstract; + }; + extern CoreExport EventHandlers OnLeaveChannel; + + struct CoreExport JoinChannel : Events + { + /** Called after a user joins a channel + * If this event triggers the user is allowed to be in the channel, and will + * not be kicked for restricted/akick/forbidden, etc. If you want to kick the user, + * use the CheckKick event instead. + * @param u The user + * @param channel The channel + */ + virtual void OnJoinChannel(User *u, Channel *c) anope_abstract; + }; + extern CoreExport EventHandlers OnJoinChannel; + + struct CoreExport TopicUpdated : Events + { + /** Called when a new topic is set + * @param c The channel + * @param setter The user who set the new topic + * @param topic The new topic + */ + virtual void OnTopicUpdated(Channel *c, const Anope::string &user, const Anope::string &topic) anope_abstract; + }; + extern CoreExport EventHandlers OnTopicUpdated; + + struct CoreExport PreServerConnect : Events + { + /** Called before Anope connecs to its uplink + */ + virtual void OnPreServerConnect() anope_abstract; + }; + extern CoreExport EventHandlers OnPreServerConnect; + + struct CoreExport ServerConnect : Events + { + /** Called when Anope connects to its uplink + */ + virtual void OnServerConnect() anope_abstract; + }; + extern CoreExport EventHandlers OnServerConnect; + + struct CoreExport PreUplinkSync : Events + { + /** Called when we are almost done synching with the uplink, just before we send the EOB + */ + virtual void OnPreUplinkSync(Server *serv) anope_abstract; + }; + extern CoreExport EventHandlers OnPreUplinkSync; + + struct CoreExport ServerDisconnect : Events + { + /** Called when Anope disconnects from its uplink, before it tries to reconnect + */ + virtual void OnServerDisconnect() anope_abstract; + }; + extern CoreExport EventHandlers OnServerDisconnect; + + struct CoreExport Restart : Events + { + /** Called when services restart + */ + virtual void OnRestart() anope_abstract; + }; + extern CoreExport EventHandlers OnRestart; + + struct CoreExport Shutdown : Events + { + /** Called when services shutdown + */ + virtual void OnShutdown() anope_abstract; + }; + extern CoreExport EventHandlers OnShutdown; + + struct CoreExport AddXLine : Events + { + /** Called before a XLine is added + * @param source The source of the XLine + * @param x The XLine + * @param xlm The xline manager it was added to + * @return EVENT_CONTINUE to let other modules decide, EVENT_STOP to halt the command and not process it + */ + virtual EventReturn OnAddXLine(CommandSource &source, const XLine *x, XLineManager *xlm) anope_abstract; + }; + extern CoreExport EventHandlers OnAddXLine; + + struct CoreExport DelXLine : Events + { + /** Called before a XLine is deleted + * @param source The source of the XLine + * @param x The XLine + * @param xlm The xline manager it was deleted from + */ + virtual void OnDelXLine(CommandSource &source, const XLine *x, XLineManager *xlm) anope_abstract; + }; + extern CoreExport EventHandlers OnDelXLine; + + struct CoreExport IsServicesOperEvent : Events + { + /** Called when a user is checked for whether they are a services oper + * @param u The user + * @return EVENT_ALLOW to allow, anything else to deny + */ + virtual EventReturn IsServicesOper(User *u) anope_abstract; + }; + extern CoreExport EventHandlers OnIsServicesOper; + + struct CoreExport ServerQuit : Events + { + /** Called when a server quits + * @param server The server + */ + virtual void OnServerQuit(Server *server) anope_abstract; + }; + extern CoreExport EventHandlers OnServerQuit; + + struct CoreExport UserQuit : Events + { + /** Called when a user quits, or is killed + * @param u The user + * @param msg The quit message + */ + virtual void OnUserQuit(User *u, const Anope::string &msg) anope_abstract; + }; + extern CoreExport EventHandlers OnUserQuit; + + struct CoreExport PreUserLogoff : Events + { + /** Called when a user is quit, before and after being internally removed from + * This is different from OnUserQuit, which takes place at the time of the quit. + * This happens shortly after when all message processing is finished. + * all lists (channels, user list, etc) + * @param u The user + */ + virtual void OnPreUserLogoff(User *u) anope_abstract; + }; + extern CoreExport EventHandlers OnPreUserLogoff; + + struct CoreExport PostUserLogoff : Events + { + virtual void OnPostUserLogoff(User *u) anope_abstract; + }; + extern CoreExport EventHandlers OnPostUserLogoff; + + struct CoreExport AccessDel : Events + { + /** Called after an access entry is deleted from a channel + * @param ci The channel + * @param source The source of the command + * @param access The access entry that was removed + */ + virtual void OnAccessDel(ChannelInfo *ci, CommandSource &source, ChanAccess *access) anope_abstract; + }; + extern CoreExport EventHandlers OnAccessDel; + + struct CoreExport AccessAdd : Events + { + /** Called when access is added + * @param ci The channel + * @param source The source of the command + * @param access The access changed + */ + virtual void OnAccessAdd(ChannelInfo *ci, CommandSource &source, ChanAccess *access) anope_abstract; + }; + extern CoreExport EventHandlers OnAccessAdd; + + struct CoreExport AccessClear : Events + { + /** Called when the access list is cleared + * @param ci The channel + * @param u The user who cleared the access + */ + virtual void OnAccessClear(ChannelInfo *ci, CommandSource &source) anope_abstract; + }; + extern CoreExport EventHandlers OnAccessClear; + + struct CoreExport ChanRegistered : Events + { + /** Called when a channel is registered + * @param ci The channel + */ + virtual void OnChanRegistered(ChannelInfo *ci) anope_abstract; + }; + extern CoreExport EventHandlers OnChanRegistered; + + + struct CoreExport CreateChan : Events + { + /** Called when a channel is being created, for any reason + * @param ci The channel + */ + virtual void OnCreateChan(ChannelInfo *ci) anope_abstract; + }; + extern CoreExport EventHandlers OnCreateChan; + + struct CoreExport DelChan : Events + { + /** Called when a channel is being deleted, for any reason + * @param ci The channel + */ + virtual void OnDelChan(ChannelInfo *ci) anope_abstract; + }; + extern CoreExport EventHandlers OnDelChan; + + struct CoreExport ChannelCreate : Events + { + /** Called when a new channel is created + * Note that this channel may not be introduced to the uplink at this point. + * @param c The channel + */ + virtual void OnChannelCreate(Channel *c) anope_abstract; + }; + extern CoreExport EventHandlers OnChannelCreate; + + struct CoreExport ChannelDelete : Events + { + /** Called when a channel is deleted + * @param c The channel + */ + virtual void OnChannelDelete(Channel *c) anope_abstract; + }; + extern CoreExport EventHandlers OnChannelDelete; + + + struct CoreExport CheckKick : Events + { + /** Called after a user join a channel when we decide whether to kick them or not + * @param u The user + * @param c The channel + * @param kick Set to true to kick + * @param mask The mask to ban, if any + * @param reason The reason for the kick + * @return EVENT_STOP to prevent the user from joining by kicking/banning the user + */ + virtual EventReturn OnCheckKick(User *u, Channel *c, Anope::string &mask, Anope::string &reason) anope_abstract; + }; + extern CoreExport EventHandlers OnCheckKick; + + struct CoreExport CheckPriv : Events + { + /** Checks if access has the channel privilege 'priv'. + * @param access THe access struct + * @param priv The privilege being checked for + * @return EVENT_ALLOW for yes, EVENT_STOP to stop all processing + */ + virtual EventReturn OnCheckPriv(const ChanAccess *access, const Anope::string &priv) anope_abstract; + }; + extern CoreExport EventHandlers OnCheckPriv; + + struct CoreExport GroupCheckPriv : Events + { + /** Check whether an access group has a privilege + * @param group The group + * @param priv The privilege + * @return MOD_ALLOW to allow, MOD_STOP to stop + */ + virtual EventReturn OnGroupCheckPriv(const AccessGroup *group, const Anope::string &priv) anope_abstract; + }; + extern CoreExport EventHandlers OnGroupCheckPriv; + + struct CoreExport NickIdentify : Events + { + /** Called when a user identifies to a nick + * @param u The user + */ + virtual void OnNickIdentify(User *u) anope_abstract; + }; + extern CoreExport EventHandlers OnNickIdentify; + + struct CoreExport UserLogin : Events + { + /** Called when a user is logged into an account + * @param u The user + */ + virtual void OnUserLogin(User *u) anope_abstract; + }; + extern CoreExport EventHandlers OnUserLogin; + + struct CoreExport NickLogout : Events + { + /** Called when a nick logs out + * @param u The nick + */ + virtual void OnNickLogout(User *u) anope_abstract; + }; + extern CoreExport EventHandlers OnNickLogout; + + struct CoreExport DelNick : Events + { + /** Called on delnick() + * @ param na pointer to the nickalias + */ + virtual void OnDelNick(NickAlias *na) anope_abstract; + }; + extern CoreExport EventHandlers OnDelNick; + + struct CoreExport NickCoreCreate : Events + { + /** Called when a nickcore is created + * @param nc The nickcore + */ + virtual void OnNickCoreCreate(NickCore *nc) anope_abstract; + }; + extern CoreExport EventHandlers OnNickCoreCreate; + + struct CoreExport DelCore : Events + { + /** Called on delcore() + * @param nc pointer to the NickCore + */ + virtual void OnDelCore(NickCore *nc) anope_abstract; + }; + extern CoreExport EventHandlers OnDelCore; + + struct CoreExport ChangeCoreDisplay : Events + { + /** Called on change_core_display() + * @param nc pointer to the NickCore + * @param newdisplay the new display + */ + virtual void OnChangeCoreDisplay(NickCore *nc, const Anope::string &newdisplay) anope_abstract; + }; + extern CoreExport EventHandlers OnChangeCoreDisplay; + + struct CoreExport NickClearAccess : Events + { + /** called from NickCore::ClearAccess() + * @param nc pointer to the NickCore + */ + virtual void OnNickClearAccess(NickCore *nc) anope_abstract; + }; + extern CoreExport EventHandlers OnNickClearAccess; + + struct CoreExport NickAddAccess : Events + { + /** Called when a user adds an entry to their access list + * @param nc The nick + * @param entry The entry + */ + virtual void OnNickAddAccess(NickCore *nc, const Anope::string &entry) anope_abstract; + }; + extern CoreExport EventHandlers OnNickAddAccess; + + struct CoreExport NickEraseAccess : Events + { + /** Called from NickCore::EraseAccess() + * @param nc pointer to the NickCore + * @param entry The access mask + */ + virtual void OnNickEraseAccess(NickCore *nc, const Anope::string &entry) anope_abstract; + }; + extern CoreExport EventHandlers OnNickEraseAccess; + + + + struct CoreExport CheckAuthentication : Events + { + /** Check whether a username and password is correct + * @param u The user trying to identify, if applicable. + * @param req The login request + */ + virtual void OnCheckAuthentication(User *u, IdentifyRequest *req) anope_abstract; + }; + extern CoreExport EventHandlers OnCheckAuthentication; + + struct CoreExport Fingerprint : Events + { + /** Called when we get informed about a users SSL fingerprint + * when we call this, the fingerprint should already be stored in the user struct + * @param u pointer to the user + */ + virtual void OnFingerprint(User *u) anope_abstract; + }; + extern CoreExport EventHandlers OnFingerprint; + + struct CoreExport UserAway : Events + { + /** Called when a user becomes (un)away + * @param message The message, is .empty() if unaway + */ + virtual void OnUserAway(User *u, const Anope::string &message) anope_abstract; + }; + extern CoreExport EventHandlers OnUserAway; + + struct CoreExport Invite : Events + { + /** Called when a user invites one of our users to a channel + * @param source The user doing the inviting + * @param c The channel the user is inviting to + * @param targ The user being invited + */ + virtual void OnInvite(User *source, Channel *c, User *targ) anope_abstract; + }; + extern CoreExport EventHandlers OnInvite; + + struct CoreExport SetVhost : Events + { + /** Called when a vhost is set + * @param na The nickalias of the vhost + */ + virtual void OnSetVhost(NickAlias *na) anope_abstract; + }; + extern CoreExport EventHandlers OnSetVhost; + + struct CoreExport SetDisplayedHost : Events + { + /** Called when a users host changes + * @param u The user + */ + virtual void OnSetDisplayedHost(User *) anope_abstract; + }; + extern CoreExport EventHandlers OnSetDisplayedHost; + + struct CoreExport ChannelModeSet : Events + { + /** Called when a mode is set on a channel + * @param c The channel + * @param setter The user or server that is setting the mode + * @param mode The mode + * @param param The mode param, if there is one + * @return EVENT_STOP to make mlock/secureops etc checks not happen + */ + virtual EventReturn OnChannelModeSet(Channel *c, MessageSource &setter, ChannelMode *mode, const Anope::string ¶m) anope_abstract; + }; + extern CoreExport EventHandlers OnChannelModeSet; + + struct CoreExport ChannelModeUnset : Events + { + /** Called when a mode is unset on a channel + * @param c The channel + * @param setter The user or server that is unsetting the mode + * @param mode The mode + * @param param The mode param, if there is one + * @return EVENT_STOP to make mlock/secureops etc checks not happen + */ + virtual EventReturn OnChannelModeUnset(Channel *c, MessageSource &setter, ChannelMode *mode, const Anope::string ¶m) anope_abstract; + }; + extern CoreExport EventHandlers OnChannelModeUnset; + + struct CoreExport UserModeSet : Events + { + /** Called when a mode is set on a user + * @param setter who/what is setting the mode + * @param u The user + * @param mname The mode name + */ + virtual void OnUserModeSet(const MessageSource &setter, User *u, const Anope::string &mname) anope_abstract; + }; + extern CoreExport EventHandlers OnUserModeSet; + + struct CoreExport UserModeUnset : Events + { + /** Called when a mode is unset from a user + * @param setter who/what is setting the mode + * @param u The user + * @param mname The mode name + */ + virtual void OnUserModeUnset(const MessageSource &setter, User *u, const Anope::string &mname) anope_abstract; + }; + extern CoreExport EventHandlers OnUserModeUnset; + + struct CoreExport ChannelModeAdd : Events + { + /** Called when a channel mode is introducted into Anope + * @param cm The mode + */ + virtual void OnChannelModeAdd(ChannelMode *cm) anope_abstract; + }; + extern CoreExport EventHandlers OnChannelModeAdd; + + struct CoreExport UserModeAdd : Events + { + /** Called when a user mode is introducted into Anope + * @param um The mode + */ + virtual void OnUserModeAdd(UserMode *um) anope_abstract; + }; + extern CoreExport EventHandlers OnUserModeAdd; + + struct CoreExport ModuleLoad : Events + { + /** Called after a module is loaded + * @param u The user loading the module, can be NULL + * @param m The module + */ + virtual void OnModuleLoad(User *u, Module *m) anope_abstract; + }; + extern CoreExport EventHandlers OnModuleLoad; + + struct CoreExport ModuleUnload : Events + { + /** Called before a module is unloaded + * @param u The user, can be NULL + * @param m The module + */ + virtual void OnModuleUnload(User *u, Module *m) anope_abstract; + }; + extern CoreExport EventHandlers OnModuleUnload; + + struct CoreExport ServerSync : Events + { + /** Called when a server is synced + * @param s The server, can be our uplink server + */ + virtual void OnServerSync(Server *s) anope_abstract; + }; + extern CoreExport EventHandlers OnServerSync; + + struct CoreExport UplinkSync : Events + { + /** Called when we sync with our uplink + * @param s Our uplink + */ + virtual void OnUplinkSync(Server *s) anope_abstract; + }; + extern CoreExport EventHandlers OnUplinkSync; + + struct CoreExport BotPrivmsg : Events + { + /** Called when we receive a PRIVMSG for one of our clients + * @param u The user sending the PRIVMSG + * @param bi The target of the PRIVMSG + * @param message The message + * @return EVENT_STOP to halt processing + */ + virtual EventReturn OnBotPrivmsg(User *u, BotInfo *bi, Anope::string &message) anope_abstract; + }; + extern CoreExport EventHandlers OnBotPrivmsg; + + struct CoreExport BotNotice : Events + { + /** Called when we receive a NOTICE for one of our clients + * @param u The user sending the NOTICE + * @param bi The target of the NOTICE + * @param message The message + */ + virtual void OnBotNotice(User *u, BotInfo *bi, Anope::string &message) anope_abstract; + }; + extern CoreExport EventHandlers OnBotNotice; + + struct CoreExport Privmsg : Events + { + /** Called when we receive a PRIVMSG for a registered channel we are in + * @param u The source of the message + * @param c The channel + * @param msg The message + */ + virtual void OnPrivmsg(User *u, Channel *c, Anope::string &msg) anope_abstract; + }; + extern CoreExport EventHandlers OnPrivmsg; + + struct CoreExport Log : Events + { + /** Called when a message is logged + * @param l The log message + */ + virtual void OnLog(::Log *l) anope_abstract; + }; + extern CoreExport EventHandlers OnLog; + + struct CoreExport LogMessage : Events + { + /** Called when a log message is actually logged to a given log info + * The message has already passed validation checks by the LogInfo + * @param li The loginfo whee the message is being logged + * @param l The log message + * @param msg The final formatted message, derived from 'l' + */ + virtual void OnLogMessage(LogInfo *li, const ::Log *l, const Anope::string &msg) anope_abstract; + }; + extern CoreExport EventHandlers OnLogMessage; + + struct CoreExport CheckModes : Events + { + /** Called when a channels modes are being checked to see if they are allowed, + * mostly to ensure mlock/+r are set. + * @param c The channel + */ + virtual void OnCheckModes(Reference &c) anope_abstract; + }; + extern CoreExport EventHandlers OnCheckModes; + + struct CoreExport ChannelSync : Events + { + /** Called when a channel is synced. + * Channels are synced after a sjoin is finished processing + * for a newly created channel to set the correct modes, topic, + * set. + */ + virtual void OnChannelSync(Channel *c) anope_abstract; + }; + extern CoreExport EventHandlers OnChannelSync; + + struct CoreExport SetCorrectModes : Events + { + /** Called to set the correct modes on the user on the given channel + * @param user The user + * @param chan The channel + * @param access The user's access on the channel + * @param give_modes If giving modes is desired + * @param take_modes If taking modes is desired + */ + virtual void OnSetCorrectModes(User *user, Channel *chan, AccessGroup &access, bool &give_modes, bool &take_modes) anope_abstract; + }; + extern CoreExport EventHandlers OnSetCorrectModes; + + struct CoreExport SerializeCheck : Events + { + virtual void OnSerializeCheck(Serialize::Type *) anope_abstract; + }; + extern CoreExport EventHandlers OnSerializeCheck; + + struct CoreExport SerializableConstruct : Events + { + virtual void OnSerializableConstruct(Serializable *) anope_abstract; + }; + extern CoreExport EventHandlers OnSerializableConstruct; + + struct CoreExport SerializableDestruct : Events + { + virtual void OnSerializableDestruct(Serializable *) anope_abstract; + }; + extern CoreExport EventHandlers OnSerializableDestruct; + + struct CoreExport SerializableUpdate : Events + { + virtual void OnSerializableUpdate(Serializable *) anope_abstract; + }; + extern CoreExport EventHandlers OnSerializableUpdate; + + struct CoreExport SerializeTypeCreate : Events + { + virtual void OnSerializeTypeCreate(Serialize::Type *) anope_abstract; + }; + extern CoreExport EventHandlers OnSerializeTypeCreate; + + struct CoreExport Message : Events + { + /** Called whenever a message is received from the uplink + * @param source The source of the message + * @param command The command being executed + * @param params Parameters + * @return EVENT_STOP to prevent the protocol module from processing this message + */ + virtual EventReturn OnMessage(MessageSource &source, Anope::string &command, std::vector ¶m) anope_abstract; + }; + extern CoreExport EventHandlers OnMessage; + + struct CoreExport CanSet : Events + { + /** Called to determine if a chnanel mode can be set by a user + * @param u The user + * @param cm The mode + */ + virtual EventReturn OnCanSet(User *u, const ChannelMode *cm) anope_abstract; + }; + extern CoreExport EventHandlers OnCanSet; + + struct CoreExport CheckDelete : Events + { + virtual EventReturn OnCheckDelete(Channel *) anope_abstract; + }; + extern CoreExport EventHandlers OnCheckDelete; + + struct CoreExport ExpireTick : Events + { + /** Called every options:expiretimeout seconds. Should be used to expire nicks, + * channels, etc. + */ + virtual void OnExpireTick() anope_abstract; + }; + extern CoreExport EventHandlers OnExpireTick; + +} + diff --git a/include/module.h b/include/module.h index 571cf4a6a..0efbb7334 100644 --- a/include/module.h +++ b/include/module.h @@ -19,6 +19,7 @@ #include "channels.h" #include "commands.h" #include "config.h" +#include "event.h" #include "extensible.h" #include "hashcomp.h" #include "language.h" @@ -43,9 +44,3 @@ #include "uplink.h" #include "users.h" #include "xline.h" - -#include "modules/pseudoclients/chanserv.h" -#include "modules/pseudoclients/global.h" -#include "modules/pseudoclients/memoserv.h" -#include "modules/pseudoclients/nickserv.h" - diff --git a/include/modules.h b/include/modules.h index 05a763b00..56778d4e2 100644 --- a/include/modules.h +++ b/include/modules.h @@ -51,77 +51,6 @@ } #endif -/** - * This #define allows us to call a method in all - * loaded modules in a readable simple way, e.g.: - * - * FOREACH_MOD(OnUserConnect, (user, exempt)); - */ -#define FOREACH_MOD(ename, args) \ -if (true) \ -{ \ - std::vector &_modules = ModuleManager::EventHandlers[I_ ## ename]; \ - for (std::vector::iterator _i = _modules.begin(); _i != _modules.end();) \ - { \ - try \ - { \ - (*_i)->ename args; \ - } \ - catch (const ModuleException &modexcept) \ - { \ - Log() << "Exception caught: " << modexcept.GetReason(); \ - } \ - catch (const NotImplementedException &) \ - { \ - _i = _modules.erase(_i); \ - continue; \ - } \ - ++_i; \ - } \ -} \ -else \ - static_cast(0) - -/** - * This define is similar to the one above but returns a result. - * The first module to return a result other than EVENT_CONTINUE is the value to be accepted, - * and any modules after are ignored. This is used like: - * - * EventReturn MOD_RESULT; - * FOREACH_RESULT(OnUserConnect, MOD_RESULT, (user, exempt)); - */ -#define FOREACH_RESULT(ename, ret, args) \ -if (true) \ -{ \ - ret = EVENT_CONTINUE; \ - std::vector &_modules = ModuleManager::EventHandlers[I_ ## ename]; \ - for (std::vector::iterator _i = _modules.begin(); _i != _modules.end();) \ - { \ - try \ - { \ - EventReturn res = (*_i)->ename args; \ - if (res != EVENT_CONTINUE) \ - { \ - ret = res; \ - break; \ - } \ - } \ - catch (const ModuleException &modexcept) \ - { \ - Log() << "Exception caught: " << modexcept.GetReason(); \ - } \ - catch (const NotImplementedException &) \ - { \ - _i = _modules.erase(_i); \ - continue; \ - } \ - ++_i; \ - } \ -} \ -else \ - static_cast(0) - - /** Possible return types from events. */ enum EventReturn @@ -144,9 +73,6 @@ enum ModuleReturn MOD_ERR_VERSION }; -/** Priority types which can be returned from Module::Prioritize() - */ -enum Priority { PRIORITY_FIRST, PRIORITY_DONTCARE, PRIORITY_LAST, PRIORITY_BEFORE, PRIORITY_AFTER }; /* Module types, in the order in which they are unloaded. The order these are in is IMPORTANT */ enum { @@ -205,8 +131,6 @@ class ModuleVersion int GetPatch() const; }; -class NotImplementedException : public CoreException { }; - /** Every module in Anope is actually a class. */ class CoreExport Module : public Extensible @@ -283,827 +207,11 @@ class CoreExport Module : public Extensible */ ModuleVersion GetVersion() const; - /* Everything below here are events. Modules must ModuleManager::Attach to these events - * before they will be called. - */ - - /** Called before a user has been kicked from a channel. - * @param source The kicker - * @param cu The user, channel, and status of the user being kicked - * @param kickmsg The reason for the kick. - */ - virtual void OnPreUserKicked(const MessageSource &source, ChanUserContainer *cu, const Anope::string &kickmsg) { throw NotImplementedException(); } - - /** Called when a user has been kicked from a channel. - * @param source The kicker - * @param target The user being kicked - * @param channel The channel the user was kicked from, which may no longer exist - * @param status The status the kicked user had on the channel before they were kicked - * @param kickmsg The reason for the kick. - */ - virtual void OnUserKicked(const MessageSource &source, User *target, const Anope::string &channel, ChannelStatus &status, const Anope::string &kickmsg) { throw NotImplementedException(); } - /** Called when Services' configuration is being (re)loaded. * @param conf The config that is being built now and will replace the global Config object * @throws A ConfigException to abort the config (re)loading process. */ - virtual void OnReload(Configuration::Conf *conf) { throw NotImplementedException(); } - - /** Called before a bot is assigned to a channel. - * @param sender The user assigning the bot - * @param ci The channel the bot is to be assigned to. - * @param bi The bot being assigned. - * @return EVENT_CONTINUE to let other modules decide, EVENT_STOP to deny the assign. - */ - virtual EventReturn OnPreBotAssign(User *sender, ChannelInfo *ci, BotInfo *bi) { throw NotImplementedException(); } - - /** Called when a bot is assigned ot a channel - */ - virtual void OnBotAssign(User *sender, ChannelInfo *ci, BotInfo *bi) { throw NotImplementedException(); } - - /** Called before a bot is unassigned from a channel. - * @param sender The user unassigning the bot - * @param ci The channel the bot is being removed from - * @return EVENT_CONTINUE to let other modules decide, EVENT_STOP to deny the unassign. - */ - virtual EventReturn OnBotUnAssign(User *sender, ChannelInfo *ci) { throw NotImplementedException(); } - - /** Called when a new user connects to the network. - * @param u The connecting user. - * @param exempt set to true/is true if the user should be excepted from bans etc - */ - virtual void OnUserConnect(User *u, bool &exempt) { throw NotImplementedException(); } - - /** Called when a new server connects to the network. - * @param s The server that has connected to the network - */ - virtual void OnNewServer(Server *s) { throw NotImplementedException(); } - - /** Called after a user changed the nick - * @param u The user. - * @param oldnick The old nick of the user - */ - virtual void OnUserNickChange(User *u, const Anope::string &oldnick) { throw NotImplementedException(); } - - /** Called when someone uses the generic/help command - * @param source Command source - * @param params Params - * @return EVENT_STOP to stop processing - */ - virtual EventReturn OnPreHelp(CommandSource &source, const std::vector ¶ms) { throw NotImplementedException(); } - - /** Called when someone uses the generic/help command - * @param source Command source - * @param params Params - */ - virtual void OnPostHelp(CommandSource &source, const std::vector ¶ms) { throw NotImplementedException(); } - - /** Called before a command is due to be executed. - * @param source The source of the command - * @param command The command the user is executing - * @param params The parameters the user is sending - * @return EVENT_CONTINUE to let other modules decide, EVENT_STOP to halt the command and not process it - */ - virtual EventReturn OnPreCommand(CommandSource &source, Command *command, std::vector ¶ms) { throw NotImplementedException(); } - - /** Called after a command has been executed. - * @param source The source of the command - * @param command The command the user executed - * @param params The parameters the user sent - */ - virtual void OnPostCommand(CommandSource &source, Command *command, const std::vector ¶ms) { throw NotImplementedException(); } - - /** Called when the databases are saved - */ - virtual void OnSaveDatabase() { throw NotImplementedException(); } - - /** Called when the databases are loaded - * @return EVENT_CONTINUE to let other modules continue loading, EVENT_STOP to stop - */ - virtual EventReturn OnLoadDatabase() { throw NotImplementedException(); } - - /** Called when anope needs to check passwords against encryption - * see src/encrypt.c for detailed informations - */ - virtual EventReturn OnEncrypt(const Anope::string &src, Anope::string &dest) { throw NotImplementedException(); } - virtual EventReturn OnDecrypt(const Anope::string &hashm, const Anope::string &src, Anope::string &dest) { throw NotImplementedException(); } - - /** Called on fantasy command - * @param source The source of the command - * @param c The command - * @param ci The channel it's being used in - * @param params The params - * @return EVENT_STOP to halt processing and not run the command, EVENT_ALLOW to allow the command to be executed - */ - virtual EventReturn OnBotFantasy(CommandSource &source, Command *c, ChannelInfo *ci, const std::vector ¶ms) { throw NotImplementedException(); } - - /** Called on fantasy command without access - * @param source The source of the command - * @param c The command - * @param ci The channel it's being used in - * @param params The params - * @return EVENT_STOP to halt processing and not run the command, EVENT_ALLOW to allow the command to be executed - */ - virtual EventReturn OnBotNoFantasyAccess(CommandSource &source, Command *c, ChannelInfo *ci, const std::vector ¶ms) { throw NotImplementedException(); } - - /** Called when a bot places a ban - * @param u User being banned - * @param ci Channel the ban is placed on - * @param mask The mask being banned - */ - virtual void OnBotBan(User *u, ChannelInfo *ci, const Anope::string &mask) { throw NotImplementedException(); } - - /** Called before a badword is added to the badword list - * @param ci The channel - * @param bw The badword - */ - virtual void OnBadWordAdd(ChannelInfo *ci, const BadWord *bw) { throw NotImplementedException(); } - - /** Called before a badword is deleted from a channel - * @param ci The channel - * @param bw The badword - */ - virtual void OnBadWordDel(ChannelInfo *ci, const BadWord *bw) { throw NotImplementedException(); } - - /** Called when a bot is created or destroyed - */ - virtual void OnCreateBot(BotInfo *bi) { throw NotImplementedException(); } - virtual void OnDelBot(BotInfo *bi) { throw NotImplementedException(); } - - /** Called before a bot kicks a user - * @param bi The bot sending the kick - * @param c The channel the user is being kicked on - * @param u The user being kicked - * @param reason The reason - * @return EVENT_CONTINUE to let other modules decide, EVENT_STOP to halt the command and not process it - */ - virtual EventReturn OnBotKick(BotInfo *bi, Channel *c, User *u, const Anope::string &reason) { throw NotImplementedException(); } - - /** Called before a user parts a channel - * @param u The user - * @param c The channel - */ - virtual void OnPrePartChannel(User *u, Channel *c) {} - - /** Called when a user parts a channel - * @param u The user - * @param c The channel, may be NULL if the channel no longer exists - * @param channel The channel name - * @param msg The part reason - */ - virtual void OnPartChannel(User *u, Channel *c, const Anope::string &channel, const Anope::string &msg) { throw NotImplementedException(); } - - /** Called when a user leaves a channel. - * From either parting, being kicked, or quitting/killed! - * @param u The user - * @param c The channel - */ - virtual void OnLeaveChannel(User *u, Channel *c) { throw NotImplementedException(); } - - /** Called after a user joins a channel - * If this event triggers the user is allowed to be in the channel, and will - * not be kicked for restricted/akick/forbidden, etc. If you want to kick the user, - * use the CheckKick event instead. - * @param u The user - * @param channel The channel - */ - virtual void OnJoinChannel(User *u, Channel *c) { throw NotImplementedException(); } - - /** Called when a new topic is set - * @param c The channel - * @param setter The user who set the new topic - * @param topic The new topic - */ - virtual void OnTopicUpdated(Channel *c, const Anope::string &user, const Anope::string &topic) { throw NotImplementedException(); } - - /** Called before a channel expires - * @param ci The channel - * @param expire Set to true to allow the chan to expire - */ - virtual void OnPreChanExpire(ChannelInfo *ci, bool &expire) { throw NotImplementedException(); } - - /** Called before a channel expires - * @param ci The channel - */ - virtual void OnChanExpire(ChannelInfo *ci) { throw NotImplementedException(); } - - /** Called before Anope connecs to its uplink - */ - virtual void OnPreServerConnect() { throw NotImplementedException(); } - - /** Called when Anope connects to its uplink - */ - virtual void OnServerConnect() { throw NotImplementedException(); } - - /** Called when we are almost done synching with the uplink, just before we send the EOB - */ - virtual void OnPreUplinkSync(Server *serv) { throw NotImplementedException(); } - - /** Called when Anope disconnects from its uplink, before it tries to reconnect - */ - virtual void OnServerDisconnect() { throw NotImplementedException(); } - - /** Called when services restart - */ - virtual void OnRestart() { throw NotImplementedException(); } - - /** Called when services shutdown - */ - virtual void OnShutdown() { throw NotImplementedException(); } - - /** Called before a nick expires - * @param na The nick - * @param expire Set to true to allow the nick to expire - */ - virtual void OnPreNickExpire(NickAlias *na, bool &expire) { throw NotImplementedException(); } - - /** Called when a nick drops - * @param na The nick - */ - virtual void OnNickExpire(NickAlias *na) { throw NotImplementedException(); } - - /** Called when defcon level changes - * @param level The level - */ - virtual void OnDefconLevel(int level) { throw NotImplementedException(); } - - /** Called after an exception has been added - * @param ex The exception - * @return EVENT_CONTINUE to let other modules decide, EVENT_STOP to halt the command and not process it - */ - virtual EventReturn OnExceptionAdd(Exception *ex) { throw NotImplementedException(); } - - /** Called before an exception is deleted - * @param source The source deleting it - * @param ex The exceotion - */ - virtual void OnExceptionDel(CommandSource &source, Exception *ex) { throw NotImplementedException(); } - - /** Called before a XLine is added - * @param source The source of the XLine - * @param x The XLine - * @param xlm The xline manager it was added to - * @return EVENT_CONTINUE to let other modules decide, EVENT_STOP to halt the command and not process it - */ - virtual EventReturn OnAddXLine(CommandSource &source, const XLine *x, XLineManager *xlm) { throw NotImplementedException(); } - - /** Called before a XLine is deleted - * @param source The source of the XLine - * @param x The XLine - * @param xlm The xline manager it was deleted from - */ - virtual void OnDelXLine(CommandSource &source, const XLine *x, XLineManager *xlm) { throw NotImplementedException(); } - - /** Called when a user is checked for whether they are a services oper - * @param u The user - * @return EVENT_ALLOW to allow, anything else to deny - */ - virtual EventReturn IsServicesOper(User *u) { throw NotImplementedException(); } - - /** Called when a server quits - * @param server Th