From 22658d63bdb1e52a66f4514af45fa55ca5891345 Mon Sep 17 00:00:00 2001 From: Adam Date: Sun, 26 May 2013 17:13:11 -0400 Subject: Get rid of the remaining references in the core to specific services. Move more stuff out of the core to the proper modules. --- data/botserv.example.conf | 3 +- data/modules.example.conf | 2 +- data/operserv.example.conf | 7 + docs/README | 2 +- include/account.h | 14 +- include/bots.h | 2 - include/channels.h | 11 +- include/config.h | 3 + include/modes.h | 28 - include/module.h | 8 +- include/modules.h | 33 +- include/modules/chanserv.h | 18 - include/modules/global.h | 20 - include/modules/memoserv.h | 34 -- include/modules/nickserv.h | 16 - 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/regchannel.h | 11 - include/users.h | 6 - modules/commands/bs_assign.cpp | 2 - modules/commands/bs_badwords.cpp | 1 - modules/commands/bs_bot.cpp | 2 - modules/commands/bs_botlist.cpp | 2 - modules/commands/bs_control.cpp | 2 - modules/commands/bs_info.cpp | 2 - modules/commands/bs_kick.cpp | 2 +- modules/commands/cs_access.cpp | 2 - modules/commands/cs_akick.cpp | 2 - modules/commands/cs_ban.cpp | 1 - modules/commands/cs_clone.cpp | 11 +- modules/commands/cs_drop.cpp | 2 - modules/commands/cs_enforce.cpp | 2 +- modules/commands/cs_entrymsg.cpp | 2 - modules/commands/cs_fantasy_stats.cpp | 2 - modules/commands/cs_fantasy_top.cpp | 2 - modules/commands/cs_flags.cpp | 3 - modules/commands/cs_getkey.cpp | 3 - modules/commands/cs_info.cpp | 6 - modules/commands/cs_invite.cpp | 3 - modules/commands/cs_kick.cpp | 4 - modules/commands/cs_list.cpp | 3 - modules/commands/cs_log.cpp | 2 - modules/commands/cs_mode.cpp | 2 - modules/commands/cs_register.cpp | 15 +- modules/commands/cs_seen.cpp | 55 +- modules/commands/cs_set.cpp | 69 ++- modules/commands/cs_set_misc.cpp | 2 - modules/commands/cs_status.cpp | 2 - modules/commands/cs_suspend.cpp | 4 +- modules/commands/cs_sync.cpp | 2 +- modules/commands/cs_unban.cpp | 2 - modules/commands/cs_updown.cpp | 16 +- modules/commands/gl_global.cpp | 4 +- modules/commands/help.cpp | 2 - modules/commands/hs_del.cpp | 2 - modules/commands/hs_group.cpp | 2 - modules/commands/hs_list.cpp | 2 - modules/commands/hs_off.cpp | 2 - modules/commands/hs_on.cpp | 2 - modules/commands/hs_request.cpp | 6 +- modules/commands/hs_set.cpp | 2 - modules/commands/ms_cancel.cpp | 2 - modules/commands/ms_check.cpp | 2 - modules/commands/ms_del.cpp | 2 - modules/commands/ms_ignore.cpp | 12 - modules/commands/ms_info.cpp | 2 - modules/commands/ms_list.cpp | 2 - modules/commands/ms_read.cpp | 2 - modules/commands/ms_rsend.cpp | 2 - modules/commands/ms_send.cpp | 2 - modules/commands/ms_sendall.cpp | 2 - modules/commands/ms_set.cpp | 6 +- modules/commands/ms_staff.cpp | 2 - modules/commands/ns_access.cpp | 4 - modules/commands/ns_ajoin.cpp | 3 +- modules/commands/ns_alist.cpp | 2 - modules/commands/ns_cert.cpp | 9 +- modules/commands/ns_drop.cpp | 4 - modules/commands/ns_getemail.cpp | 2 - modules/commands/ns_getpass.cpp | 4 - modules/commands/ns_group.cpp | 10 +- modules/commands/ns_identify.cpp | 3 - modules/commands/ns_info.cpp | 4 - modules/commands/ns_list.cpp | 2 - modules/commands/ns_logout.cpp | 4 +- modules/commands/ns_recover.cpp | 20 +- modules/commands/ns_register.cpp | 20 +- modules/commands/ns_resetpass.cpp | 2 - modules/commands/ns_set.cpp | 16 +- modules/commands/ns_set_misc.cpp | 2 - modules/commands/ns_status.cpp | 2 - modules/commands/ns_suspend.cpp | 9 +- modules/commands/ns_update.cpp | 2 - modules/commands/os_akill.cpp | 2 - modules/commands/os_chankill.cpp | 2 - modules/commands/os_config.cpp | 2 - modules/commands/os_defcon.cpp | 26 +- modules/commands/os_forbid.cpp | 9 +- modules/commands/os_ignore.cpp | 2 - modules/commands/os_jupe.cpp | 2 - modules/commands/os_kick.cpp | 2 - modules/commands/os_kill.cpp | 2 - modules/commands/os_list.cpp | 2 - modules/commands/os_login.cpp | 2 - modules/commands/os_mode.cpp | 2 - modules/commands/os_modinfo.cpp | 2 - modules/commands/os_module.cpp | 2 - modules/commands/os_news.cpp | 19 +- modules/commands/os_noop.cpp | 3 +- modules/commands/os_oline.cpp | 2 - modules/commands/os_oper.cpp | 2 - modules/commands/os_reload.cpp | 2 - modules/commands/os_session.cpp | 47 +- modules/commands/os_set.cpp | 2 - modules/commands/os_shutdown.cpp | 2 - modules/commands/os_stats.cpp | 2 - modules/commands/os_svs.cpp | 6 +- modules/commands/os_sxline.cpp | 2 - modules/commands/os_update.cpp | 2 - modules/cs_statusupdate.cpp | 2 +- modules/database/db_flatfile.cpp | 8 +- modules/database/db_old.cpp | 2 - modules/database/db_plain.cpp | 8 +- modules/encryption/enc_md5.cpp | 2 - modules/extra/m_ldap_authentication.cpp | 2 + modules/extra/m_proxyscan.cpp | 1 + modules/extra/m_sql_authentication.cpp | 1 + modules/extra/m_sql_oper.cpp | 1 + modules/m_dnsbl.cpp | 1 + modules/m_helpchan.cpp | 2 +- modules/m_redis.cpp | 3 +- modules/protocol/bahamut.cpp | 16 +- modules/protocol/charybdis.cpp | 13 + modules/protocol/hybrid.cpp | 32 +- modules/protocol/inspircd11.cpp | 892 ------------------------------- modules/protocol/inspircd12.cpp | 16 +- modules/protocol/inspircd20.cpp | 4 +- modules/protocol/ngircd.cpp | 2 +- modules/protocol/plexus.cpp | 12 +- modules/protocol/ratbox.cpp | 4 - modules/protocol/unreal.cpp | 21 +- modules/pseudoclients/botserv.cpp | 27 +- modules/pseudoclients/chanserv.cpp | 241 ++++++--- modules/pseudoclients/global.cpp | 51 +- modules/pseudoclients/hostserv.cpp | 22 +- modules/pseudoclients/memoserv.cpp | 85 ++- modules/pseudoclients/nickserv.cpp | 295 ++++++---- modules/pseudoclients/operserv.cpp | 29 +- src/bots.cpp | 2 - src/channels.cpp | 73 +-- src/config.cpp | 12 + src/init.cpp | 2 +- src/logger.cpp | 10 +- src/main.cpp | 19 +- src/memos.cpp | 2 +- src/messages.cpp | 15 +- src/misc.cpp | 1 + src/modes.cpp | 33 +- src/nickalias.cpp | 109 ---- src/nickcore.cpp | 3 - src/protocol.cpp | 2 +- src/regchannel.cpp | 43 +- src/servers.cpp | 29 - src/tools/anopesmtp.cpp | 26 - src/users.cpp | 89 +-- src/xline.cpp | 2 +- 168 files changed, 920 insertions(+), 2222 deletions(-) delete mode 100644 include/modules/chanserv.h delete mode 100644 include/modules/global.h delete mode 100644 include/modules/memoserv.h delete mode 100644 include/modules/nickserv.h create mode 100644 include/modules/pseudoclients/chanserv.h create mode 100644 include/modules/pseudoclients/global.h create mode 100644 include/modules/pseudoclients/memoserv.h create mode 100644 include/modules/pseudoclients/nickserv.h delete mode 100644 modules/protocol/inspircd11.cpp diff --git a/data/botserv.example.conf b/data/botserv.example.conf index 887ddcd7d..1bd450123 100644 --- a/data/botserv.example.conf +++ b/data/botserv.example.conf @@ -298,7 +298,8 @@ command { service = "BotServ"; name = "SET GREET"; command = "botserv/set/greet" command { service = "BotServ"; name = "SET NOBOT"; command = "botserv/set/nobot"; permission = "botserv/set/nobot"; } command { service = "BotServ"; name = "SET PRIVATE"; command = "botserv/set/private"; permission = "botserv/set/private"; } -/* Fantasy commands +/* + * Fantasy commands * * Fantasy commands can be executed in channels that have a BotServ bot by prefixing the * command with one of the fantasy characters configured in botserv's fantasycharacter diff --git a/data/modules.example.conf b/data/modules.example.conf index 2129d3ac9..d906cb8bd 100644 --- a/data/modules.example.conf +++ b/data/modules.example.conf @@ -533,7 +533,7 @@ module { name = "help" } * * Provides the regex engine regex/pcre, which uses the Perl Compatible Regular Expressions library. */ -module { name = "m_regex_pcre" } +#module { name = "m_regex_pcre" } /* * m_regex_posix diff --git a/data/operserv.example.conf b/data/operserv.example.conf index 687247f0a..fab52fe2e 100644 --- a/data/operserv.example.conf +++ b/data/operserv.example.conf @@ -468,6 +468,13 @@ module { name = "os_news" + /* + * The service bot names to use to send news to users on connection + * and to opers when they oper. + */ + announcer = "Global" + oper_announcer = "OperServ" + /* * The number of LOGON/OPER news items to display when a user logs on. * diff --git a/docs/README b/docs/README index cd3864d44..8a455f03d 100644 --- a/docs/README +++ b/docs/README @@ -173,7 +173,7 @@ Table of Contents * Bahamut 1.4.27 or later (including 1.8) * Charybdis 3.4 or later * Hybrid 8.1 or later - * InspIRCd 1.1, 1.2, or 2.0 + * InspIRCd 1.2 or 2.0 * ngIRCd 19.2 or later * Plexus 3 or later * Ratbox 2.0.6 or later diff --git a/include/account.h b/include/account.h index b5edd7ec2..4d6bd714f 100644 --- a/include/account.h +++ b/include/account.h @@ -65,18 +65,6 @@ class CoreExport NickAlias : public Serializable, public Extensible void Serialize(Serialize::Data &data) const anope_override; static Serializable* Unserialize(Serializable *obj, Serialize::Data &); - /** Release a nick - * See the comment in users.cpp - */ - void Release(); - - /** This function is called when a user on this nick either disconnects or changes nick. - * Note that the user isnt necessarially identified to this nick - * See the comment in users.cpp - * @param u The user - */ - void OnCancel(User *u); - /** Set a vhost for the user * @param ident The ident * @param host The host @@ -306,7 +294,7 @@ class CoreExport NickCore : public Serializable, public Extensible }; /* A request to check if an account/password is valid. These can exist for - * extended periods of time due to some authentication modules take. + * extended periods due to the time some authentication modules take. */ class CoreExport IdentifyRequest { diff --git a/include/bots.h b/include/bots.h index 42345d8ea..ef05c11e0 100644 --- a/include/bots.h +++ b/include/bots.h @@ -131,6 +131,4 @@ class CoreExport BotInfo : public User, public Serializable static BotInfo* Find(const Anope::string &nick, bool nick_only = false); }; -extern CoreExport BotInfo *BotServ, *ChanServ, *Global, *HostServ, *MemoServ, *NickServ, *OperServ; - #endif // BOTS_H diff --git a/include/channels.h b/include/channels.h index 7d1918f08..25bd95097 100644 --- a/include/channels.h +++ b/include/channels.h @@ -30,12 +30,6 @@ struct ChanUserContainer : public Extensible ChanUserContainer(User *u, Channel *c) : user(u), chan(c) { } }; -/* Possible flags: - * - * INHABIT - ChanServ is currently holding the channel - * PERSIST - Channel still exists when emptied (IRCd enforced) - * SYNCING - Channel is syncing users (channel was just created) and it should not be deleted - */ class CoreExport Channel : public Base, public Extensible { public: @@ -52,6 +46,8 @@ class CoreExport Channel : public Base, public Extensible Serialize::Reference ci; /* When the channel was created */ time_t creation_time; + /* If the channel has just been created in a netjoin */ + bool syncing; /* Users in the channel */ typedef std::map ChanUserList; @@ -272,9 +268,8 @@ class CoreExport Channel : public Base, public Extensible * for the specified user. * @param user The user to give/remove modes to/from * @param give_modes if true modes may be given to the user - * @param check_noop if true, CI_NOAUTOOP is checked before giving modes */ - void SetCorrectModes(User *u, bool give_mode, bool check_noop); + void SetCorrectModes(User *u, bool give_modes); /** Unbans a user from this channel. * @param u The user to unban diff --git a/include/config.h b/include/config.h index bd76ca8a5..0ea30e5f6 100644 --- a/include/config.h +++ b/include/config.h @@ -124,6 +124,7 @@ namespace Configuration /* module configuration blocks */ std::map modules; + Anope::map bots; Conf(); @@ -131,6 +132,8 @@ namespace Configuration Block *GetModule(Module *); Block *GetModule(const Anope::string &name); + + BotInfo *GetClient(const Anope::string &name); }; struct Uplink diff --git a/include/modes.h b/include/modes.h index 2d9755817..1e5d7f7c1 100644 --- a/include/modes.h +++ b/include/modes.h @@ -262,24 +262,6 @@ class CoreExport ChannelModeRegistered : public ChannelMode bool CanSet(User *u) const anope_override; }; -class StackerInfo -{ - public: - /* Modes to be added */ - std::list > AddModes; - /* Modes to be deleted */ - std::list > DelModes; - /* Bot this is sent from */ - const BotInfo *bi; - - /** Add a mode to this object - * @param mode The mode - * @param set true if setting, false if unsetting - * @param param The param for the mode - */ - void AddMode(Mode *mode, bool set, const Anope::string ¶m); -}; - /** This is the mode manager * It contains functions for adding modes to Anope so Anope can track them * and do things such as MLOCK. @@ -289,16 +271,6 @@ class StackerInfo class CoreExport ModeManager { protected: - /* List of pairs of user/channels and their stacker info */ - static std::map UserStackerObjects; - static std::map ChannelStackerObjects; - - /** Build a list of mode strings to send to the IRCd from the mode stacker - * @param info The stacker info for a channel or user - * @return a list of strings - */ - static std::list BuildModeStrings(StackerInfo *info); - /* Array of all modes Anope knows about. Modes are in this array at position * modechar. Additionally, status modes are in this array (again) at statuschar. */ diff --git a/include/module.h b/include/module.h index d2b365bd7..39ef3403f 100644 --- a/include/module.h +++ b/include/module.h @@ -46,9 +46,9 @@ #include "users.h" #include "xline.h" -#include "modules/chanserv.h" -#include "modules/global.h" -#include "modules/memoserv.h" -#include "modules/nickserv.h" +#include "modules/pseudoclients/chanserv.h" +#include "modules/pseudoclients/global.h" +#include "modules/pseudoclients/memoserv.h" +#include "modules/pseudoclients/nickserv.h" #endif // MODULE_H diff --git a/include/modules.h b/include/modules.h index 641f6f80e..3f99a9114 100644 --- a/include/modules.h +++ b/include/modules.h @@ -363,9 +363,8 @@ class CoreExport Module : public Extensible virtual void OnPostCommand(CommandSource &source, Command *command, const std::vector ¶ms) { } /** Called when the databases are saved - * @return EVENT_CONTINUE to let other modules continue saving, EVENT_STOP to stop */ - virtual EventReturn OnSaveDatabase() { return EVENT_CONTINUE; } + virtual void OnSaveDatabase() { } /** Called when the databases are loaded * @return EVENT_CONTINUE to let other modules continue loading, EVENT_STOP to stop @@ -714,11 +713,16 @@ class CoreExport Module : public Extensible */ virtual void OnNickGroup(User *u, NickAlias *target) { } - /** Called when a user identifies + /** Called when a user identifies to a nick * @param u The user */ virtual void OnNickIdentify(User *u) { } + /** Called when a user is logged into an account + * @param u The user + */ + virtual void OnUserLogin(User *u) { } + /** Called when a nick logs out * @param u The nick */ @@ -985,8 +989,9 @@ class CoreExport Module : public Extensible * @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) { } + virtual void OnSetCorrectModes(User *user, Channel *chan, AccessGroup &access, bool &give_modes, bool &take_modes) { } virtual void OnSerializeCheck(Serialize::Type *) { } virtual void OnSerializableConstruct(Serializable *) { } @@ -1025,6 +1030,13 @@ class CoreExport Module : public Extensible * @param cm The mode */ virtual EventReturn OnCanSet(User *u, const ChannelMode *cm) { return EVENT_CONTINUE; } + + virtual EventReturn OnCheckDelete(Channel *) { return EVENT_CONTINUE; } + + /** Called every options:expiretimeout seconds. Should be used to expire nicks, + * channels, etc. + */ + virtual void OnExpireTick() { } }; /** Implementation-specific flags which may be set in ModuleManager::Attach() @@ -1036,13 +1048,13 @@ enum Implementation I_OnPreNickExpire, I_OnNickExpire, I_OnNickForbidden, I_OnNickGroup, I_OnNickLogout, I_OnNickIdentify, I_OnNickDrop, I_OnNickRegister, I_OnNickSuspended, I_OnNickUnsuspended, I_OnDelNick, I_OnNickCoreCreate, I_OnDelCore, I_OnChangeCoreDisplay, I_OnNickClearAccess, I_OnNickAddAccess, I_OnNickEraseAccess, I_OnNickClearCert, I_OnNickAddCert, I_OnNickEraseCert, - I_OnNickInfo, I_OnCheckAuthentication, I_OnNickUpdate, I_OnSetNickOption, + I_OnNickInfo, I_OnCheckAuthentication, I_OnNickUpdate, I_OnSetNickOption, I_OnUserLogin, /* ChanServ */ I_OnChanSuspend, I_OnChanDrop, I_OnPreChanExpire, I_OnChanExpire, I_OnAccessAdd, I_OnAccessDel, I_OnAccessClear, I_OnLevelChange, I_OnChanRegistered, I_OnChanUnsuspend, I_OnCreateChan, I_OnDelChan, I_OnChannelCreate, - I_OnChannelDelete, I_OnAkickAdd, I_OnAkickDel, I_OnCheckKick, I_OnCheckModes, - I_OnChanInfo, I_OnCheckPriv, I_OnGroupCheckPriv, I_OnSetChannelOption, I_OnChannelSync, I_OnSetCorrectModes, + I_OnAkickAdd, I_OnAkickDel, I_OnCheckKick, I_OnCheckModes, + I_OnChanInfo, I_OnCheckPriv, I_OnGroupCheckPriv, I_OnSetChannelOption, I_OnSetCorrectModes, /* BotServ */ I_OnCreateBot, I_OnDelBot, @@ -1055,6 +1067,9 @@ enum Implementation /* MemoServ */ I_OnMemoSend, I_OnMemoDel, + /* Channels */ + I_OnChannelModeSet, I_OnChannelModeUnset, I_OnChannelDelete, I_OnChannelSync, I_OnCheckDelete, + /* Users */ I_OnUserConnect, I_OnUserNickChange, I_OnUserQuit, I_OnPreUserLogoff, I_OnPostUserLogoff, I_OnJoinChannel, I_OnPrePartChannel, I_OnPartChannel, I_OnLeaveChannel, I_OnFingerprint, I_OnUserAway, I_OnInvite, @@ -1074,9 +1089,9 @@ enum Implementation I_OnPreHelp, I_OnPostHelp, I_OnPreCommand, I_OnPostCommand, I_OnRestart, I_OnShutdown, I_OnServerQuit, I_OnTopicUpdated, I_OnEncrypt, I_OnDecrypt, - I_OnChannelModeSet, I_OnChannelModeUnset, I_OnUserModeSet, I_OnUserModeUnset, I_OnChannelModeAdd, I_OnUserModeAdd, + I_OnUserModeSet, I_OnUserModeUnset, I_OnChannelModeAdd, I_OnUserModeAdd, I_OnMLock, I_OnUnMLock, I_OnServerSync, I_OnUplinkSync, I_OnBotPrivmsg, I_OnPrivmsg, I_OnLog, I_OnDnsRequest, - I_OnMessage, I_OnCanSet, + I_OnMessage, I_OnCanSet, I_OnExpireTick, I_OnSerializeCheck, I_OnSerializableConstruct, I_OnSerializableDestruct, I_OnSerializableUpdate, I_OnSerializeTypeCreate, I_END diff --git a/include/modules/chanserv.h b/include/modules/chanserv.h deleted file mode 100644 index e1c3849fd..000000000 --- a/include/modules/chanserv.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef CHANSERV_H -#define CHANSERV_H - -class ChanServService : public Service -{ - public: - ChanServService(Module *m) : Service(m, "ChanServService", "ChanServ") - { - } - - /* Have ChanServ hold the channel, that is, join and set +nsti and wait - * for a few minutes so no one can join or rejoin. - */ - virtual void Hold(Channel *c) = 0; -}; - -#endif // CHANSERV_H - diff --git a/include/modules/global.h b/include/modules/global.h deleted file mode 100644 index 52afc4a23..000000000 --- a/include/modules/global.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef GLOBAL_H -#define GLOBAL_H - -class GlobalService : public Service -{ - public: - GlobalService(Module *m) : Service(m, "GlobalService", "Global") - { - } - - /** Send out a global message to all users - * @param sender Our client which should send the global - * @param source The sender of the global - * @param message The message - */ - virtual void SendGlobal(const BotInfo *sender, const Anope::string &source, const Anope::string &message) = 0; -}; - -#endif // GLOBAL_H - diff --git a/include/modules/memoserv.h b/include/modules/memoserv.h deleted file mode 100644 index d35d3f8a0..000000000 --- a/include/modules/memoserv.h +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef MEMOSERV_H -#define MEMOSERV_H - -class MemoServService : public Service -{ - public: - enum MemoResult - { - MEMO_SUCCESS, - MEMO_INVALID_TARGET, - MEMO_TOO_FAST, - MEMO_TARGET_FULL - }; - - MemoServService(Module *m) : Service(m, "MemoServService", "MemoServ") - { - } - - /** Sends a memo. - * @param source The source of the memo, can be anythin. - * @param target The target of the memo, nick or channel. - * @param message Memo text - * @param force true to force the memo, restrictions/delays etc are not checked - */ - virtual MemoResult Send(const Anope::string &source, const Anope::string &target, const Anope::string &message, bool force = false) = 0; - - /** Check for new memos and notify the user if there are any - * @param u The user - */ - virtual void Check(User *u) = 0; -}; - -#endif // MEMOSERV_H - diff --git a/include/modules/nickserv.h b/include/modules/nickserv.h deleted file mode 100644 index b20d6ebd1..000000000 --- a/include/modules/nickserv.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef NICKSERV_H -#define NICKSERV_H - -class NickServService : public Service -{ - public: - NickServService(Module *m) : Service(m, "NickServService", "NickServ") - { - } - - virtual void Validate(User *u) = 0; - virtual void Login(User *u, NickAlias *na) = 0; -}; - -#endif // NICKSERV_H - diff --git a/include/modules/pseudoclients/chanserv.h b/include/modules/pseudoclients/chanserv.h new file mode 100644 index 000000000..e1c3849fd --- /dev/null +++ b/include/modules/pseudoclients/chanserv.h @@ -0,0 +1,18 @@ +#ifndef CHANSERV_H +#define CHANSERV_H + +class ChanServService : public Service +{ + public: + ChanServService(Module *m) : Service(m, "ChanServService", "ChanServ") + { + } + + /* Have ChanServ hold the channel, that is, join and set +nsti and wait + * for a few minutes so no one can join or rejoin. + */ + virtual void Hold(Channel *c) = 0; +}; + +#endif // CHANSERV_H + diff --git a/include/modules/pseudoclients/global.h b/include/modules/pseudoclients/global.h new file mode 100644 index 000000000..52afc4a23 --- /dev/null +++ b/include/modules/pseudoclients/global.h @@ -0,0 +1,20 @@ +#ifndef GLOBAL_H +#define GLOBAL_H + +class GlobalService : public Service +{ + public: + GlobalService(Module *m) : Service(m, "GlobalService", "Global") + { + } + + /** Send out a global message to all users + * @param sender Our client which should send the global + * @param source The sender of the global + * @param message The message + */ + virtual void SendGlobal(const BotInfo *sender, const Anope::string &source, const Anope::string &message) = 0; +}; + +#endif // GLOBAL_H + diff --git a/include/modules/pseudoclients/memoserv.h b/include/modules/pseudoclients/memoserv.h new file mode 100644 index 000000000..d35d3f8a0 --- /dev/null +++ b/include/modules/pseudoclients/memoserv.h @@ -0,0 +1,34 @@ +#ifndef MEMOSERV_H +#define MEMOSERV_H + +class MemoServService : public Service +{ + public: + enum MemoResult + { + MEMO_SUCCESS, + MEMO_INVALID_TARGET, + MEMO_TOO_FAST, + MEMO_TARGET_FULL + }; + + MemoServService(Module *m) : Service(m, "MemoServService", "MemoServ") + { + } + + /** Sends a memo. + * @param source The source of the memo, can be anythin. + * @param target The target of the memo, nick or channel. + * @param message Memo text + * @param force true to force the memo, restrictions/delays etc are not checked + */ + virtual MemoResult Send(const Anope::string &source, const Anope::string &target, const Anope::string &message, bool force = false) = 0; + + /** Check for new memos and notify the user if there are any + * @param u The user + */ + virtual void Check(User *u) = 0; +}; + +#endif // MEMOSERV_H + diff --git a/include/modules/pseudoclients/nickserv.h b/include/modules/pseudoclients/nickserv.h new file mode 100644 index 000000000..c0238ecfc --- /dev/null +++ b/include/modules/pseudoclients/nickserv.h @@ -0,0 +1,17 @@ +#ifndef NICKSERV_H +#define NICKSERV_H + +class NickServService : public Service +{ + public: + NickServService(Module *m) : Service(m, "NickServService", "NickServ") + { + } + + virtual void Validate(User *u) = 0; + virtual void Collide(User *u, NickAlias *na) = 0; + virtual void Release(NickAlias *na) = 0; +}; + +#endif // NICKSERV_H + diff --git a/include/regchannel.h b/include/regchannel.h index 91cc90ffa..08fae12b3 100644 --- a/include/regchannel.h +++ b/include/regchannel.h @@ -399,17 +399,6 @@ class CoreExport ChannelInfo : public Serializable, public Extensible */ bool CheckKick(User *user); - /** Check the channel topic - * If topic lock is enabled will change the topic back, else it records - * the new topic in the ChannelInfo - */ - void CheckTopic(); - - /** Restore the channel topic, used on channel creation when not syncing with the uplink - * and after uplink sync - */ - void RestoreTopic(); - /** Get the level for a privilege * @param priv The privilege name * @return the level diff --git a/include/users.h b/include/users.h index 00ff5e410..768b6dfa1 100644 --- a/include/users.h +++ b/include/users.h @@ -187,12 +187,6 @@ class CoreExport User : public virtual Base, public Extensible, public CommandRe void SendMessage(const BotInfo *source, const char *fmt, ...); void SendMessage(const BotInfo *source, const Anope::string &msg) anope_override; - /** Collide a nick - * See the comment in users.cpp - * @param na The nick - */ - void Collide(NickAlias *na); - /** Identify the user to the Nick * updates last_seen, logs the user in, * send messages, checks for mails, set vhost and more diff --git a/modules/commands/bs_assign.cpp b/modules/commands/bs_assign.cpp index bbac6e689..9a0b638c7 100644 --- a/modules/commands/bs_assign.cpp +++ b/modules/commands/bs_assign.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" class CommandBSAssign : public Command diff --git a/modules/commands/bs_badwords.cpp b/modules/commands/bs_badwords.cpp index 31dee8f8e..22fa74714 100644 --- a/modules/commands/bs_badwords.cpp +++ b/modules/commands/bs_badwords.cpp @@ -215,7 +215,6 @@ class CommandBSBadwords : public Command ci->ClearBadWords(); source.Reply(_("Bad words list is now empty.")); - return; } public: diff --git a/modules/commands/bs_bot.cpp b/modules/commands/bs_bot.cpp index 16fd9f2f2..aa3cf378d 100644 --- a/modules/commands/bs_bot.cpp +++ b/modules/commands/bs_bot.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" class CommandBSBot : public Command diff --git a/modules/commands/bs_botlist.cpp b/modules/commands/bs_botlist.cpp index e682bd47d..2714c3fdc 100644 --- a/modules/commands/bs_botlist.cpp +++ b/modules/commands/bs_botlist.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" class CommandBSBotList : public Command diff --git a/modules/commands/bs_control.cpp b/modules/commands/bs_control.cpp index 32e9392d7..94186c13b 100644 --- a/modules/commands/bs_control.cpp +++ b/modules/commands/bs_control.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" class CommandBSSay : public Command diff --git a/modules/commands/bs_info.cpp b/modules/commands/bs_info.cpp index 6c017dc55..8bbfd0b18 100644 --- a/modules/commands/bs_info.cpp +++ b/modules/commands/bs_info.cpp @@ -10,8 +10,6 @@ * * */ -/*************************************************************************/ - #include "module.h" class CommandBSInfo : public Command diff --git a/modules/commands/bs_kick.cpp b/modules/commands/bs_kick.cpp index 5c1bdc6a8..4b869421d 100644 --- a/modules/commands/bs_kick.cpp +++ b/modules/commands/bs_kick.cpp @@ -74,7 +74,7 @@ class CommandBSKickBase : public Command virtual bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override = 0; protected: - bool CheckArguments(CommandSource &source, const std::vector ¶ms, ChannelInfo* &ci) anope_override + bool CheckArguments(CommandSource &source, const std::vector ¶ms, ChannelInfo* &ci) { const Anope::string &chan = params[0]; const Anope::string &option = params[1]; diff --git a/modules/commands/cs_access.cpp b/modules/commands/cs_access.cpp index f8356b383..64b2386fb 100644 --- a/modules/commands/cs_access.cpp +++ b/modules/commands/cs_access.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" static std::map defaultLevels; diff --git a/modules/commands/cs_akick.cpp b/modules/commands/cs_akick.cpp index 51665d309..1cce6afbe 100644 --- a/modules/commands/cs_akick.cpp +++ b/modules/commands/cs_akick.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" class CommandCSAKick : public Command diff --git a/modules/commands/cs_ban.cpp b/modules/commands/cs_ban.cpp index c3fffecd9..fbd9833a5 100644 --- a/modules/commands/cs_ban.cpp +++ b/modules/commands/cs_ban.cpp @@ -9,7 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ #include "module.h" diff --git a/modules/commands/cs_clone.cpp b/modules/commands/cs_clone.cpp index e4c1ac7f6..d7045123f 100644 --- a/modules/commands/cs_clone.cpp +++ b/modules/commands/cs_clone.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" class CommandCSClone : public Command @@ -75,14 +73,7 @@ public: target_ci->c->CheckModes(); - target_ci->c->SetCorrectModes(u, true, true); - - /* Mark the channel as persistent */ - if (target_ci->c->HasMode("PERM")) - target_ci->ExtendMetadata("PERSIST"); - /* Persist may be in def cflags, set it here */ - else if (target_ci->HasExt("PERSIST")) - target_ci->c->SetMode(NULL, "PERM"); + target_ci->c->SetCorrectModes(u, true); } if (target_ci->c && !target_ci->c->topic.empty()) diff --git a/modules/commands/cs_drop.cpp b/modules/commands/cs_drop.cpp index 433e35799..998dd8ab0 100644 --- a/modules/commands/cs_drop.cpp +++ b/modules/commands/cs_drop.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" class CommandCSDrop : public Command diff --git a/modules/commands/cs_enforce.cpp b/modules/commands/cs_enforce.cpp index 0579ebb2b..e40676186 100644 --- a/modules/commands/cs_enforce.cpp +++ b/modules/commands/cs_enforce.cpp @@ -33,7 +33,7 @@ class CommandCSEnforce : public Command { ChanUserContainer *uc = it->second; - ci->c->SetCorrectModes(uc->user, false, false); + ci->c->SetCorrectModes(uc->user, false); } if (!hadsecureops) diff --git a/modules/commands/cs_entrymsg.cpp b/modules/commands/cs_entrymsg.cpp index da764d81c..c5e31f122 100644 --- a/modules/commands/cs_entrymsg.cpp +++ b/modules/commands/cs_entrymsg.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" struct EntryMsg : Serializable diff --git a/modules/commands/cs_fantasy_stats.cpp b/modules/commands/cs_fantasy_stats.cpp index b8c83e73b..a7324bf9f 100644 --- a/modules/commands/cs_fantasy_stats.cpp +++ b/modules/commands/cs_fantasy_stats.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" #include "modules/sql.h" diff --git a/modules/commands/cs_fantasy_top.cpp b/modules/commands/cs_fantasy_top.cpp index 7f82ba221..ca2e67ab9 100644 --- a/modules/commands/cs_fantasy_top.cpp +++ b/modules/commands/cs_fantasy_top.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" #include "modules/sql.h" diff --git a/modules/commands/cs_flags.cpp b/modules/commands/cs_flags.cpp index 18b72ef29..4867b9029 100644 --- a/modules/commands/cs_flags.cpp +++ b/modules/commands/cs_flags.cpp @@ -9,11 +9,8 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" -static ServiceReference chanserv("ChanServService", "ChanServ"); static std::map defaultFlags; class FlagsChanAccess : public ChanAccess diff --git a/modules/commands/cs_getkey.cpp b/modules/commands/cs_getkey.cpp index ec64b45f8..d22cd2319 100644 --- a/modules/commands/cs_getkey.cpp +++ b/modules/commands/cs_getkey.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" class CommandCSGetKey : public Command @@ -50,7 +48,6 @@ class CommandCSGetKey : public Command Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci); source.Reply(_("Key for channel \002%s\002 is \002%s\002."), chan.c_str(), key.c_str()); - return; } bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override diff --git a/modules/commands/cs_info.cpp b/modules/commands/cs_info.cpp index 61511aaaf..3f9a014bb 100644 --- a/modules/commands/cs_info.cpp +++ b/modules/commands/cs_info.cpp @@ -9,12 +9,8 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" -static ServiceReference chanserv("ChanServService", "ChanServ"); - class CommandCSInfo : public Command { void CheckOptStr(Anope::string &buf, const Anope::string &opt, const char *str, const ChannelInfo *ci, const NickCore *nc) @@ -116,8 +112,6 @@ class CommandCSInfo : public Command for (unsigned i = 0; i < replies.size(); ++i) source.Reply(replies[i]); - - return; } bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override diff --git a/modules/commands/cs_invite.cpp b/modules/commands/cs_invite.cpp index 4b204bfc4..d5d42c65f 100644 --- a/modules/commands/cs_invite.cpp +++ b/modules/commands/cs_invite.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" class CommandCSInvite : public Command @@ -83,7 +81,6 @@ class CommandCSInvite : public Command } u2->SendMessage(ci->WhoSends(), _("You have been invited to \002%s\002."), c->name.c_str()); } - return; } bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override diff --git a/modules/commands/cs_kick.cpp b/modules/commands/cs_kick.cpp index f1a632af3..8d6749540 100644 --- a/modules/commands/cs_kick.cpp +++ b/modules/commands/cs_kick.cpp @@ -9,12 +9,8 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" -static ServiceReference chanserv("ChanServService", "ChanServ"); - class CommandCSKick : public Command { public: diff --git a/modules/commands/cs_list.cpp b/modules/commands/cs_list.cpp index 13492c007..9e2df0a62 100644 --- a/modules/commands/cs_list.cpp +++ b/modules/commands/cs_list.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" class CommandCSList : public Command @@ -117,7 +115,6 @@ class CommandCSList : public Command source.Reply(replies[i]); source.Reply(_("End of list - %d/%d matches shown."), nchans > listmax ? listmax : nchans, nchans); - return; } bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override diff --git a/modules/commands/cs_log.cpp b/modules/commands/cs_log.cpp index b3ad62859..a7987a740 100644 --- a/modules/commands/cs_log.cpp +++ b/modules/commands/cs_log.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" class CommandCSLog : public Command diff --git a/modules/commands/cs_mode.cpp b/modules/commands/cs_mode.cpp index ef43d1061..895bd3d5b 100644 --- a/modules/commands/cs_mode.cpp +++ b/modules/commands/cs_mode.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" class CommandCSMode : public Command diff --git a/modules/commands/cs_register.cpp b/modules/commands/cs_register.cpp index ff2fbf69c..4d4bc9353 100644 --- a/modules/commands/cs_register.cpp +++ b/modules/commands/cs_register.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" class CommandCSRegister : public Command @@ -74,19 +72,11 @@ class CommandCSRegister : public Command { c->CheckModes(); if (u) - c->SetCorrectModes(u, true, true); - - /* Mark the channel as persistent */ - if (c->HasMode("PERM")) - ci->Extend("PERSIST"); - /* Persist may be in def cflags, set it here */ - else if (ci->HasExt("PERSIST")) - c->SetMode(NULL, "PERM"); + c->SetCorrectModes(u, true); } FOREACH_MOD(I_OnChanRegistered, OnChanRegistered(ci)); } - return; } bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override @@ -103,7 +93,8 @@ class CommandCSRegister : public Command "\"founder\" of the channel. The channel founder is allowed\n" "to change all of the channel settings for the channel;\n" "%s will also automatically give the founder\n" - "channel-operator privileges when s/he enters the channel.")); + "channel-operator privileges when s/he enters the channel."), + source.service->nick.c_str(), source.service->nick.c_str()); BotInfo *bi; Anope::string cmd; if (Command::FindCommandFromService("chanserv/access", bi, cmd)) diff --git a/modules/commands/cs_seen.cpp b/modules/commands/cs_seen.cpp index 610ad4475..aacd3c168 100644 --- a/modules/commands/cs_seen.cpp +++ b/modules/commands/cs_seen.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" @@ -290,14 +288,28 @@ class CommandSeen : public Command } }; -class DataBasePurger : public Timer +class CSSeen : public Module { + Serialize::Type seeninfo_type; + CommandSeen commandseen; + CommandOSSeen commandosseen; public: - DataBasePurger(Module *o) : Timer(o, 300, Anope::CurTime, true) { } + CSSeen(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), seeninfo_type("SeenInfo", SeenInfo::Unserialize), commandseen(this), commandosseen(this) + { + + Implementation eventlist[] = { I_OnExpireTick, + I_OnUserConnect, + I_OnUserNickChange, + I_OnUserQuit, + I_OnJoinChannel, + I_OnPartChannel, + I_OnPreUserKicked }; + ModuleManager::Attach(eventlist, this, sizeof(eventlist) / sizeof(Implementation)); + } - void Tick(time_t) anope_override + void OnExpireTick() anope_override { - size_t previous_size = database.size(), purgetime = Config->GetModule(this->GetOwner())->Get("purgetime"); + size_t previous_size = database.size(), purgetime = Config->GetModule(this)->Get("purgetime"); if (!purgetime) purgetime = Anope::DoTime("30d"); for (database_map::iterator it = database.begin(), it_end = database.end(); it != it_end;) @@ -314,37 +326,6 @@ class DataBasePurger : public Timer } Log(LOG_DEBUG) << "cs_seen: Purged database, checked " << previous_size << " nicks and removed " << (previous_size - database.size()) << " old entries."; } -}; - -class CSSeen : public Module -{ - Serialize::Type seeninfo_type; - CommandSeen commandseen; - CommandOSSeen commandosseen; - DataBasePurger purger; - public: - CSSeen(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), seeninfo_type("SeenInfo", SeenInfo::Unserialize), commandseen(this), commandosseen(this), purger(this) - { - - Implementation eventlist[] = { I_OnReload, - I_OnUserConnect, - I_OnUserNickChange, - I_OnUserQuit, - I_OnJoinChannel, - I_OnPartChannel, - I_OnPreUserKicked }; - ModuleManager::Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation)); - } - - void OnReload(Configuration::Conf *conf) anope_override - { - time_t expiretimeout = conf->GetModule(this)->Get("expiretimeout"); - if (!expiretimeout) - expiretimeout = Anope::DoTime("1d"); - - if (purger.GetSecs() != expiretimeout) - purger.SetSecs(expiretimeout); - } void OnUserConnect(User *u, bool &exempt) anope_override { diff --git a/modules/commands/cs_set.cpp b/modules/commands/cs_set.cpp index 028ff0069..45373e254 100644 --- a/modules/commands/cs_set.cpp +++ b/modules/commands/cs_set.cpp @@ -23,7 +23,6 @@ class CommandCSSet : public Command void Execute(CommandSource &source, const std::vector ¶ms) anope_override { this->OnSyntaxError(source, ""); - return; } bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override @@ -515,11 +514,13 @@ class CommandCSSetPersist : public Command */ if (!ci->bi && !cm) { + BotInfo *ChanServ = Config->GetClient("ChanServ"); if (!ChanServ) { source.Reply(_("ChanServ is required to enable persist on this network.")); return; } + ChanServ->Assign(NULL, ci); if (!ci->c->FindUser(ChanServ)) { @@ -559,6 +560,8 @@ class CommandCSSetPersist : public Command /* No channel mode, no BotServ, but using ChanServ as the botserv bot * which was assigned when persist was set on */ + BotInfo *ChanServ = Config->GetClient("ChanServ"), + *BotServ = Config->GetClient("BotServ"); if (!cm && !BotServ && ci->bi) { if (!ChanServ) @@ -576,8 +579,6 @@ class CommandCSSetPersist : public Command } else this->OnSyntaxError(source, "PERSIST"); - - return; } bool OnHelp(CommandSource &source, const Anope::string &) anope_override @@ -1105,7 +1106,6 @@ class CSSet : public Module CommandCSSetAutoOp commandcssetautoop; CommandCSSetBanType commandcssetbantype; CommandCSSetChanstats commandcssetchanstats; - bool CSDefChanstats; CommandCSSetDescription commandcssetdescription; CommandCSSetFounder commandcssetfounder; CommandCSSetKeepTopic commandcssetkeeptopic; @@ -1123,13 +1123,14 @@ class CSSet : public Module public: CSSet(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), commandcsset(this), commandcssetautoop(this), commandcssetbantype(this), commandcssetchanstats(this), - CSDefChanstats(false), commandcssetdescription(this), commandcssetfounder(this), commandcssetkeeptopic(this), + commandcssetdescription(this), commandcssetfounder(this), commandcssetkeeptopic(this), commandcssetpeace(this), commandcssetpersist(this), commandcssetprivate(this), commandcssetrestricted(this), commandcssetsecure(this), commandcssetsecurefounder(this), commandcssetsecureops(this), commandcssetsignkick(this), commandcssetsuccessor(this), commandcssetnoexpire(this) { - Implementation i[] = { I_OnCheckKick, I_OnDelChan }; + Implementation i[] = { I_OnCheckKick, I_OnDelChan, I_OnChannelModeSet, I_OnChannelModeUnset, I_OnCheckDelete, I_OnJoinChannel, + I_OnSetCorrectModes }; ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); } @@ -1148,6 +1149,62 @@ class CSSet : public Module { if (ci->c && ci->HasExt("PERSIST")) ci->c->RemoveMode(ci->WhoSends(), "PERM", "", false); + ci->Shrink("PERSIST"); + } + + EventReturn OnChannelModeSet(Channel *c, MessageSource &setter, const Anope::string &mname, const Anope::string ¶m) anope_override + { + /* Channel mode +P or so was set, mark this channel as persistent */ + if (mname == "PERM" && c->ci) + { + c->ci->ExtendMetadata("PERSIST"); + } + + return EVENT_CONTINUE; + } + + EventReturn OnChannelModeUnset(Channel *c, MessageSource &setter, const Anope::string &mname, const Anope::string ¶m) anope_override + { + if (mname == "PERM") + { + if (c->ci) + c->ci->Shrink("PERSIST"); + + if (c->users.empty() && !c->syncing && c->CheckDelete()) + { + delete c; + return EVENT_STOP; + } + } + + return EVENT_CONTINUE; + } + + EventReturn OnCheckDelete(Channel *c) anope_override + { + if (c->ci && c->ci->HasExt("PERSIST")) + return EVENT_STOP; + return EVENT_CONTINUE; + } + + void OnJoinChannel(User *u, Channel *c) anope_override + { + if (c->ci && c->ci->HasExt("PERSIST") && c->creation_time > c->ci->time_registered) + { + Log(LOG_DEBUG) << "Changing TS of " << c->name << " from " << c->creation_time << " to " << c->ci->time_registered; + c->creation_time = c->ci->time_registered; + IRCD->SendChannel(c); + c->Reset(); + } + } + + void OnSetCorrectModes(User *user, Channel *chan, AccessGroup &access, bool &give_modes, bool &take_modes) anope_override + { + if (chan->ci) + { + give_modes &= !chan->ci->HasExt("NOAUTOOP"); + take_modes |= chan->ci->HasExt("SECUREOPS"); + } } }; diff --git a/modules/commands/cs_set_misc.cpp b/modules/commands/cs_set_misc.cpp index 9402f5b78..5f1359f18 100644 --- a/modules/commands/cs_set_misc.cpp +++ b/modules/commands/cs_set_misc.cpp @@ -8,8 +8,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" static std::map descriptions; diff --git a/modules/commands/cs_status.cpp b/modules/commands/cs_status.cpp index 50f7080ac..5529e6148 100644 --- a/modules/commands/cs_status.cpp +++ b/modules/commands/cs_status.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" class CommandCSStatus : public Command diff --git a/modules/commands/cs_suspend.cpp b/modules/commands/cs_suspend.cpp index e19710e60..88a369e58 100644 --- a/modules/commands/cs_suspend.cpp +++ b/modules/commands/cs_suspend.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" class CommandCSSuspend : public Command @@ -205,7 +203,7 @@ class CSSuspend : public Module ci->Shrink("suspend:reason"); ci->Shrink("suspend:time"); - Log(LOG_NORMAL, "expire", ChanServ) << "Expiring suspend for " << ci->name; + Log(this) << "Expiring suspend for " << ci->name; } } catch (const ConvertException &) { } diff --git a/modules/commands/cs_sync.cpp b/modules/commands/cs_sync.cpp index 9e6dfb0ec..4b854bd45 100644 --- a/modules/commands/cs_sync.cpp +++ b/modules/commands/cs_sync.cpp @@ -35,7 +35,7 @@ class CommandCSSync : public Command Log(LOG_COMMAND, source, this, ci); for (Channel::ChanUserList::iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it) - ci->c->SetCorrectModes(it->second->user, true, false); + ci->c->SetCorrectModes(it->second->user, true); source.Reply(_("All user modes on \002%s\002 have been synced."), ci->name.c_str()); } diff --git a/modules/commands/cs_unban.cpp b/modules/commands/cs_unban.cpp index 8b90ee93d..59d2dfeaa 100644 --- a/modules/commands/cs_unban.cpp +++ b/modules/commands/cs_unban.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" class CommandCSUnban : public Command diff --git a/modules/commands/cs_updown.cpp b/modules/commands/cs_updown.cpp index 8a8f3f336..ab00d5d5d 100644 --- a/modules/commands/cs_updown.cpp +++ b/modules/commands/cs_updown.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" class CommandCSUp : public Command @@ -31,7 +29,7 @@ class CommandCSUp : public Command for (User::ChanUserList::iterator it = source.GetUser()->chans.begin(); it != source.GetUser()->chans.end(); ++it) { Channel *c = it->second->chan; - c->SetCorrectModes(source.GetUser(), true, false); + c->SetCorrectModes(source.GetUser(), true); } } else @@ -58,6 +56,11 @@ class CommandCSUp : public Command source.Reply(NICK_X_NOT_IN_USE, nick.c_str()); return; } + else if (!u->FindChannel(c)) + { + source.Reply(NICK_X_NOT_ON_CHAN, nick.c_str(), channel.c_str()); + return; + } else if (source.GetUser() && u != source.GetUser() && c->ci->HasExt("PEACE")) { if (c->ci->AccessFor(u) > c->ci->AccessFor(source.GetUser())) @@ -67,7 +70,7 @@ class CommandCSUp : public Command } } - c->SetCorrectModes(u, true, false); + c->SetCorrectModes(u, true); } } @@ -136,6 +139,11 @@ class CommandCSDown : public Command source.Reply(NICK_X_NOT_IN_USE, nick.c_str()); return; } + else if (!u->FindChannel(c)) + { + source.Reply(NICK_X_NOT_ON_CHAN, nick.c_str(), channel.c_str()); + return; + } else if (source.GetUser() && u != source.GetUser() && c->ci->HasExt("PEACE")) { if (c->ci->AccessFor(u) > c->ci->AccessFor(source.GetUser())) diff --git a/modules/commands/gl_global.cpp b/modules/commands/gl_global.cpp index 70dd4d324..a02c1cccd 100644 --- a/modules/commands/gl_global.cpp +++ b/modules/commands/gl_global.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" class CommandGLGlobal : public Command @@ -33,7 +31,7 @@ class CommandGLGlobal : public Command else { Log(LOG_ADMIN, source, this); - GService->SendGlobal(Global, source.GetNick(), msg); + GService->SendGlobal(NULL, source.GetNick(), msg); } } diff --git a/modules/commands/help.cpp b/modules/commands/help.cpp index eaf45ebf4..47ce98825 100644 --- a/modules/commands/help.cpp +++ b/modules/commands/help.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" class CommandHelp : public Command diff --git a/modules/commands/hs_del.cpp b/modules/commands/hs_del.cpp index ad9347ce0..1fa4f7b31 100644 --- a/modules/commands/hs_del.cpp +++ b/modules/commands/hs_del.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" class CommandHSDel : public Command diff --git a/modules/commands/hs_group.cpp b/modules/commands/hs_group.cpp index 13062fc9e..c07ce297a 100644 --- a/modules/commands/hs_group.cpp +++ b/modules/commands/hs_group.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" class CommandHSGroup : public Command diff --git a/modules/commands/hs_list.cpp b/modules/commands/hs_list.cpp index 6bf6d49a9..aa712008f 100644 --- a/modules/commands/hs_list.cpp +++ b/modules/commands/hs_list.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" class CommandHSList : public Command diff --git a/modules/commands/hs_off.cpp b/modules/commands/hs_off.cpp index 13a64c9d9..433fff675 100644 --- a/modules/commands/hs_off.cpp +++ b/modules/commands/hs_off.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" class CommandHSOff : public Command diff --git a/modules/commands/hs_on.cpp b/modules/commands/hs_on.cpp index fb3ca1396..95e685309 100644 --- a/modules/commands/hs_on.cpp +++ b/modules/commands/hs_on.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" class CommandHSOn : public Command diff --git a/modules/commands/hs_request.cpp b/modules/commands/hs_request.cpp index 99c5a4811..d12973e01 100644 --- a/modules/commands/hs_request.cpp +++ b/modules/commands/hs_request.cpp @@ -193,7 +193,7 @@ class CommandHSActivate : public Command FOREACH_MOD(I_OnSetVhost, OnSetVhost(na)); if (Config->GetModule(this->owner)->Get("memouser") && memoserv) - memoserv->Send(HostServ->nick, na->nick, _("[auto memo] Your requested vHost has been approved."), true); + memoserv->Send(source.service->nick, na->nick, _("[auto memo] Your requested vHost has been approved."), true); source.Reply(_("vHost for %s has been activated."), na->nick.c_str()); Log(LOG_COMMAND, source, this) << "for " << na->nick << " for vhost " << (!req->ident.empty() ? req->ident + "@" : "") << req->host; @@ -244,7 +244,7 @@ class CommandHSReject : public Command else message = _("[auto memo] Your requested vHost has been rejected."); - memoserv->Send(HostServ->nick, nick, message, true); + memoserv->Send(source.service->nick, nick, message, true); } source.Reply(_("vHost for %s has been rejected."), nick.c_str()); @@ -380,7 +380,7 @@ static void req_send_memos(Module *me, CommandSource &source, const Anope::strin Anope::string message = Anope::printf(_("[auto memo] vHost \002%s\002 has been requested by %s."), host.c_str(), source.GetNick().c_str()); - memoserv->Send(HostServ->nick, na->nick, message, true); + memoserv->Send(source.service->nick, na->nick, message, true); } } diff --git a/modules/commands/hs_set.cpp b/modules/commands/hs_set.cpp index 8e83ae8a8..834ac5fc1 100644 --- a/modules/commands/hs_set.cpp +++ b/modules/commands/hs_set.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" class CommandHSSet : public Command diff --git a/modules/commands/ms_cancel.cpp b/modules/commands/ms_cancel.cpp index 2ab605f40..cf1a0809f 100644 --- a/modules/commands/ms_cancel.cpp +++ b/modules/commands/ms_cancel.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" class CommandMSCancel : public Command diff --git a/modules/commands/ms_check.cpp b/modules/commands/ms_check.cpp index 9a24e9973..b912777fe 100644 --- a/modules/commands/ms_check.cpp +++ b/modules/commands/ms_check.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" class CommandMSCheck : public Command diff --git a/modules/commands/ms_del.cpp b/modules/commands/ms_del.cpp index 18927f8ee..dac5ae43e 100644 --- a/modules/commands/ms_del.cpp +++ b/modules/commands/ms_del.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" class MemoDelCallback : public NumberList diff --git a/modules/commands/ms_ignore.cpp b/modules/commands/ms_ignore.cpp index 056b20128..28dd6514d 100644 --- a/modules/commands/ms_ignore.cpp +++ b/modules/commands/ms_ignore.cpp @@ -9,13 +9,8 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - - #include "module.h" -static ServiceReference MemoServService("MemoServService", "MemoServ"); - class CommandMSIgnore : public Command { public: @@ -29,10 +24,6 @@ class CommandMSIgnore : public Command void Execute(CommandSource &source, const std::vector ¶ms) anope_override { - if (!MemoServService) - return; - - Anope::string channel = params[0]; Anope::string command = (params.size() > 1 ? params[1] : ""); Anope::string param = (params.size() > 2 ? params[2] : ""); @@ -123,9 +114,6 @@ class MSIgnore : public Module MSIgnore(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), commandmsignore(this) { - - if (!MemoServService) - throw ModuleException("No MemoServ!"); } }; diff --git a/modules/commands/ms_info.cpp b/modules/commands/ms_info.cpp index 517e6b1ac..67a504117 100644 --- a/modules/commands/ms_info.cpp +++ b/modules/commands/ms_info.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" class CommandMSInfo : public Command diff --git a/modules/commands/ms_list.cpp b/modules/commands/ms_list.cpp index 8b7ebeb62..dff88667b 100644 --- a/modules/commands/ms_list.cpp +++ b/modules/commands/ms_list.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" class CommandMSList : public Command diff --git a/modules/commands/ms_read.cpp b/modules/commands/ms_read.cpp index b25b4fc4b..8c1ebc9ba 100644 --- a/modules/commands/ms_read.cpp +++ b/modules/commands/ms_read.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" static ServiceReference MemoServService("MemoServService", "MemoServ"); diff --git a/modules/commands/ms_rsend.cpp b/modules/commands/ms_rsend.cpp index a9372c328..235fb06d0 100644 --- a/modules/commands/ms_rsend.cpp +++ b/modules/commands/ms_rsend.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" namespace diff --git a/modules/commands/ms_send.cpp b/modules/commands/ms_send.cpp index d4d63a383..87603025a 100644 --- a/modules/commands/ms_send.cpp +++ b/modules/commands/ms_send.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" namespace diff --git a/modules/commands/ms_sendall.cpp b/modules/commands/ms_sendall.cpp index b19b96036..803fbf6ba 100644 --- a/modules/commands/ms_sendall.cpp +++ b/modules/commands/ms_sendall.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" namespace diff --git a/modules/commands/ms_set.cpp b/modules/commands/ms_set.cpp index d1edaecca..9bf63b15d 100644 --- a/modules/commands/ms_set.cpp +++ b/modules/commands/ms_set.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" class CommandMSSet : public Command @@ -20,6 +18,10 @@ class CommandMSSet : public Command { const Anope::string ¶m = params[1]; NickCore *nc = source.nc; + BotInfo *MemoServ = Config->GetClient("MemoServ"); + + if (!MemoServ) + return; if (param.equals_ci("ON")) { diff --git a/modules/commands/ms_staff.cpp b/modules/commands/ms_staff.cpp index 30ec92b16..20ce265a4 100644 --- a/modules/commands/ms_staff.cpp +++ b/modules/commands/ms_staff.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" namespace diff --git a/modules/commands/ns_access.cpp b/modules/commands/ns_access.cpp index 7de20b9b7..4fa3a2074 100644 --- a/modules/commands/ns_access.cpp +++ b/modules/commands/ns_access.cpp @@ -9,12 +9,8 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" -static ServiceReference nickserv("NickServService", "NickServ"); - class CommandNSAccess : public Command { private: diff --git a/modules/commands/ns_ajoin.cpp b/modules/commands/ns_ajoin.cpp index ba7e53912..0de8b43ff 100644 --- a/modules/commands/ns_ajoin.cpp +++ b/modules/commands/ns_ajoin.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/************************************************************************