summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2013-05-26 17:13:11 -0400
committerAdam <Adam@anope.org>2013-05-26 17:13:11 -0400
commit22658d63bdb1e52a66f4514af45fa55ca5891345 (patch)
tree673304ab19f7e077b489354248247867518331f8
parentf2dee1e1d642b07947f59f91dfba9af34ef84685 (diff)
Get rid of the remaining references in the core to specific services. Move more stuff out of the core to the proper modules.
-rw-r--r--data/botserv.example.conf3
-rw-r--r--data/modules.example.conf2
-rw-r--r--data/operserv.example.conf7
-rw-r--r--docs/README2
-rw-r--r--include/account.h14
-rw-r--r--include/bots.h2
-rw-r--r--include/channels.h11
-rw-r--r--include/config.h3
-rw-r--r--include/modes.h28
-rw-r--r--include/module.h8
-rw-r--r--include/modules.h33
-rw-r--r--include/modules/pseudoclients/chanserv.h (renamed from include/modules/chanserv.h)0
-rw-r--r--include/modules/pseudoclients/global.h (renamed from include/modules/global.h)0
-rw-r--r--include/modules/pseudoclients/memoserv.h (renamed from include/modules/memoserv.h)0
-rw-r--r--include/modules/pseudoclients/nickserv.h (renamed from include/modules/nickserv.h)3
-rw-r--r--include/regchannel.h11
-rw-r--r--include/users.h6
-rw-r--r--modules/commands/bs_assign.cpp2
-rw-r--r--modules/commands/bs_badwords.cpp1
-rw-r--r--modules/commands/bs_bot.cpp2
-rw-r--r--modules/commands/bs_botlist.cpp2
-rw-r--r--modules/commands/bs_control.cpp2
-rw-r--r--modules/commands/bs_info.cpp2
-rw-r--r--modules/commands/bs_kick.cpp2
-rw-r--r--modules/commands/cs_access.cpp2
-rw-r--r--modules/commands/cs_akick.cpp2
-rw-r--r--modules/commands/cs_ban.cpp1
-rw-r--r--modules/commands/cs_clone.cpp11
-rw-r--r--modules/commands/cs_drop.cpp2
-rw-r--r--modules/commands/cs_enforce.cpp2
-rw-r--r--modules/commands/cs_entrymsg.cpp2
-rw-r--r--modules/commands/cs_fantasy_stats.cpp2
-rw-r--r--modules/commands/cs_fantasy_top.cpp2
-rw-r--r--modules/commands/cs_flags.cpp3
-rw-r--r--modules/commands/cs_getkey.cpp3
-rw-r--r--modules/commands/cs_info.cpp6
-rw-r--r--modules/commands/cs_invite.cpp3
-rw-r--r--modules/commands/cs_kick.cpp4
-rw-r--r--modules/commands/cs_list.cpp3
-rw-r--r--modules/commands/cs_log.cpp2
-rw-r--r--modules/commands/cs_mode.cpp2
-rw-r--r--modules/commands/cs_register.cpp15
-rw-r--r--modules/commands/cs_seen.cpp55
-rw-r--r--modules/commands/cs_set.cpp69
-rw-r--r--modules/commands/cs_set_misc.cpp2
-rw-r--r--modules/commands/cs_status.cpp2
-rw-r--r--modules/commands/cs_suspend.cpp4
-rw-r--r--modules/commands/cs_sync.cpp2
-rw-r--r--modules/commands/cs_unban.cpp2
-rw-r--r--modules/commands/cs_updown.cpp16
-rw-r--r--modules/commands/gl_global.cpp4
-rw-r--r--modules/commands/help.cpp2
-rw-r--r--modules/commands/hs_del.cpp2
-rw-r--r--modules/commands/hs_group.cpp2
-rw-r--r--modules/commands/hs_list.cpp2
-rw-r--r--modules/commands/hs_off.cpp2
-rw-r--r--modules/commands/hs_on.cpp2
-rw-r--r--modules/commands/hs_request.cpp6
-rw-r--r--modules/commands/hs_set.cpp2
-rw-r--r--modules/commands/ms_cancel.cpp2
-rw-r--r--modules/commands/ms_check.cpp2
-rw-r--r--modules/commands/ms_del.cpp2
-rw-r--r--modules/commands/ms_ignore.cpp12
-rw-r--r--modules/commands/ms_info.cpp2
-rw-r--r--modules/commands/ms_list.cpp2
-rw-r--r--modules/commands/ms_read.cpp2
-rw-r--r--modules/commands/ms_rsend.cpp2
-rw-r--r--modules/commands/ms_send.cpp2
-rw-r--r--modules/commands/ms_sendall.cpp2
-rw-r--r--modules/commands/ms_set.cpp6
-rw-r--r--modules/commands/ms_staff.cpp2
-rw-r--r--modules/commands/ns_access.cpp4
-rw-r--r--modules/commands/ns_ajoin.cpp3
-rw-r--r--modules/commands/ns_alist.cpp2
-rw-r--r--modules/commands/ns_cert.cpp9
-rw-r--r--modules/commands/ns_drop.cpp4
-rw-r--r--modules/commands/ns_getemail.cpp2
-rw-r--r--modules/commands/ns_getpass.cpp4
-rw-r--r--modules/commands/ns_group.cpp10
-rw-r--r--modules/commands/ns_identify.cpp3
-rw-r--r--modules/commands/ns_info.cpp4
-rw-r--r--modules/commands/ns_list.cpp2
-rw-r--r--modules/commands/ns_logout.cpp4
-rw-r--r--modules/commands/ns_recover.cpp20
-rw-r--r--modules/commands/ns_register.cpp20
-rw-r--r--modules/commands/ns_resetpass.cpp2
-rw-r--r--modules/commands/ns_set.cpp16
-rw-r--r--modules/commands/ns_set_misc.cpp2
-rw-r--r--modules/commands/ns_status.cpp2
-rw-r--r--modules/commands/ns_suspend.cpp9
-rw-r--r--modules/commands/ns_update.cpp2
-rw-r--r--modules/commands/os_akill.cpp2
-rw-r--r--modules/commands/os_chankill.cpp2
-rw-r--r--modules/commands/os_config.cpp2
-rw-r--r--modules/commands/os_defcon.cpp26
-rw-r--r--modules/commands/os_forbid.cpp9
-rw-r--r--modules/commands/os_ignore.cpp2
-rw-r--r--modules/commands/os_jupe.cpp2
-rw-r--r--modules/commands/os_kick.cpp2
-rw-r--r--modules/commands/os_kill.cpp2
-rw-r--r--modules/commands/os_list.cpp2
-rw-r--r--modules/commands/os_login.cpp2
-rw-r--r--modules/commands/os_mode.cpp2
-rw-r--r--modules/commands/os_modinfo.cpp2
-rw-r--r--modules/commands/os_module.cpp2
-rw-r--r--modules/commands/os_news.cpp19
-rw-r--r--modules/commands/os_noop.cpp3
-rw-r--r--modules/commands/os_oline.cpp2
-rw-r--r--modules/commands/os_oper.cpp2
-rw-r--r--modules/commands/os_reload.cpp2
-rw-r--r--modules/commands/os_session.cpp47
-rw-r--r--modules/commands/os_set.cpp2
-rw-r--r--modules/commands/os_shutdown.cpp2
-rw-r--r--modules/commands/os_stats.cpp2
-rw-r--r--modules/commands/os_svs.cpp6
-rw-r--r--modules/commands/os_sxline.cpp2
-rw-r--r--modules/commands/os_update.cpp2
-rw-r--r--modules/cs_statusupdate.cpp2
-rw-r--r--modules/database/db_flatfile.cpp8
-rw-r--r--modules/database/db_old.cpp2
-rw-r--r--modules/database/db_plain.cpp8
-rw-r--r--modules/encryption/enc_md5.cpp2
-rw-r--r--modules/extra/m_ldap_authentication.cpp2
-rw-r--r--modules/extra/m_proxyscan.cpp1
-rw-r--r--modules/extra/m_sql_authentication.cpp1
-rw-r--r--modules/extra/m_sql_oper.cpp1
-rw-r--r--modules/m_dnsbl.cpp1
-rw-r--r--modules/m_helpchan.cpp2
-rw-r--r--modules/m_redis.cpp3
-rw-r--r--modules/protocol/bahamut.cpp16
-rw-r--r--modules/protocol/charybdis.cpp13
-rw-r--r--modules/protocol/hybrid.cpp32
-rw-r--r--modules/protocol/inspircd11.cpp892
-rw-r--r--modules/protocol/inspircd12.cpp16
-rw-r--r--modules/protocol/inspircd20.cpp4
-rw-r--r--modules/protocol/ngircd.cpp2
-rw-r--r--modules/protocol/plexus.cpp12
-rw-r--r--modules/protocol/ratbox.cpp4
-rw-r--r--modules/protocol/unreal.cpp21
-rw-r--r--modules/pseudoclients/botserv.cpp27
-rw-r--r--modules/pseudoclients/chanserv.cpp241
-rw-r--r--modules/pseudoclients/global.cpp51
-rw-r--r--modules/pseudoclients/hostserv.cpp22
-rw-r--r--modules/pseudoclients/memoserv.cpp85
-rw-r--r--modules/pseudoclients/nickserv.cpp295
-rw-r--r--modules/pseudoclients/operserv.cpp29
-rw-r--r--src/bots.cpp2
-rw-r--r--src/channels.cpp73
-rw-r--r--src/config.cpp12
-rw-r--r--src/init.cpp2
-rw-r--r--src/logger.cpp10
-rw-r--r--src/main.cpp19
-rw-r--r--src/memos.cpp2
-rw-r--r--src/messages.cpp15
-rw-r--r--src/misc.cpp1
-rw-r--r--src/modes.cpp33
-rw-r--r--src/nickalias.cpp109
-rw-r--r--src/nickcore.cpp3
-rw-r--r--src/protocol.cpp2
-rw-r--r--src/regchannel.cpp43
-rw-r--r--src/servers.cpp29
-rw-r--r--src/tools/anopesmtp.cpp26
-rw-r--r--src/users.cpp89
-rw-r--r--src/xline.cpp2
164 files changed, 833 insertions, 2135 deletions
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
@@ -469,6 +469,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.
*
* This directive is optional, if no set it will default to 3.
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<ChannelInfo> 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<User *, ChanUserContainer *> 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<Anope::string, Block *> modules;
+ Anope::map<Anope::string> 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<std::pair<Mode *, Anope::string> > AddModes;
- /* Modes to be deleted */
- std::list<std::pair<Mode *, Anope::string> > 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 &param);
-};
-
/** 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<User *, StackerInfo *> UserStackerObjects;
- static std::map<Channel *, StackerInfo *> 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<Anope::string> 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<Anope::string> &params) { }
/** 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/pseudoclients/chanserv.h
index e1c3849fd..e1c3849fd 100644
--- a/include/modules/chanserv.h
+++ b/include/modules/pseudoclients/chanserv.h
diff --git a/include/modules/global.h b/include/modules/pseudoclients/global.h
index 52afc4a23..52afc4a23 100644
--- a/include/modules/global.h
+++ b/include/modules/pseudoclients/global.h
diff --git a/include/modules/memoserv.h b/include/modules/pseudoclients/memoserv.h
index d35d3f8a0..d35d3f8a0 100644
--- a/include/modules/memoserv.h
+++ b/include/modules/pseudoclients/memoserv.h
diff --git a/include/modules/nickserv.h b/include/modules/pseudoclients/nickserv.h
index b20d6ebd1..c0238ecfc 100644
--- a/include/modules/nickserv.h
+++ b/include/modules/pseudoclients/nickserv.h
@@ -9,7 +9,8 @@ class NickServService : public Service
}
virtual void Validate(User *u) = 0;
- virtual void Login(User *u, NickAlias *na) = 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<Anope::string> &params, ChannelInfo* &ci) anope_override
+ bool CheckArguments(CommandSource &source, const std::vector<Anope::string> &params, 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<Anope::string, int16_t, ci::less> 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<ChanServService> chanserv("ChanServService", "ChanServ");
static std::map<Anope::string, char> 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<ChanServService> 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<ChanServService> 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<time_t>("purgetime");
+ size_t previous_size = database.size(), purgetime = Config->GetModule(this)->Get<time_t>("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<time_t>("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<Anope::string> &params) 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 &param) 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 &param) 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<Anope::string, Anope::string> 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<bool>("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("MemoServService", "MemoServ");
-
class CommandMSIgnore : public Command
{
public:
@@ -29,10 +24,6 @@ class CommandMSIgnore : public Command
void Execute(CommandSource &source, const std::vector<Anope::string> &params) 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("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 &param = 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<NickServService> 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.
*/
-/*************************************************************************/
-
#include "module.h"
struct AJoinEntry;
@@ -250,6 +248,7 @@ class NSAJoin : public Module
void OnNickIdentify(User *u) anope_override
{
+ BotInfo *NickServ = Config->GetClient("NickServ");
if (!NickServ)
return;
diff --git a/modules/commands/ns_alist.cpp b/modules/commands/ns_alist.cpp
index 9c673a7fc..591af44c3 100644
--- a/modules/commands/ns_alist.cpp
+++ b/modules/commands/ns_alist.cpp
@@ -9,8 +9,6 @@
* Based on the original code of Services by Andy Church.
*/
-/*************************************************************************/
-
#include "module.h"
class CommandNSAList : public Command
diff --git a/modules/commands/ns_cert.cpp b/modules/commands/ns_cert.cpp
index 71836481a..022d803ea 100644
--- a/modules/commands/ns_cert.cpp
+++ b/modules/commands/ns_cert.cpp
@@ -9,8 +9,6 @@
* Based on the original code of Services by Andy Church.
*/
-/*************************************************************************/
-
#include "module.h"
static unsigned accessmax;
@@ -169,8 +167,6 @@ class CommandNSCert : public Command
return this->DoList(source, nc);
else
this->OnSyntaxError(source, cmd);
-
- return;
}
bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
@@ -180,8 +176,8 @@ class CommandNSCert : public Command
source.Reply(_("Modifies or displays the certificate list for your nick.\n"
"If you connect to IRC and provide a client certificate with a\n"
"matching fingerprint in the cert list, your nick will be\n"
- "automatically identified to %s.\n"
- " \n"), NickServ ? NickServ->nick.c_str() : source.service->nick.c_str());
+ "automatically identified to services.\n"
+ " \n"));
source.Reply(_("Examples:\n"
" \n"
" \002CERT ADD <fingerprint>\002\n"
@@ -205,6 +201,7 @@ class NSCert : public Module
void DoAutoIdentify(User *u)
{
NickAlias *na = NickAlias::Find(u->nick);
+ BotInfo *NickServ = Config->GetClient("NickServ");
if (!NickServ || !na)
return;
if (u->IsIdentified() && u->Account() == na->nc)
diff --git a/modules/commands/ns_drop.cpp b/modules/commands/ns_drop.cpp
index 023d696f6..a21cac709 100644
--- a/modules/commands/ns_drop.cpp
+++ b/modules/commands/ns_drop.cpp
@@ -9,12 +9,8 @@
* Based on the original code of Services by Andy Church.
*/
-/*************************************************************************/
-
#include "module.h"
-static ServiceReference<NickServService> nickserv("NickServService", "NickServ");
-
class CommandNSDrop : public Command
{
public:
diff --git a/modules/commands/ns_getemail.cpp b/modules/commands/ns_getemail.cpp
index 386940a0a..8139139e1 100644
--- a/modules/commands/ns_getemail.cpp
+++ b/modules/commands/ns_getemail.cpp
@@ -13,8 +13,6 @@
* Cards are not excepted. Must use user@email-host.
*/
-/*************************************************************************/
-
#include "module.h"
class CommandNSGetEMail : public Command
diff --git a/modules/commands/ns_getpass.cpp b/modules/commands/ns_getpass.cpp
index a99181b3f..cb320ad76 100644
--- a/modules/commands/ns_getpass.cpp
+++ b/modules/commands/ns_getpass.cpp
@@ -9,12 +9,8 @@
* Based on the original code of Services by Andy Church.
*/
-/*************************************************************************/
-
#include "module.h"
-static ServiceReference<NickServService> nickserv("NickServService", "NickServ");
-
class CommandNSGetPass : public Command
{
public:
diff --git a/modules/commands/ns_group.cpp b/modules/commands/ns_group.cpp
index a744b9afc..9b202b31c 100644
--- a/modules/commands/ns_group.cpp
+++ b/modules/commands/ns_group.cpp
@@ -9,12 +9,8 @@
* Based on the original code of Services by Andy Church.
*/
-/*************************************************************************/
-
#include "module.h"
-static ServiceReference<NickServService> nickserv("NickServService", "NickServ");
-
class NSGroupRequest : public IdentifyRequest
{
CommandSource source;
@@ -48,8 +44,6 @@ class NSGroupRequest : public IdentifyRequest
u->Login(target->nc);
IRCD->SendLogin(u);
- if (!Config->GetBlock("options")->Get<bool>("nonicknameownership") && na->nc == u->Account() && na->nc->HasExt("UNCONFIRMED") == false)
- u->SetMode(NickServ, "REGISTERED");
FOREACH_MOD(I_OnNickGroup, OnNickGroup(u, target));
Log(LOG_COMMAND, source, cmd) << "makes " << nick << " join group of " << target->nick << " (" << target->nc->display << ") (email: " << (!target->nc->email.empty() ? target->nc->email : "none") << ")";
@@ -251,10 +245,8 @@ class CommandNSUngroup : public Command
User *user = User::Find(na->nick);
if (user)
/* The user on the nick who was ungrouped may be identified to the old group, set -r */
- user->RemoveMode(NickServ, "REGISTERED");
+ user->RemoveMode(source.service, "REGISTERED");
}
-
- return;
}
bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
diff --git a/modules/commands/ns_identify.cpp b/modules/commands/ns_identify.cpp
index 037072728..aec43c1be 100644
--- a/modules/commands/ns_identify.cpp
+++ b/modules/commands/ns_identify.cpp
@@ -9,8 +9,6 @@
* Based on the original code of Services by Andy Church.
*/
-/*************************************************************************/
-
#include "module.h"
class NSIdentifyRequest : public IdentifyRequest
@@ -39,7 +37,6 @@ class NSIdentifyRequest : public IdentifyRequest
Log(LOG_COMMAND, source, cmd) << "and identified for account " << na->nc->display;
source.Reply(_("Password accepted - you are now recognized."));
u->Identify(na);
- na->Release();
}
}
diff --git a/modules/commands/ns_info.cpp b/modules/commands/ns_info.cpp
index 3e946a1f1..f1de95275 100644
--- a/modules/commands/ns_info.cpp
+++ b/modules/commands/ns_info.cpp
@@ -9,12 +9,8 @@
* Based on the original code of Services by Andy Church.
*/
-/*************************************************************************/
-
#include "module.h"
-static ServiceReference<NickServService> nickserv("NickServService", "NickServ");
-
class CommandNSInfo : public Command
{
private:
diff --git a/modules/commands/ns_list.cpp b/modules/commands/ns_list.cpp
index 69648c2f4..a4e73e857 100644
--- a/modules/commands/ns_list.cpp
+++ b/modules/commands/ns_list.cpp
@@ -9,8 +9,6 @@
* Based on the original code of Services by Andy Church.
*/
-/*************************************************************************/
-
#include "module.h"
class CommandNSList : public Command
diff --git a/modules/commands/ns_logout.cpp b/modules/commands/ns_logout.cpp
index c149dc1f2..d5765b0f6 100644
--- a/modules/commands/ns_logout.cpp
+++ b/modules/commands/ns_logout.cpp
@@ -9,8 +9,6 @@
* Based on the original code of Services by Andy Church.
*/
-/*************************************************************************/
-
#include "module.h"
static ServiceReference<NickServService> NickServService("NickServService", "NickServ");
@@ -52,7 +50,7 @@ class CommandNSLogout : public Command
source.Reply(_("Your nick has been logged out."));
IRCD->SendLogout(u2);
- u2->RemoveMode(NickServ, "REGISTERED");
+ u2->RemoveMode(source.service, "REGISTERED");
u2->Logout();
/* Send out an event */
diff --git a/modules/commands/ns_recover.cpp b/modules/commands/ns_recover.cpp
index e9455f88a..33bc9d19e 100644
--- a/modules/commands/ns_recover.cpp
+++ b/modules/commands/ns_recover.cpp
@@ -9,10 +9,10 @@
* Based on the original code of Services by Andy Church.
*/
-/*************************************************************************/
-
#include "module.h"
+static ServiceReference<NickServService> nickserv("NickServService", "NickServ");
+
struct NSRecoverExtensibleInfo : ExtensibleItem, std::map<Anope::string, ChannelStatus> { };
class NSRecoverRequest : public IdentifyRequest
@@ -39,7 +39,7 @@ class NSRecoverRequest : public IdentifyRequest
/* Nick is being held by us, release it */
if (na->HasExt("HELD"))
{
- na->Release();
+ nickserv->Release(na);
source.Reply(_("Service's hold on \002%s\002 has been released."), na->nick.c_str());
}
else if (!u)
@@ -68,7 +68,7 @@ class NSRecoverRequest : public IdentifyRequest
}
}
- u->SendMessage(NickServ, _("This nickname has been recovered by %s. If you did not do\n"
+ u->SendMessage(source.service, _("This nickname has been recovered by %s. If you did not do\n"
"this then %s may have your password, and you should change it.\n"),
source.GetNick().c_str(), source.GetNick().c_str());
@@ -89,13 +89,14 @@ class NSRecoverRequest : public IdentifyRequest
Log(LOG_COMMAND, source, cmd) << "and was automatically identified to " << na->nick << " (" << na->nc->display << ")";
}
- u->SendMessage(NickServ, _("This nickname has been recovered by %s."), source.GetNick().c_str());
- u->Collide(na);
+ u->SendMessage(source.service, _("This nickname has been recovered by %s."), source.GetNick().c_str());
+ if (nickserv)
+ nickserv->Collide(u, na);
if (IRCD->CanSVSNick)
{
/* If we can svsnick then release our hold and svsnick the user using the command */
- na->Release();
+ nickserv->Release(na);
IRCD->SendForceNickChange(source.GetUser(), GetAccount(), Anope::CurTime);
}
else
@@ -226,7 +227,7 @@ class NSRecover : public Module
* because some IRCds do not allow us to have these automatically expire
*/
for (nickalias_map::const_iterator it = NickAliasList->begin(); it != NickAliasList->end(); ++it)
- it->second->Release();
+ nickserv->Release(it->second);
}
void OnRestart() anope_override { OnShutdown(); }
@@ -236,8 +237,9 @@ class NSRecover : public Module
if (Config->GetModule(this)->Get<bool>("restoreonrecover"))
{
NSRecoverExtensibleInfo *ei = u->GetExt<NSRecoverExtensibleInfo *>("ns_recover_info");
+ BotInfo *NickServ = Config->GetClient("NickServ");
- if (ei != NULL)
+ if (ei != NULL && NickServ != NULL)
for (std::map<Anope::string, ChannelStatus>::iterator it = ei->begin(), it_end = ei->end(); it != it_end;)
{
Channel *c = Channel::Find(it->first);
diff --git a/modules/commands/ns_register.cpp b/modules/commands/ns_register.cpp
index 2d2f59877..ac1c55696 100644
--- a/modules/commands/ns_register.cpp
+++ b/modules/commands/ns_register.cpp
@@ -9,8 +9,6 @@
* Based on the original code of Services by Andy Church.
*/
-/*************************************************************************/
-
#include "module.h"
static bool SendRegmail(User *u, const NickAlias *na, const BotInfo *bi);
@@ -59,7 +57,7 @@ class CommandNSConfirm : public Command
IRCD->SendLogin(source.GetUser());
const NickAlias *na = NickAlias::Find(source.GetNick());
if (!Config->GetBlock("options")->Get<bool>("nonicknameownership") && na != NULL && na->nc == source.GetAccount() && na->nc->HasExt("UNCONFIRMED") == false)
- source.GetUser()->SetMode(NickServ, "REGISTERED");
+ source.GetUser()->SetMode(source.service, "REGISTERED");
}
}
else
@@ -192,8 +190,6 @@ class CommandNSRegister : public Command
{
na->last_usermask = u->GetIdent() + "@" + u->GetDisplayedHost();
na->last_realname = u->realname;
-
- u->Login(nc);
}
Log(LOG_COMMAND, source, this) << "to register " << na->nick << " (email: " << (!na->nc->email.empty() ? na->nc->email : "none") << ")";
@@ -227,18 +223,14 @@ class CommandNSRegister : public Command
source.Reply(_("If you do not confirm your email address within %s your account will expire."), Anope::Duration(unconfirmed_expire).c_str());
}
}
- else if (nsregister.equals_ci("none"))
- {
- if (u)
- {
- IRCD->SendLogin(u);
- if (!Config->GetBlock("options")->Get<bool>("nonicknameownership") && na->nc == u->Account() && na->nc->HasExt("UNCONFIRMED") == false)
- u->SetMode(NickServ, "REGISTERED");
- }
- }
if (u)
+ {
+ u->Login(nc);
+ if (!nc->HasExt("UNCONFIRMED"))
+ IRCD->SendLogin(u);
u->lastnickreg = Anope::CurTime;
+ }
}
}
diff --git a/modules/commands/ns_resetpass.cpp b/modules/commands/ns_resetpass.cpp
index bf1e8dacf..44d941662 100644
--- a/modules/commands/ns_resetpass.cpp
+++ b/modules/commands/ns_resetpass.cpp
@@ -9,8 +9,6 @@
* Based on the original code of Services by Andy Church.
*/
-/*************************************************************************/
-
#include "module.h"
static bool SendResetEmail(User *u, const NickAlias *na, const BotInfo *bi);
diff --git a/modules/commands/ns_set.cpp b/modules/commands/ns_set.cpp
index 3dac72f71..fd32fb2be 100644
--- a/modules/commands/ns_set.cpp
+++ b/modules/commands/ns_set.cpp
@@ -11,8 +11,6 @@
#include "module.h"
-static ServiceReference<NickServService> nickserv("NickServService", "NickServ");
-
class CommandNSSet : public Command
{
public:
@@ -1350,7 +1348,6 @@ class NSSet : public Module
CommandNSSetChanstats commandnssetchanstats;
CommandNSSASetChanstats commandnssasetchanstats;
- bool NSDefChanstats;
CommandNSSetDisplay commandnssetdisplay;
CommandNSSASetDisplay commandnssasetdisplay;
@@ -1388,7 +1385,7 @@ class NSSet : public Module
NSSet(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR),
commandnsset(this), commandnssaset(this),
commandnssetautoop(this), commandnssasetautoop(this),
- commandnssetchanstats(this), commandnssasetchanstats(this), NSDefChanstats(false),
+ commandnssetchanstats(this), commandnssasetchanstats(this),
commandnssetdisplay(this), commandnssasetdisplay(this),
commandnssetemail(this), commandnssasetemail(this),
commandnssetgreet(this), commandnssasetgreet(this),
@@ -1402,7 +1399,7 @@ class NSSet : public Module
commandnssasetnoexpire(this)
{
- Implementation i[] = { I_OnPreCommand };
+ Implementation i[] = { I_OnPreCommand, I_OnSetCorrectModes };
ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation));
}
@@ -1429,6 +1426,15 @@ class NSSet : public Module
return EVENT_CONTINUE;
}
+
+ void OnSetCorrectModes(User *user, Channel *chan, AccessGroup &access, bool &give_modes, bool &take_modes) anope_override
+ {
+ if (chan->ci)
+ {
+ /* Only give modes if autoop is set */
+ give_modes &= !user->Account() || user->Account()->HasExt("AUTOOP");
+ }
+ }
};
MODULE_INIT(NSSet)
diff --git a/modules/commands/ns_set_misc.cpp b/modules/commands/ns_set_misc.cpp
index ae7c2cb53..753450414 100644
--- a/modules/commands/ns_set_misc.cpp
+++ b/modules/commands/ns_set_misc.cpp
@@ -9,8 +9,6 @@
* Based on the original code of Services by Andy Church.
*/
-/*************************************************************************/
-
#include "module.h"
static std::map<Anope::string, Anope::string> descriptions;
diff --git a/modules/commands/ns_status.cpp b/modules/commands/ns_status.cpp
index 68568de0a..3bfeab888 100644
--- a/modules/commands/ns_status.cpp
+++ b/modules/commands/ns_status.cpp
@@ -9,8 +9,6 @@
* Based on the original code of Services by Andy Church.
*/
-/*************************************************************************/
-
#include "module.h"
class CommandNSStatus : public Command
diff --git a/modules/commands/ns_suspend.cpp b/modules/commands/ns_suspend.cpp
index 5ca9ca81d..eadb35d7d 100644
--- a/modules/commands/ns_suspend.cpp
+++ b/modules/commands/ns_suspend.cpp
@@ -9,8 +9,6 @@
* Based on the original code of Services by Andy Church.
*/
-/*************************************************************************/
-
#include "module.h"
static ServiceReference<NickServService> nickserv("NickServService", "NickServ");
@@ -87,7 +85,8 @@ class CommandNSSuspend : public Command
if (u2)
{
u2->Logout();
- u2->Collide(na2);
+ if (nickserv)
+ nickserv->Collide(u2, na2);
}
}
}
@@ -96,8 +95,6 @@ class CommandNSSuspend : public Command
source.Reply(_("Nick %s is now suspended."), nick.c_str());
FOREACH_MOD(I_OnNickSuspended, OnNickSuspend(na));
-
- return;
}
bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
@@ -218,7 +215,7 @@ class NSSuspend : public Module
na->nc->Shrink("suspend:reason");
na->nc->Shrink("suspend:time");
- Log(LOG_NORMAL, "expire", NickServ) << "Expiring suspend for " << na->nick;
+ Log(LOG_NORMAL, "expire", Config->GetClient("NickServ")) << "Expiring suspend for " << na->nick;
}
}
catch (const ConvertException &) { }
diff --git a/modules/commands/ns_update.cpp b/modules/commands/ns_update.cpp
index ee8a2c8cb..b56f8eded 100644
--- a/modules/commands/ns_update.cpp
+++ b/modules/commands/ns_update.cpp
@@ -9,8 +9,6 @@
* Based on the original code of Services by Andy Church.
*/
-/*************************************************************************/
-
#include "module.h"
class CommandNSUpdate : public Command
diff --git a/modules/commands/os_akill.cpp b/modules/commands/os_akill.cpp
index b7433d0eb..34e6dbd2b 100644
--- a/modules/commands/os_akill.cpp
+++ b/modules/commands/os_akill.cpp
@@ -9,8 +9,6 @@
* Based on the original code of Services by Andy Church.
*/
-/*************************************************************************/
-
#include "module.h"
static ServiceReference<XLineManager> akills("XLineManager", "xlinemanager/sgline");
diff --git a/modules/commands/os_chankill.cpp b/modules/commands/os_chankill.cpp
index 713b5922f..1304dd75c 100644
--- a/modules/commands/os_chankill.cpp
+++ b/modules/commands/os_chankill.cpp
@@ -9,8 +9,6 @@
* Based on the original code of Services by Andy Church.
*/
-/*************************************************************************/
-
#include "module.h"
static ServiceReference<XLineManager> akills("XLineManager", "xlinemanager/sgline");
diff --git a/modules/commands/os_config.cpp b/modules/commands/os_config.cpp
index 391d36157..a9ff515fb 100644
--- a/modules/commands/os_config.cpp
+++ b/modules/commands/os_config.cpp
@@ -9,8 +9,6 @@
* Based on the original code of Services by Andy Church.
*/
-/*************************************************************************/
-
#include "module.h"
class CommandOSConfig : public Command
diff --git a/modules/commands/os_defcon.cpp b/modules/commands/os_defcon.cpp
index 236cf2e2f..ba695649d 100644
--- a/modules/commands/os_defcon.cpp
+++ b/modules/commands/os_defcon.cpp
@@ -9,8 +9,6 @@
* Based on the original code of Services by Andy Church.
*/
-/*************************************************************************/
-
#include "module.h"
#include "modules/os_session.h"
@@ -128,17 +126,17 @@ class DefConTimeout : public Timer
{
DConfig.defaultlevel = level;
FOREACH_MOD(I_OnDefconLevel, OnDefconLevel(level));
- Log(OperServ, "operserv/defcon") << "Defcon level timeout, returning to level " << level;
+ Log(Config->GetClient("OperServ"), "operserv/defcon") << "Defcon level timeout, returning to level " << level;
if (DConfig.globalondefcon)
{
if (!DConfig.offmessage.empty())
- GlobalService->SendGlobal(Global, "", DConfig.offmessage);
+ GlobalService->SendGlobal(NULL, "", DConfig.offmessage);
else
- GlobalService->SendGlobal(Global, "", Anope::printf(Language::Translate(_("The Defcon Level is now at Level: \002%d\002")), DConfig.defaultlevel));
+ GlobalService->SendGlobal(NULL, "", Anope::printf(Language::Translate(_("The Defcon Level is now at Level: \002%d\002")), DConfig.defaultlevel));
if (!DConfig.message.empty())
- GlobalService->SendGlobal(Global, "", DConfig.message);
+ GlobalService->SendGlobal(NULL, "", DConfig.message);
}
runDefCon();
@@ -221,12 +219,12 @@ class CommandOSDefcon : public Command
if (DConfig.globalondefcon)
{
if (DConfig.defaultlevel == 5 && !DConfig.offmessage.empty())
- GlobalService->SendGlobal(Global, "", DConfig.offmessage);
+ GlobalService->SendGlobal(NULL, "", DConfig.offmessage);
else if (DConfig.defaultlevel != 5)
{
- GlobalService->SendGlobal(Global, "", Anope::printf(_("The Defcon level is now at: \002%d\002"), DConfig.defaultlevel));
+ GlobalService->SendGlobal(NULL, "", Anope::printf(_("The Defcon level is now at: \002%d\002"), DConfig.defaultlevel));
if (!DConfig.message.empty())
- GlobalService->SendGlobal(Global, "", DConfig.message);
+ GlobalService->SendGlobal(NULL, "", DConfig.message);
}
}
@@ -417,7 +415,7 @@ class OSDefcon : public Module
if (DConfig.Check(DEFCON_FORCE_CHAN_MODES) && cm && DConfig.DefConModesOff.count(mname))
{
- c->RemoveMode(OperServ, cm, param);
+ c->RemoveMode(Config->GetClient("OperServ"), cm, param);
return EVENT_STOP;
}
@@ -434,9 +432,9 @@ class OSDefcon : public Module
Anope::string param;
if (DConfig.GetDefConParam(mname, param))
- c->SetMode(OperServ, cm, param);
+ c->SetMode(Config->GetClient("OperServ"), cm, param);
else
- c->SetMode(OperServ, cm);
+ c->SetMode(Config->GetClient("OperServ"), cm);
return EVENT_STOP;
@@ -488,6 +486,7 @@ class OSDefcon : public Module
if (exempt || u->Quitting() || !u->server->IsSynced() || u->server->IsULined())
return;
+ BotInfo *OperServ = Config->GetClient("OperServ");
if (DConfig.Check(DEFCON_AKILL_NEW_CLIENTS) && akills)
{
Log(OperServ, "operserv/defcon") << "DEFCON: adding akill for *@" << u->host;
@@ -548,12 +547,13 @@ class OSDefcon : public Module
void OnChannelSync(Channel *c) anope_override
{
if (DConfig.Check(DEFCON_FORCE_CHAN_MODES))
- c->SetModes(OperServ, false, "%s", DConfig.chanmodes.c_str());
+ c->SetModes(Config->GetClient("OperServ"), false, "%s", DConfig.chanmodes.c_str());
}
};
static void runDefCon()
{
+ BotInfo *OperServ = Config->GetClient("OperServ");
if (DConfig.Check(DEFCON_FORCE_CHAN_MODES))
{
if (!DConfig.chanmodes.empty() && !DefConModesSet)
diff --git a/modules/commands/os_forbid.cpp b/modules/commands/os_forbid.cpp
index c7c147c7e..a56d08219 100644
--- a/modules/commands/os_forbid.cpp
+++ b/modules/commands/os_forbid.cpp
@@ -9,11 +9,11 @@
* Based on the original code of Services by Andy Church.
*/
-/*************************************************************************/
-
#include "module.h"
#include "modules/os_forbid.h"
+static ServiceReference<NickServService> nickserv("NickServService", "NickServ");
+
class MyForbidService : public ForbidService
{
Serialize::Checker<std::vector<ForbidData *>[FT_SIZE - 1]> forbid_data;
@@ -271,6 +271,7 @@ class OSForbid : public Module
ForbidData *d = this->forbidService.FindForbid(u->nick, FT_NICK);
if (d != NULL)
{
+ BotInfo *OperServ = Config->GetClient("OperServ");
if (OperServ)
{
if (d->reason.empty())
@@ -278,12 +279,14 @@ class OSForbid : public Module
else
u->SendMessage(OperServ, _("This nickname has been forbidden: %s"), d->reason.c_str());
}
- u->Collide(NULL);
+ if (nickserv)
+ nickserv->Collide(u, NULL);
}
}
void OnJoinChannel(User *u, Channel *c) anope_override
{
+ BotInfo *OperServ = Config->GetClient("OperServ");
if (u->HasMode("OPER") || !OperServ)
return;
diff --git a/modules/commands/os_ignore.cpp b/modules/commands/os_ignore.cpp
index b7dda73a3..56c784856 100644
--- a/modules/commands/os_ignore.cpp
+++ b/modules/commands/os_ignore.cpp
@@ -9,8 +9,6 @@
* Based on the original code of Services by Andy Church.
*/
-/*************************************************************************/
-
#include "module.h"
#include "modules/os_ignore.h"
diff --git a/modules/commands/os_jupe.cpp b/modules/commands/os_jupe.cpp
index 4f40a5495..fbade0e82 100644
--- a/modules/commands/os_jupe.cpp
+++ b/modules/commands/os_jupe.cpp
@@ -9,8 +9,6 @@
* Based on the original code of Services by Andy Church.
*/
-/*************************************************************************/
-
#include "module.h"
class CommandOSJupe : public Command
diff --git a/modules/commands/os_kick.cpp b/modules/commands/os_kick.cpp
index d9ac75c9a..ea382a453 100644
--- a/modules/commands/os_kick.cpp
+++ b/modules/commands/os_kick.cpp
@@ -9,8 +9,6 @@
* Based on the original code of Services by Andy Church.
*/
-/*************************************************************************/
-
#include "module.h"
class CommandOSKick : public Command
diff --git a/modules/commands/os_kill.cpp b/modules/commands/os_kill.cpp
index 99a65ae4b..972092ef9 100644
--- a/modules/commands/os_kill.cpp
+++ b/modules/commands/os_kill.cpp
@@ -9,8 +9,6 @@
* Based on the original code of Services by Andy Church.
*/
-/*************************************************************************/
-
#include "module.h"
class CommandOSKill : public Command
diff --git a/modules/commands/os_list.cpp b/modules/commands/os_list.cpp
index dc1fd15ed..f0005e1da 100644
--- a/modules/commands/os_list.cpp
+++ b/modules/commands/os_list.cpp
@@ -9,8 +9,6 @@
* Based on the original code of Services by Andy Church.
*/
-/*************************************************************************/
-
#include "module.h"
class CommandOSChanList : public Command
diff --git a/modules/commands/os_login.cpp b/modules/commands/os_login.cpp
index 30172a0f3..573379236 100644
--- a/modules/commands/os_login.cpp
+++ b/modules/commands/os_login.cpp
@@ -10,8 +10,6 @@
*
*
*/
-/*************************************************************************/
-
#include "module.h"
class CommandOSLogin : public Command
diff --git a/modules/commands/os_mode.cpp b/modules/commands/os_mode.cpp
index 8af247da5..7057ead72 100644
--- a/modules/commands/os_mode.cpp
+++ b/modules/commands/os_mode.cpp
@@ -9,8 +9,6 @@
* Based on the original code of Services by Andy Church.
*/
-/*************************************************************************/
-
#include "module.h"
class CommandOSMode : public Command
diff --git a/modules/commands/os_modinfo.cpp b/modules/commands/os_modinfo.cpp
index b6f793796..1ad03c7c0 100644
--- a/modules/commands/os_modinfo.cpp
+++ b/modules/commands/os_modinfo.cpp
@@ -9,8 +9,6 @@
* Based on the original code of Services by Andy Church.
*/
-/*************************************************************************/
-
#include "module.h"
class CommandOSModInfo : public Command
diff --git a/modules/commands/os_module.cpp b/modules/commands/os_module.cpp
index 0de03971e..8ff7498a7 100644
--- a/modules/commands/os_module.cpp
+++ b/modules/commands/os_module.cpp
@@ -9,8 +9,6 @@
* Based on the original code of Services by Andy Church.
*/
-/*************************************************************************/
-
#include "module.h"
class CommandOSModLoad : public Command
diff --git a/modules/commands/os_news.cpp b/modules/commands/os_news.cpp
index e9f70b693..1d55df843 100644
--- a/modules/commands/os_news.cpp
+++ b/modules/commands/os_news.cpp
@@ -9,8 +9,6 @@
* Based on the original code of Services by Andy Church.
*/
-/*************************************************************************/
-
#include "module.h"
#include "modules/os_news.h"
@@ -342,6 +340,14 @@ class OSNews : public Module
if (newsList.empty())
return;
+ BotInfo *bi = NULL;
+ if (Type == NEWS_OPER)
+ bi = BotInfo::Find(Config->GetModule(this)->Get<const Anope::string>("oper_announcer", "OperServ"), true);
+ else
+ bi = BotInfo::Find(Config->GetModule(this)->Get<const Anope::string>("announcer", "Global"), true);
+ if (bi == NULL)
+ return;
+
Anope::string msg;
if (Type == NEWS_LOGON)
msg = _("[\002Logon News\002 - %s] %s");
@@ -357,14 +363,7 @@ class OSNews : public Module
if (Type == NEWS_RANDOM && i != cur_rand_news)
continue;
- const BotInfo *gl = Global;
- if (!gl && !BotListByNick->empty())
- gl = BotListByNick->begin()->second;
- const BotInfo *os = OperServ;
- if (!os)
- os = gl;
- if (gl)
- u->SendMessage(Type != NEWS_OPER ? gl : os, msg.c_str(), Anope::strftime(newsList[i]->time).c_str(), newsList[i]->text.c_str());
+ u->SendMessage(bi, msg.c_str(), Anope::strftime(newsList[i]->time).c_str(), newsList[i]->text.c_str());
++displayed;
diff --git a/modules/commands/os_noop.cpp b/modules/commands/os_noop.cpp
index 204b0e6e8..239b09a32 100644
--- a/modules/commands/os_noop.cpp
+++ b/modules/commands/os_noop.cpp
@@ -9,8 +9,6 @@
* Based on the original code of Services by Andy Church.
*/
-/*************************************************************************/
-
#include "module.h"
class CommandOSNOOP : public Command
@@ -95,6 +93,7 @@ class OSNOOP : public Module
if (setter)
{
Anope::string reason = "NOOP command used by " + *setter;
+ BotInfo *OperServ = Config->GetClient("OperServ");
u->Kill(OperServ ? OperServ->nick : "", reason);
}
}
diff --git a/modules/commands/os_oline.cpp b/modules/commands/os_oline.cpp
index e8f7cee9d..a2da17406 100644
--- a/modules/commands/os_oline.cpp
+++ b/modules/commands/os_oline.cpp
@@ -9,8 +9,6 @@
* Based on the original code of Services by Andy Church.
*/
-/*************************************************************************/
-
#include "module.h"
class CommandOSOLine : public Command
diff --git a/modules/commands/os_oper.cpp b/modules/commands/os_oper.cpp
index c3327dd4b..66a76334a 100644
--- a/modules/commands/os_oper.cpp
+++ b/modules/commands/os_oper.cpp
@@ -9,8 +9,6 @@
* Based on the original code of Services by Andy Church.
*/
-/*************************************************************************/
-
#include "module.h"
struct MyOper : Oper, Serializable
diff --git a/modules/commands/os_reload.cpp b/modules/commands/os_reload.cpp
index ed04fbea3..d3521eef1 100644
--- a/modules/commands/os_reload.cpp
+++ b/modules/commands/os_reload.cpp
@@ -9,8 +9,6 @@
* Based on the original code of Services by Andy Church.
*/
-/*************************************************************************/
-
#include "module.h"
class CommandOSReload : public Command
diff --git a/modules/commands/os_session.cpp b/modules/commands/os_session.cpp
index 656e046af..af6a547f5 100644
--- a/modules/commands/os_session.cpp
+++ b/modules/commands/os_session.cpp
@@ -9,8 +9,6 @@
* Based on the original code of Services by Andy Church.
*/
-/*************************************************************************/
-
#include "module.h"
#include "modules/os_session.h"
@@ -90,7 +88,7 @@ class MySessionService : public SessionService
return this->Exceptions;
}
- void DelSession(Session *s) anope_override
+ void DelSession(Session *s)
{
this->Sessions.erase(s->addr);
}
@@ -125,28 +123,6 @@ class MySessionService : public SessionService
}
};
-class ExpireTimer : public Timer
-{
- public:
- ExpireTimer() : Timer(Config->GetBlock("options")->Get<time_t>("expiretimeout"), Anope::CurTime, true) { }
-
- void Tick(time_t) anope_override
- {
- if (!session_service || Anope::NoExpire)
- return;
- for (unsigned i = session_service->GetExceptions().size(); i > 0; --i)
- {
- Exception *e = session_service->GetExceptions()[i - 1];
-
- if (!e->expires || e->expires > Anope::CurTime)
- continue;
- Log(OperServ, "expire/exception") << "Session exception for " << e->mask << "has expired.";
- session_service->DelException(e);
- delete e;
- }
- }
-};
-
class ExceptionDelCallback : public NumberList
{
protected:
@@ -633,7 +609,6 @@ class OSSession : public Module
{
Serialize::Type exception_type;
MySessionService ss;
- ExpireTimer expiretimer;
CommandOSSession commandossession;
CommandOSException commandosexception;
ServiceReference<XLineManager> akills;
@@ -644,7 +619,7 @@ class OSSession : public Module
{
this->SetPermanent(true);
- Implementation i[] = { I_OnReload, I_OnUserConnect, I_OnUserQuit };
+ Implementation i[] = { I_OnReload, I_OnUserConnect, I_OnUserQuit, I_OnExpireTick };
ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation));
ModuleManager::SetPriority(this, PRIORITY_FIRST);
}
@@ -706,6 +681,7 @@ class OSSession : public Module
if (kill && !exempt)
{
+ BotInfo *OperServ = Config->GetClient("OperServ");
if (OperServ)
{
if (!sle_reason.empty())
@@ -760,6 +736,23 @@ class OSSession : public Module
delete session;
sessions.erase(sit);
}
+
+ void OnExpireTick() anope_override
+ {
+ if (!Anope::NoExpire)
+ return;
+ for (unsigned i = this->ss.GetExceptions().size(); i > 0; --i)
+ {
+ Exception *e = this->ss.GetExceptions()[i - 1];
+
+ if (!e->expires || e->expires > Anope::CurTime)
+ continue;
+ BotInfo *OperServ = Config->GetClient("OperServ");
+ Log(OperServ, "expire/exception") << "Session exception for " << e->mask << "has expired.";
+ this->ss.DelException(e);
+ delete e;
+ }
+ }
};
MODULE_INIT(OSSession)
diff --git a/modules/commands/os_set.cpp b/modules/commands/os_set.cpp
index 6fc05ab60..f30d3723e 100644
--- a/modules/commands/os_set.cpp
+++ b/modules/commands/os_set.cpp
@@ -9,8 +9,6 @@
* Based on the original code of Services by Andy Church.
*/
-/*************************************************************************/
-
#include "module.h"
class CommandOSSet : public Command
diff --git a/modules/commands/os_shutdown.cpp b/modules/commands/os_shutdown.cpp
index 833c78491..f4fceada7 100644
--- a/modules/commands/os_shutdown.cpp
+++ b/modules/commands/os_shutdown.cpp
@@ -9,8 +9,6 @@
* Based on the original code of Services by Andy Church.
*/
-/*************************************************************************/
-
#include "module.h"
class CommandOSQuit : public Command
diff --git a/modules/commands/os_stats.cpp b/modules/commands/os_stats.cpp
index 8b975a6c7..1ce27f501 100644
--- a/modules/commands/os_stats.cpp
+++ b/modules/commands/os_stats.cpp
@@ -9,8 +9,6 @@
* Based on the original code of Services by Andy Church.
*/
-/*************************************************************************/
-
#include "module.h"
#include "modules/os_session.h"
diff --git a/modules/commands/os_svs.cpp b/modules/commands/os_svs.cpp
index 9fb1d63c3..4e9a31e6b 100644
--- a/modules/commands/os_svs.cpp
+++ b/modules/commands/os_svs.cpp
@@ -9,8 +9,6 @@
* Based on the original code of Services by Andy Church.
*/
-/*************************************************************************/
-
#include "module.h"
class CommandOSSVSNick : public Command
@@ -101,7 +99,7 @@ class CommandOSSVSJoin : public Command
source.Reply(_("\002%s\002 is already in \002%s\002."), target->nick.c_str(), c->name.c_str());
else
{
- IRCD->SendSVSJoin(OperServ, target, params[1], "");
+ IRCD->SendSVSJoin(source.service, target, params[1], "");
Log(LOG_ADMIN, source, this) << "to force " << target->nick << " to join " << params[1];
source.Reply(_("\002%s\002 has been joined to \002%s\002."), target->nick.c_str(), params[1].c_str());
}
@@ -145,7 +143,7 @@ class CommandOSSVSPart : public Command
source.Reply(_("\002%s\002 is not in \002%s\002."), target->nick.c_str(), c->name.c_str());
else
{
- IRCD->SendSVSPart(OperServ, target, params[1], "");
+ IRCD->SendSVSPart(source.service, target, params[1], "");
Log(LOG_ADMIN, source, this) << "to force " << target->nick << " to part " << c->name;
source.Reply(_("\002%s\002 has been parted from \002%s\002."), target->nick.c_str(), c->name.c_str());
}
diff --git a/modules/commands/os_sxline.cpp b/modules/commands/os_sxline.cpp
index dcf7863fe..d12237c93 100644
--- a/modules/commands/os_sxline.cpp
+++ b/modules/commands/os_sxline.cpp
@@ -9,8 +9,6 @@
* Based on the original code of Services by Andy Church.
*/
-/*************************************************************************/
-
#include "module.h"
class SXLineDelCallback : public NumberList
diff --git a/modules/commands/os_update.cpp b/modules/commands/os_update.cpp
index bce2feeed..3e411cbc8 100644
--- a/modules/commands/os_update.cpp
+++ b/modules/commands/os_update.cpp
@@ -9,8 +9,6 @@
* Based on the original code of Services by Andy Church.
*/
-/*************************************************************************/
-
#include "module.h"
class CommandOSUpdate : public Command
diff --git a/modules/cs_statusupdate.cpp b/modules/cs_statusupdate.cpp
index 130c0c3dc..bdb6c73d0 100644
--- a/modules/cs_statusupdate.cpp
+++ b/modules/cs_statusupdate.cpp
@@ -32,7 +32,7 @@ class StatusUpdate : public Module
if (!access->HasPriv("AUTO" + cms->name))
ci->c->RemoveMode(NULL, cms, user->GetUID());
}
- ci->c->SetCorrectModes(user, true, false);
+ ci->c->SetCorrectModes(user, true);
}
}
}
diff --git a/modules/database/db_flatfile.cpp b/modules/database/db_flatfile.cpp
index 19f263e98..27b6ce1a2 100644
--- a/modules/database/db_flatfile.cpp
+++ b/modules/database/db_flatfile.cpp
@@ -8,8 +8,6 @@
* Based on the original code of Services by Andy Church.
*/
-/*************************************************************************/
-
#include "module.h"
class SaveData : public Serialize::Data
@@ -240,7 +238,7 @@ class DBFlatFile : public Module, public Pipe
}
- EventReturn OnSaveDatabase() anope_override
+ void OnSaveDatabase() anope_override
{
BackupDatabase();
@@ -250,7 +248,7 @@ class DBFlatFile : public Module, public Pipe
{
i = fork();
if (i > 0)
- return EVENT_CONTINUE;
+ return;
else if (i < 0)
Log(this) << "Unable to fork for database save";
}
@@ -335,8 +333,6 @@ class DBFlatFile : public Module, public Pipe
this->Notify();
exit(0);
}
-
- return EVENT_CONTINUE;
}
/* Load just one type. Done if a module is reloaded during runtime */
diff --git a/modules/database/db_old.cpp b/modules/database/db_old.cpp
index 64faafe10..b901d879a 100644
--- a/modules/database/db_old.cpp
+++ b/modules/database/db_old.cpp
@@ -8,8 +8,6 @@
* Based on the original code of Services by Andy Church.
*/
-/*************************************************************************/
-
#include "module.h"
#include "modules/os_session.h"
diff --git a/modules/database/db_plain.cpp b/modules/database/db_plain.cpp
index fe95e06bb..a2c8d4274 100644
--- a/modules/database/db_plain.cpp
+++ b/modules/database/db_plain.cpp
@@ -8,8 +8,6 @@
* Based on the original code of Services by Andy Church.
*/
-/*************************************************************************/
-
#include "module.h"
#include "modules/os_session.h"
@@ -654,7 +652,7 @@ class DBPlain : public Module
}
- EventReturn OnSaveDatabase() anope_override
+ void OnSaveDatabase() anope_override
{
BackupDatabase();
@@ -868,15 +866,13 @@ class DBPlain : public Module
if (!db.is_open())
{
IRCD->SendGlobops(NULL, "Unable to open %s for writing!", DatabaseFile.c_str());
- return EVENT_CONTINUE;
+ return;
}
db << db_buffer.str();
db_buffer.str("");
db.close();
-
- return EVENT_CONTINUE;
}
};
diff --git a/modules/encryption/enc_md5.cpp b/modules/encryption/enc_md5.cpp
index 3bcdb599c..e19931800 100644
--- a/modules/encryption/enc_md5.cpp
+++ b/modules/encryption/enc_md5.cpp
@@ -14,8 +14,6 @@
#include "module.h"
#include "encryption.h"
-/*************************************************************************/
-
/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
rights reserved.
diff --git a/modules/extra/m_ldap_authentication.cpp b/modules/extra/m_ldap_authentication.cpp
index 935ba76d5..617929380 100644
--- a/modules/extra/m_ldap_authentication.cpp
+++ b/modules/extra/m_ldap_authentication.cpp
@@ -104,6 +104,7 @@ class IdentifyInterface : public LDAPInterface
{
na = new NickAlias(ii->req->GetAccount(), new NickCore(ii->req->GetAccount()));
FOREACH_MOD(I_OnNickRegister, OnNickRegister(ii->user, na));
+ BotInfo *NickServ = Config->GetClient("NickServ");
if (ii->user && NickServ)
ii->user->SendMessage(NickServ, _("Your account \002%s\002 has been successfully created."), na->nick.c_str());
}
@@ -164,6 +165,7 @@ class OnIdentifyInterface : public LDAPInterface
if (!email.equals_ci(u->Account()->email))
{
u->Account()->email = email;
+ BotInfo *NickServ = Config->GetClient("NickServ");
if (NickServ)
u->SendMessage(NickServ, _("Your email has been updated to \002%s\002"), email.c_str());
Log(this->owner) << "m_ldap_authentication: Updated email address for " << u->nick << " (" << u->Account()->display << ") to " << email;
diff --git a/modules/extra/m_proxyscan.cpp b/modules/extra/m_proxyscan.cpp
index 4e2a6bd88..fb5f96758 100644
--- a/modules/extra/m_proxyscan.cpp
+++ b/modules/extra/m_proxyscan.cpp
@@ -85,6 +85,7 @@ class ProxyConnect : public ConnectionSocket
reason = reason.replace_all_cs("%i", this->conaddr.addr());
reason = reason.replace_all_cs("%p", stringify(this->conaddr.port()));
+ BotInfo *OperServ = Config->GetClient("OperServ");
Log(OperServ) << "PROXYSCAN: Open " << this->GetType() << " proxy found on " << this->conaddr.addr() << ":" << this->conaddr.port() << " (" << reason << ")";
XLine *x = new XLine("*@" + this->conaddr.addr(), OperServ ? OperServ->nick : "", Anope::CurTime + this->proxy.duration, reason, XLineManager::GenerateUID());
if (add_to_akill && akills)
diff --git a/modules/extra/m_sql_authentication.cpp b/modules/extra/m_sql_authentication.cpp
index ecc8700f6..648dc22c2 100644
--- a/modules/extra/m_sql_authentication.cpp
+++ b/modules/extra/m_sql_authentication.cpp
@@ -38,6 +38,7 @@ class SQLAuthenticationResult : public SQL::Interface
catch (const SQL::Exception &) { }
NickAlias *na = NickAlias::Find(req->GetAccount());
+ BotInfo *NickServ = Config->GetClient("NickServ");
if (na == NULL)
{
na = new NickAlias(req->GetAccount(), new NickCore(req->GetAccount()));
diff --git a/modules/extra/m_sql_oper.cpp b/modules/extra/m_sql_oper.cpp
index 0289e9a22..6f9f05004 100644
--- a/modules/extra/m_sql_oper.cpp
+++ b/modules/extra/m_sql_oper.cpp
@@ -41,6 +41,7 @@ class SQLOperResult : public SQL::Interface
}
catch (const SQL::Exception &) { }
+ BotInfo *OperServ = Config->GetClient("OperServ");
if (opertype.empty())
{
if (user->Account() && user->Account()->o && !user->Account()->o->config)
diff --git a/modules/m_dnsbl.cpp b/modules/m_dnsbl.cpp
index 08d4e365d..4a3b7dddc 100644
--- a/modules/m_dnsbl.cpp
+++ b/modules/m_dnsbl.cpp
@@ -65,6 +65,7 @@ class DNSBLResolver : public Request
reason = reason.replace_all_cs("%r", record_reason);
reason = reason.replace_all_cs("%N", Config->GetBlock("networkinfo")->Get<const Anope::string>("networkname"));
+ BotInfo *OperServ = Config->GetClient("OperServ");
Log(OperServ) << "DNSBL: " << user->GetMask() << " (" << user->ip << ") appears in " << this->blacklist.name;
XLine *x = new XLine("*@" + user->ip, OperServ ? OperServ->nick : "m_dnsbl", Anope::CurTime + this->blacklist.bantime, reason, XLineManager::GenerateUID());
if (this->add_to_akill && akills)
diff --git a/modules/m_helpchan.cpp b/modules/m_helpchan.cpp
index eaf6eb777..a3003e59f 100644
--- a/modules/m_helpchan.cpp
+++ b/modules/m_helpchan.cpp
@@ -23,7 +23,7 @@ class HelpChannel : public Module
User *u = User::Find(param);
if (u && c->ci->AccessFor(u).HasPriv("OPME"))
- u->SetMode(OperServ, "HELPOP");
+ u->SetMode(Config->GetClient("OperServ"), "HELPOP");
}
return EVENT_CONTINUE;
diff --git a/modules/m_redis.cpp b/modules/m_redis.cpp
index ce3093d50..03f6f8547 100644
--- a/modules/m_redis.cpp
+++ b/modules/m_redis.cpp
@@ -176,7 +176,7 @@ class MyRedisService : public Provider
this->SendCommand(s, i, args);
}
- void Send(Interface *i, const std::vector<std::pair<const char *, size_t> > &args) anope_override
+ void Send(Interface *i, const std::vector<std::pair<const char *, size_t> > &args)
{
if (!sock)
{
@@ -202,6 +202,7 @@ class MyRedisService : public Provider
this->SendCommand(i, args);
}
+ public:
bool BlockAndProcess() anope_override
{
this->sock->ProcessWrite();
diff --git a/modules/protocol/bahamut.cpp b/modules/protocol/bahamut.cpp
index f485bd62c..ecea98329 100644
--- a/modules/protocol/bahamut.cpp
+++ b/modules/protocol/bahamut.cpp
@@ -9,8 +9,6 @@
* Based on the original code of Services by Andy Church.
*/
-/*************************************************************************/
-
#include "module.h"
class ChannelModeFlood : public ChannelModeParam
@@ -211,7 +209,7 @@ class BahamutIRCdProto : public IRCDProto
x = new XLine("*@" + u->host, old->by, old->expires, old->reason, old->id);
old->manager->AddXLine(x);
- Log(OperServ, "akill") << "AKILL: Added an akill for " << x->mask << " because " << u->GetMask() << "#" << u->realname << " matches " << old->mask;
+ Log(Config->GetClient("OperServ"), "akill") << "AKILL: Added an akill for " << x->mask << " because " << u->GetMask() << "#" << u->realname << " matches " << old->mask;
}
/* ZLine if we can instead */
@@ -292,12 +290,12 @@ class BahamutIRCdProto : public IRCDProto
void SendLogin(User *u) anope_override
{
- IRCD->SendMode(NickServ, u, "+d %d", u->signon);
+ IRCD->SendMode(Config->GetClient("NickServ"), u, "+d %d", u->signon);
}
void SendLogout(User *u) anope_override
{
- IRCD->SendMode(NickServ, u, "+d 1");
+ IRCD->SendMode(Config->GetClient("NickServ"), u, "+d 1");
}
};
@@ -368,9 +366,7 @@ struct IRCDMessageMode : IRCDMessage
*/
struct IRCDMessageNick : IRCDMessage
{
- ServiceReference<NickServService> NSService;
-
- IRCDMessageNick(Module *creator) : IRCDMessage(creator, "NICK", 2), NSService("NickServService", "NickServ") { SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
+ IRCDMessageNick(Module *creator) : IRCDMessage(creator, "NICK", 2) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
{
@@ -387,8 +383,8 @@ struct IRCDMessageNick : IRCDMessage
try
{
NickAlias *na;
- if (NSService && user->signon == convertTo<time_t>(params[7]) && (na = NickAlias::Find(user->nick)))
- NSService->Login(user, na);
+ if (user->signon == convertTo<time_t>(params[7]) && (na = NickAlias::Find(user->nick)))
+ user->Login(na->nc);
}
catch (const ConvertException &) { }
}
diff --git a/modules/protocol/charybdis.cpp b/modules/protocol/charybdis.cpp
index ec08aac65..368c79eac 100644
--- a/modules/protocol/charybdis.cpp
+++ b/modules/protocol/charybdis.cpp
@@ -196,6 +196,10 @@ struct IRCDMessageEncap : IRCDMessage
void OnSuccess() anope_override
{
+ BotInfo *NickServ = Config->GetClient("NickServ");
+ if (!NickServ)
+ return;
+
/* SVSLOGIN
* parameters: target, new nick, new username, new visible hostname, new login name
* Sent after successful SASL authentication.
@@ -212,6 +216,10 @@ struct IRCDMessageEncap : IRCDMessage
void OnFail() anope_override
{
+ BotInfo *NickServ = Config->GetClient("NickServ");
+ if (!NickServ)
+ return;
+
UplinkSocket::Message(Me) << "ENCAP " << msource.GetName() << " SASL " << NickServ->GetUID() << " " << this->uid << " " << " D F";
Log(NickServ) << "A user failed to identify for account " << this->GetAccount() << " using SASL";
@@ -219,6 +227,10 @@ struct IRCDMessageEncap : IRCDMessage
};
if (params[4] == "S")
{
+ BotInfo *NickServ = Config->GetClient("NickServ");
+ if (!NickServ)
+ return;
+
if (params[5] == "PLAIN")
UplinkSocket::Message(Me) << "ENCAP " << source.GetName() << " SASL " << NickServ->GetUID() << " " << params[2] << " C +";
else
@@ -280,6 +292,7 @@ struct IRCDMessageEUID : IRCDMessage
{
u->Login(na->nc);
+ BotInfo *NickServ = Config->GetClient("NickServ");
if (u->server->IsSynced() && NickServ)
u->SendMessage(NickServ, _("You have been logged in as \2%s\2."), na->nc->display.c_str());
}
diff --git a/modules/protocol/hybrid.cpp b/modules/protocol/hybrid.cpp
index afef85726..4649f3cf6 100644
--- a/modules/protocol/hybrid.cpp
+++ b/modules/protocol/hybrid.cpp
@@ -46,22 +46,22 @@ class HybridProto : public IRCDProto
void SendSQLine(User *, const XLine *x) anope_override
{
- UplinkSocket::Message(OperServ) << "RESV " << (x->expires ? x->expires - Anope::CurTime : 0) << " " << x->mask << " 0 :" << x->reason;
+ UplinkSocket::Message(Config->GetClient("OperServ")) << "RESV " << (x->expires ? x->expires - Anope::CurTime : 0) << " " << x->mask << " 0 :" << x->reason;
}
void SendSGLineDel(const XLine *x) anope_override
{
- UplinkSocket::Message(OperServ) << "UNXLINE * " << x->mask;
+ UplinkSocket::Message(Config->GetClient("OperServ")) << "UNXLINE * " << x->mask;
}
void SendSGLine(User *, const XLine *x) anope_override
{
- UplinkSocket::Message(OperServ) << "XLINE * " << x->mask << " 0 :" << x->GetReason();
+ UplinkSocket::Message(Config->GetClient("OperServ")) << "XLINE * " << x->mask << " 0 :" << x->GetReason();
}
void SendSZLineDel(const XLine *x) anope_override
{
- UplinkSocket::Message(OperServ) << "UNDLINE * " << x->GetHost();
+ UplinkSocket::Message(Config->GetClient("OperServ")) << "UNDLINE * " << x->GetHost();
}
void SendSZLine(User *, const XLine *x) anope_override
@@ -72,7 +72,7 @@ class HybridProto : public IRCDProto
if (timeleft > 172800 || !x->expires)
timeleft = 172800;
- UplinkSocket::Message(OperServ) << "DLINE * " << timeleft << " " << x->GetHost() << " :" << x->GetReason();
+ UplinkSocket::Message(Config->GetClient("OperServ")) << "DLINE * " << timeleft << " " << x->GetHost() << " :" << x->GetReason();
}
void SendAkillDel(const XLine *x) anope_override
@@ -80,12 +80,12 @@ class HybridProto : public IRCDProto
if (x->IsRegex() || x->HasNickOrReal())
return;
- UplinkSocket::Message(OperServ) << "UNKLINE * " << x->GetUser() << " " << x->GetHost();
+ UplinkSocket::Message(Config->GetClient("OperServ")) << "UNKLINE * " << x->GetUser() << " " << x->GetHost();
}
void SendSQLineDel(const XLine *x) anope_override
{
- UplinkSocket::Message(OperServ) << "UNRESV * " << x->mask;
+ UplinkSocket::Message(Config->GetClient("OperServ")) << "UNRESV * " << x->mask;
}
void SendJoin(User *user, Channel *c, const ChannelStatus *status) anope_override
@@ -137,7 +137,7 @@ class HybridProto : public IRCDProto
old->manager->AddXLine(xline);
x = xline;
- Log(OperServ, "akill") << "AKILL: Added an akill for " << x->mask << " because " << u->GetMask() << "#"
+ Log(Config->GetClient("OperServ"), "akill") << "AKILL: Added an akill for " << x->mask << " because " << u->GetMask() << "#"
<< u->realname << " matches " << old->mask;
}
@@ -147,7 +147,7 @@ class HybridProto : public IRCDProto
if (timeleft > 172800 || !x->expires)
timeleft = 172800;
- UplinkSocket::Message(OperServ) << "KLINE * " << timeleft << " " << x->GetUser() << " " << x->GetHost() << " :" << x->GetReason();
+ UplinkSocket::Message(Config->GetClient("OperServ")) << "KLINE * " << timeleft << " " << x->GetUser() << " " << x->GetHost() << " :" << x->GetReason();
}
void SendServer(const Server *server) anope_override
@@ -208,12 +208,12 @@ class HybridProto : public IRCDProto
void SendLogin(User *u) anope_override
{
- IRCD->SendMode(NickServ, u, "+d %s", u->Account()->display.c_str());
+ IRCD->SendMode(Config->GetClient("NickServ"), u, "+d %s", u->Account()->display.c_str());
}
void SendLogout(User *u) anope_override
{
- IRCD->SendMode(NickServ, u, "+d 0");
+ IRCD->SendMode(Config->GetClient("NickServ"), u, "+d 0");
}
void SendChannel(Channel *c) anope_override
@@ -251,7 +251,7 @@ class HybridProto : public IRCDProto
void SendSVSHold(const Anope::string &nick, time_t t) anope_override
{
- XLine x(nick, OperServ->nick, Anope::CurTime + t, "Being held for registered user");
+ XLine x(nick, Me->GetName(), Anope::CurTime + t, "Being held for registered user");
this->SendSQLine(NULL, &x);
}
@@ -486,9 +486,7 @@ struct IRCDMessageTMode : IRCDMessage
struct IRCDMessageUID : IRCDMessage
{
- ServiceReference<NickServService> NSService;
-
- IRCDMessageUID(Module *creator) : IRCDMessage(creator, "UID", 10), NSService("NickServService", "NickServ") { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); }
+ IRCDMessageUID(Module *creator) : IRCDMessage(creator, "UID", 10) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); }
/* 0 1 2 3 4 5 6 7 8 9 */
/* :0MC UID Steve 1 1350157102 +oi ~steve resolved.host 10.0.0.1 0MCAAAAAB 1350157108 :Mining all the time */
@@ -505,11 +503,11 @@ struct IRCDMessageUID : IRCDMessage
params[9], params[2].is_pos_number_only() ? convertTo<time_t>(params[2]) : 0,
params[3], params[7]);
- if (NSService && params[8] != "0")
+ if (params[8] != "0")
{
NickAlias *na = NickAlias::Find(params[8]);
if (na != NULL)
- NSService->Login(user, na);
+ user->Login(na->nc);
}
}
};
diff --git a/modules/protocol/inspircd11.cpp b/modules/protocol/inspircd11.cpp
deleted file mode 100644
index f978417f6..000000000
--- a/modules/protocol/inspircd11.cpp
+++ /dev/null
@@ -1,892 +0,0 @@
-/* inspircd 1.1 beta 6+ functions
- *
- * (C) 2003-2013 Anope Team
- * Contact us at team@anope.org
- *
- * Please read COPYING and README for further details.
- *
- * Based on the original code of Epona by Lara.
- * Based on the original code of Services by Andy Church.
- */
-
-/*************************************************************************/
-
-#include "module.h"
-
-static bool has_servicesmod = false;
-static bool has_globopsmod = false;
-static bool has_chghostmod = false;
-static bool has_chgidentmod = false;
-static bool has_hidechansmod = false;
-
-class InspIRCdProto : public IRCDProto
-{
- public:
- InspIRCdProto(Module *creator) : IRCDProto(creator, "InspIRCd 1.1")
- {
- DefaultPseudoclientModes = "+I";
- CanSVSNick = true;
- CanSVSJoin = true;
- CanSetVHost = true;
- CanSetVIdent = true;
- CanSNLine = true;
- CanSQLine = true;
- CanSZLine = true;
- CanSVSHold = true;
- CanSVSO = true;
- MaxModes = 20;
- }
- private:
-
- Anope::string current_pass;
-
- void inspircd_cmd_chgident(const Anope::string &nick, const Anope::string &vIdent)
- {
- if (has_chgidentmod)
- {
- if (nick.empty() || vIdent.empty())
- return;
- UplinkSocket::Message(OperServ) << "CHGIDENT " << nick << " " << vIdent;
- }
- else
- Log() << "CHGIDENT not loaded!";
- }
-
- void inspircd_cmd_chghost(const Anope::string &nick, const Anope::string &vhost)
- {
- if (has_chghostmod)
- {
- if (nick.empty() || vhost.empty())
- return;
- UplinkSocket::Message(OperServ) << "CHGHOST " << nick << " " << vhost;
- }
- else
- Log() << "CHGHOST not loaded!";
- }
-
- void SendGlobalNotice(const BotInfo *bi, const Server *dest, const Anope::string &msg) anope_override
- {
- UplinkSocket::Message(bi) << "NOTICE $" << dest->GetName() << " :" << msg;
- }
-
- void SendGlobalPrivmsg(const BotInfo *bi, const Server *dest, const Anope::string &msg) anope_override
- {
- UplinkSocket::Message(bi) << "PRIVMSG $" << dest->GetName() << " :" << msg;
- }
-
- void SendAkillDel(const XLine *x) anope_override
- {
- if (x->IsRegex() || x->HasNickOrReal())
- return;
-
- /* ZLine if we can instead */
- if (x->GetUser() == "*")
- {
- sockaddrs a(x->GetHost());
- if (a.valid())
- {
- IRCD->SendSZLineDel(x);
- return;
- }
- }
-
- UplinkSocket::Message(OperServ) << "GLINE " << x->mask;
- }
-
- void SendTopic(BotInfo *whosets, Channel *c) anope_override
- {
- UplinkSocket::Message(whosets) << "FTOPIC " << c->name << " " << c->topic_time << " " << c->topic_ts <<" :" << c->topic;
- }
-
- void SendVhostDel(User *u) anope_override
- {
- if (u->HasMode("CLOAK"))
- inspircd_cmd_chghost(u->nick, u->chost);
- else
- inspircd_cmd_chghost(u->nick, u->host);
-
- if (has_chgidentmod && u->GetIdent() != u->GetVIdent())
- inspircd_cmd_chgident(u->nick, u->GetIdent());
- }
-
- void SendAkill(User *u, XLine *x) anope_override
- {
- if (x->IsRegex() || x->HasNickOrReal())
- {
- if (!u)
- {
- /* No user (this akill was just added), and contains nick and/or realname. Find users that match and ban them */
- for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it)
- if (x->manager->Check(it->second, x))
- this->SendAkill(it->second, x);
- return;
- }
-
- const XLine *old = x;
-
- if (old->manager->HasEntry("*@" + u->host))
- return;
-
- /* We can't akill x as it has a nick and/or realname included, so create a new akill for *@host */
- x = new XLine("*@" + u->host, old->by, old->expires, old->reason, old->id);
- old->manager->AddXLine(x);
-
- Log(OperServ, "akill") << "AKILL: Added an akill for " << x->mask << " because " << u->GetMask() << "#" << u->realname << " matches " << old->mask;
- }
-
- /* ZLine if we can instead */
- if (x->GetUser() == "*")
- {
- sockaddrs a(x->GetHost());
- if (a.valid())
- {
- IRCD->SendSZLine(u, x);
- return;
- }
- }
-
- // Calculate the time left before this would expire, capping it at 2 days
- time_t timeleft = x->expires - Anope::CurTime;
- if (timeleft > 172800 || !x->expires)
- timeleft = 172800;
- UplinkSocket::Message(Me) << "ADDLINE G " << x->mask << " " << x->by << " " << Anope::CurTime << " " << timeleft << " :" << x->GetReason();
- }
-
- void SendSVSKillInternal(const BotInfo *source, User *user, const Anope::string &buf) anope_override
- {
- if (source)
- {
- UplinkSocket::Message(source) << "KILL " << user->nick << " :" << buf;
- user->KillInternal(source->nick, buf);
- }
- else
- {
- UplinkSocket::Message(Me) << "KILL " << user->nick << " :" << buf;
- user->KillInternal(Me->GetName(), buf);
- }
- }
-
- void SendNumericInternal(int numeric, const Anope::string &dest, const Anope::string &buf) anope_override
- {
- UplinkSocket::Message() << "PUSH " << dest << " ::" << Me->GetName() << " " << numeric << " " << dest << " " << buf;
- }
-
- void SendModeInternal(const BotInfo *source, const Channel *dest, const Anope::string &buf) anope_override
- {
- if (source)
- UplinkSocket::Message(source) << "FMODE " << dest->name << " " << dest->creation_time << " " << buf;
- else
- UplinkSocket::Message(Me) << "FMODE " << dest->name << " " << dest->creation_time << " " << buf;
- }
-
- void SendClientIntroduction(const User *u) anope_override
- {
- Anope::string modes = "+" + u->GetModes();
- UplinkSocket::Message(Me) << "NICK " << u->timestamp << " " << u->nick << " " << u->host << " " << u->host << " " << u->GetIdent() << " " << modes << " 0.0.0.0 :" << u->realname;
- UplinkSocket::Message(u) << "OPERTYPE Service";
- }
-
- /* SERVER services-dev.chatspike.net password 0 :Description here */
- void SendServer(const Server *server) anope_override
- {
- UplinkSocket::Message(Me) << "SERVER " << server->GetName() << " " << current_pass << " " << server->GetHops() << " :" << server->GetDescription();
- }
-
- /* JOIN */
- void SendJoin(User *user, Channel *c, const ChannelStatus *status) anope_override
- {
- UplinkSocket::Message(user) << "JOIN " << c->name << " " << c->creation_time;
- if (status)
- {
- /* First save the channel status incase uc->Status == status */
- ChannelStatus cs = *status;
- /* If the user is internally on the channel with flags, kill them so that
- * the stacker will allow this.
- */
- ChanUserContainer *uc = c->FindUser(user);
- if (uc != NULL)
- uc->status.Clear();
-
- BotInfo *setter = BotInfo::Find(user->nick);
- for (size_t i = 0; i < cs.Modes().length(); ++i)
- c->SetMode(setter, ModeManager::FindChannelModeByChar(cs.Modes()[i]), user->GetUID(), false);
- }
- }
-
- /* UNSQLINE */
- void SendSQLineDel(const XLine *x) anope_override
- {
- UplinkSocket::Message(OperServ) << "QLINE " << x->mask;
- }
-
- /* SQLINE */
- void SendSQLine(User *, const XLine *x) anope_override
- {
- // Calculate the time left before this would expire, capping it at 2 days
- time_t timeleft = x->expires - Anope::CurTime;
- if (timeleft > 172800 || !x->expires)
- timeleft = 172800;
- UplinkSocket::Message(Me) << "ADDLINE Q " << x->mask << " " << x->by << " " << Anope::CurTime << " " << timeleft << " :" << x->GetReason();
- }
-
- /* Functions that use serval cmd functions */
-
- void SendVhost(User *u, const Anope::string &vIdent, const Anope::string &vhost) anope_override
- {
- if (!vIdent.empty())
- inspircd_cmd_chgident(u->nick, vIdent);
- if (!vhost.empty())
- inspircd_cmd_chghost(u->nick, vhost);
- }
-
- void SendConnect() anope_override
- {
- current_pass = Config->Uplinks[Anope::CurrentUplink].password;
- SendServer(Me);
- UplinkSocket::Message() << "BURST";
- Module *enc = ModuleManager::FindFirstOf(ENCRYPTION);
- UplinkSocket::Message(Me) << "VERSION :Anope-" << Anope::Version() << " " << Me->GetName() << " :" << this->GetProtocolName() << " - (" << (enc ? enc->name : "none") << ") -- " << Anope::VersionBuildString();
- }
-
- /* SVSHOLD - set */
- void SendSVSHold(const Anope::string &nick, time_t t) anope_override
- {
- UplinkSocket::Message(OperServ) << "SVSHOLD " << nick << " " << t << "s :Being held for registered user";
- }
-
- /* SVSHOLD - release */
- void SendSVSHoldDel(const Anope::string &nick) anope_override
- {
- UplinkSocket::Message(OperServ) << "SVSHOLD " << nick;
- }
-
- /* UNSZLINE */
- void SendSZLineDel(const XLine *x) anope_override
- {
- UplinkSocket::Message(OperServ) << "ZLINE " << x->GetHost();
- }
-
- /* SZLINE */
- void SendSZLine(User *, const XLine *x) anope_override
- {
- // Calculate the time left before this would expire, capping it at 2 days
- time_t timeleft = x->expires - Anope::CurTime;
- if (timeleft > 172800 || !x->expires)
- timeleft = 172800;
- UplinkSocket::Message(Me) << "ADDLINE Z " << x->GetHost() << " " << x->by << " " << Anope::CurTime << " " << timeleft << " :" << x->GetReason();
- }
-
- void SendSVSJoin(const BotInfo *source, const User *u, const Anope::string &chan, const Anope::string &) anope_override
- {
- UplinkSocket::Message(source) << "SVSJOIN " << u->GetUID() << " " << chan;
- }
-
- void SendSVSPart(const BotInfo *source, const User *u, const Anope::string &chan, const Anope::string &param) anope_override
- {
- if (!param.empty())
- UplinkSocket::Message(source) << "SVSPART " << u->GetUID() << " " << chan << " :" << param;
- else
- UplinkSocket::Message(source) << "SVSPART " << u->GetUID() << " " << chan;
- }
-
- void SendBOB() anope_override
- {
- UplinkSocket::Message() << "BURST " << Anope::CurTime;
- }
-
- void SendEOB() anope_override
- {
- UplinkSocket::Message() << "ENDBURST";
- }
-
- void SendLogin(User *u) anope_override
- {
- if (!u->Account())
- return;
-
- Anope::string svidbuf = stringify(u->timestamp);
- u->Account()->Extend("authenticationtoken", new ExtensibleItemClass<Anope::string>(svidbuf));
- }
-
- void SendLogout(User *u) anope_override
- {
- }
-};
-
-class ChannelModeFlood : public ChannelModeParam
-{
- public:
- ChannelModeFlood(char modeChar, bool minusNoArg) : ChannelModeParam("FLOOD", modeChar, minusNoArg) { }
-
- bool IsValid(const Anope::string &value) const anope_override
- {
- try
- {
- Anope::string rest;
- if (!value.empty() && value[0] != ':' && convertTo<int>(value[0] == '*' ? value.substr(1) : value, rest, false) > 0 && rest[0] == ':' && rest.length() > 1 && convertTo<int>(rest.substr(1), rest, false) > 0 && rest.empty())
- return true;
- }
- catch (const ConvertException &) { }
-
- return false;
- }
-};
-
-struct IRCDMessageCapab : Message::Capab
-{
- IRCDMessageCapab(Module *creator) : Message::Capab(creator, "CAPAB") { SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
-
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
- {
- if (params[0].equals_cs("START"))
- {
- /* reset CAPAB */
- has_servicesmod = false;
- has_globopsmod = false;
- has_chghostmod = false;
- has_chgidentmod = false;
- has_hidechansmod = false;
- IRCD->CanSVSHold = false;
- }
- else if (params[0].equals_cs("MODULES") && params.size() > 1)
- {
- if (params[1].find("m_globops.so") != Anope::string::npos)
- has_globopsmod = true;
- if (params[1].find("m_services.so") != Anope::string::npos)
- has_servicesmod = true;
- if (params[1].find("m_svshold.so") != Anope::string::npos)
- IRCD->CanSVSHold = true;
- if (params[1].find("m_chghost.so") != Anope::string::npos)
- has_chghostmod = true;
- if (params[1].find("m_chgident.so") != Anope::string::npos)
- has_chgidentmod = true;
- if (params[1].find("m_hidechans.so") != Anope::string::npos)
- has_hidechansmod = true;
- }
- else if (params[0].equals_cs("CAPABILITIES") && params.size() > 1)
- {
- spacesepstream ssep(params[1]);
- Anope::string capab;
- while (ssep.GetToken(capab))
- {
- if (capab.find("CHANMODES") != Anope::string::npos)
- {
- Anope::string modes(capab.begin() + 10, capab.end());
- commasepstream sep(modes);
- Anope::string modebuf;
-
- sep.GetToken(modebuf);
- for (size_t t = 0, end = modebuf.length(); t < end; ++t)
- {
- switch (modebuf[t])
- {
- case 'b':
- ModeManager::AddChannelMode(new ChannelModeList("BAN", 'b'));
- continue;
- case 'e':
- ModeManager::AddChannelMode(new ChannelModeList("EXCEPT", 'e'));
- continue;
- case 'I':
- ModeManager::AddChannelMode(new ChannelModeList("INVITEOVERRIDE", 'I'));
- continue;
- default:
- ModeManager::AddChannelMode(new ChannelModeList("", modebuf[t]));
- }
- }
-
- sep.GetToken(modebuf);
- for (size_t t = 0, end = modebuf.length(); t < end; ++t)
- {
- switch (modebuf[t])
- {
- case 'k':
- ModeManager::AddChannelMode(new ChannelModeKey('k'));
- continue;
- default:
- ModeManager::AddChannelMode(new ChannelModeParam("", modebuf[t]));
- }
- }
-
- sep.GetToken(modebuf);
- for (size_t t = 0, end = modebuf.length(); t < end; ++t)
- {
- switch (modebuf[t])
- {
- case 'f':
- ModeManager::AddChannelMode(new ChannelModeFlood('f', false));
- continue;
- case 'l':
- ModeManager::AddChannelMode(new ChannelModeParam("LIMIT", 'l', true));
- continue;
- case 'L':
- ModeManager::AddChannelMode(new ChannelModeParam("REDIRECT", 'L', true));
- continue;
- default:
- ModeManager::AddChannelMode(new ChannelModeParam("", modebuf[t], true));
- }
- }
-
- sep.GetToken(modebuf);
- for (size_t t = 0, end = modebuf.length(); t < end; ++t)
- {
- switch (modebuf[t])
- {
- case 'i':
- ModeManager::AddChannelMode(new ChannelMode("INVITE", 'i'));
- continue;
- case 'm':
- ModeManager::AddChannelMode(new ChannelMode("MODERATED", 'm'));
- continue;
- case 'n':
- ModeManager::AddChannelMode(new ChannelMode("NOEXTERNAL", 'n'));
- continue;
- case 'p':
- ModeManager::AddChannelMode(new ChannelMode("PRIVATE", 'p'));
- continue;
- case 's':
- ModeManager::AddChannelMode(new ChannelMode("SECRET", 's'));
- continue;
- case 't':
- ModeManager::AddChannelMode(new ChannelMode("TOPIC", 't'));
- continue;
- case 'r':
- ModeManager::AddChannelMode(new ChannelModeRegistered('r'));
- continue;
- case 'c':
- ModeManager::AddChannelMode(new ChannelMode("BLOCKCOLOR", 'c'));
- continue;
- case 'u':
- ModeManager::AddChannelMode(new ChannelMode("AUDITORIUM", 'u'));
- continue;
- case 'z':
- ModeManager::AddChannelMode(new ChannelMode("SSL", 'z'));
- continue;
- case 'A':
- ModeManager::AddChannelMode(new ChannelMode("ALLINVITE", 'A'));
- continue;
- case 'C':
- ModeManager::AddChannelMode(new ChannelMode("NOCTCP", 'C'));
- continue;
- case 'G':
- ModeManager::AddChannelMode(new ChannelMode("FILTER", 'G'));
- continue;
- case 'K':
- ModeManager::AddChannelMode(new ChannelMode("NOKNOCK", 'K'));
- continue;
- case 'N':
- ModeManager::AddChannelMode(new ChannelMode("NONICK", 'N'));
- continue;
- case 'O':
- ModeManager::AddChannelMode(new ChannelModeOper('O'));
- continue;
- case 'Q':
- ModeManager::AddChannelMode(new ChannelMode("NOKICK", 'Q'));
- continue;
- case 'R':
- ModeManager::AddChannelMode(new ChannelMode("REGISTEREDONLY", 'R'));
- continue;
- case 'S':
- ModeManager::AddChannelMode(new ChannelMode("STRIPCOLOR", 'S'));
- continue;
- case 'V':
- ModeManager::AddChannelMode(new ChannelMode("NOINVITE", 'V'));
- continue;
- default:
- ModeManager::AddChannelMode(new ChannelMode("", modebuf[t]));
- }
- }
- }
- else if (capab.find("PREFIX=(") != Anope::string::npos)
- {
- Anope::string modes(capab.begin() + 8, capab.begin() + capab.find(')'));
- Anope::string chars(capab.begin() + capab.find(')') + 1, capab.end());
- unsigned short level = modes.length() - 1;
-
- for (size_t t = 0, end = modes.length(); t < end; ++t)
- {
- switch (modes[t])
- {
- case 'q':
- ModeManager::AddChannelMode(new ChannelModeStatus("OWNER", 'q', '~', level--));
- continue;
- case 'a':
- ModeManager::AddChannelMode(new ChannelModeStatus("PROTECT", 'a', '&', level--));
- continue;
- case 'o':
- ModeManager::AddChannelMode(new ChannelModeStatus("OP", 'o', '@', level--));
- continue;
- case 'h':
- ModeManager::AddChannelMode(new ChannelModeStatus("HALFOP", 'h', '%', level--));
- continue;
- case 'v':
- ModeManager::AddChannelMode(new ChannelModeStatus("VOICE", 'v', '+', level--));
- continue;
- default:
- ModeManager::AddChannelMode(new ChannelModeStatus("", modes[t], chars[t], level--));
- }
- }
-
- ModeManager::RebuildStatusModes();
- }
- else if (capab.find("MAXMODES=") != Anope::string::npos)
- {
- Anope::string maxmodes(capab.begin() + 9, capab.end());
- IRCD->MaxModes = maxmodes.is_pos_number_only() ? convertTo<unsigned>(maxmodes) : 3;
- }
- }
- }
- else if (params[0].equals_cs("END"))
- {
- if (!has_globopsmod)
- {
- UplinkSocket::Message() << "ERROR :m_globops is not loaded. This is required by Anope";
- Anope::QuitReason = "ERROR: Remote server does not have the m_globops module loaded, and this is required.";
- Anope::Quitting = true;
- return;
- }
- if (!has_servicesmod)
- {
- UplinkSocket::Message() << "ERROR :m_services is not loaded. This is required by Anope";
- Anope::QuitReason = "ERROR: Remote server does not have the m_services module loaded, and this is required.";
- Anope::Quitting = true;
- return;
- }
- if (!has_hidechansmod)
- {
- UplinkSocket::Message() << "ERROR :m_hidechans.so is not loaded. This is required by Anope";
- Anope::QuitReason = "ERROR: Remote server deos not have the m_hidechans module loaded, and this is required.";
- Anope::Quitting = true;
- return;
- }
- if (!IRCD->CanSVSHold)
- Log() << "SVSHOLD missing, Usage disabled until module is loaded.";
- if (!has_chghostmod)
- Log() << "CHGHOST missing, Usage disabled until module is loaded.";
- if (!has_chgidentmod)
- Log() << "CHGIDENT missing, Usage disabled until module is loaded.";
- }
-
- Message::Capab::Run(source, params);
- }
-};
-
-struct IRCDMessageChgIdent : IRCDMessage
-{
- IRCDMessageChgIdent(Module *creator, const Anope::string &n) : IRCDMessage(creator, n, 2) { }
-
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
- {
- User *u = User::Find(params[0]);
- if (!u)
- {
- Log(LOG_DEBUG) << "CHGIDENT for nonexistent user " << params[0];
- return;
- }
-
- u->SetIdent(params[1]);
- }
-};
-
-struct IRCDMessageChgName : IRCDMessage
-{
- IRCDMessageChgName(Module *creator, const Anope::string &n) : IRCDMessage(creator, n, 1) { SetFlag(IRCDMESSAGE_REQUIRE_USER); }
-
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
- {
- source.GetUser()->SetRealname(params[0]);
- }
-};
-
-struct IRCDMessageEndBurst : IRCDMessage
-{
- IRCDMessageEndBurst(Module *creator) : IRCDMessage(creator, "ENDBURST", 0) { }
-
- void Run(MessageSource &, const std::vector<Anope::string> &params) anope_override
- {
- Me->GetLinks().front()->Sync(true);
- }
-};
-
-struct IRCDMessageFHost : IRCDMessage
-{
- IRCDMessageFHost(Module *creator, const Anope::string &n) : IRCDMessage(creator, n, 1) { SetFlag(IRCDMESSAGE_REQUIRE_USER); }
-
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
- {
- source.GetUser()->SetDisplayedHost(params[0]);
- }
-};
-
-struct IRCDMessageFJoin : IRCDMessage
-{
- IRCDMessageFJoin(Module *creator) : IRCDMessage(creator, "FJOIN", 2) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
-
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
- {
- std::list<Message::Join::SJoinUser> users;
-
- spacesepstream sep(params[params.size() - 1]);
- Anope::string buf;
-
- while (sep.GetToken(buf))
- {
- Message::Join::SJoinUser sju;
-
- /* Loop through prefixes */
- for (char ch; (ch = ModeManager::GetStatusChar(buf[0]));)
- {
- ChannelMode *cm = ModeManager::FindChannelModeByChar(ch);
- buf.erase(buf.begin());
-
- if (!cm)
- {
- Log() << "Received unknown mode prefix " << ch << " in FJOIN string";
- continue;
- }
-
- sju.first.AddMode(cm->mchar);
- }
- /* Erase the , */
- buf.erase(buf.begin());
-
- sju.second = User::Find(buf);
- if (!sju.second)
- {
- Log(LOG_DEBUG) << "FJOIN for nonexistant user " << buf << " on " << params[0];
- continue;
- }
-
- }
-
- time_t ts = Anope::string(params[1]).is_pos_number_only() ? convertTo<time_t>(params[1]) : Anope::CurTime;
- Message::Join::SJoin(source, params[0], ts, "", users);
- }
-};
-
-struct IRCDMessageFMode : IRCDMessage
-{
- IRCDMessageFMode(Module *creator) : IRCDMessage(creator, "FMODE", 3) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
-
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
- {
- /* :source FMODE #test 12345678 +nto foo */
-
- Channel *c = Channel::Find(params[0]);
- if (!c)
- return;
- time_t ts = Anope::string(params[1]).is_pos_number_only() ? convertTo<time_t>(params[1]) : 0;
-
- /* TS's are equal now, so we can proceed with parsing */
- // For fun, modes sometimes get sent without a mode prefix
- Anope::string modes = "+" + params[2];
- for (unsigned n = 3; n < params.size(); ++n)
- modes += " " + params[n];
-
- c->SetModesInternal(source, modes, ts);
- }
-};
-
-struct IRCDMessageFTopic : IRCDMessage
-{
- IRCDMessageFTopic(Module *creator) : IRCDMessage(creator, "FTOPIC", 4) { }
-
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
- {
- Channel *c = Channel::Find(params[0]);
- if (c)
- c->ChangeTopicInternal(params[2], params[3], Anope::string(params[1]).is_pos_number_only() ? convertTo<time_t>(params[1]) : Anope::CurTime);
- }
-};
-
-struct IRCDMessageIdle : IRCDMessage
-{
- IRCDMessageIdle(Module *creator) : IRCDMessage(creator, "IDLE", 1) { SetFlag(IRCDMESSAGE_REQUIRE_USER); }
-
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
- {
- const BotInfo *bi = BotInfo::Find(params[0]);
- UplinkSocket::Message(bi) << "IDLE " << source.GetSource() << " " << Anope::StartTime << " " << (bi ? Anope::CurTime - bi->lastmsg : 0);
- }
-};
-
-struct IRCDMessageMode : IRCDMessage
-{
- IRCDMessageMode(Module *creator) : IRCDMessage(creator, "MODE", 2) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
-
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
- {
- if (IRCD->IsChannelValid(params[0]))
- {
- Channel *c = Channel::Find(params[0]);
- time_t ts;
-
- try
- {
- ts = convertTo<time_t>(params[2]);
- }
- catch (const ConvertException &)
- {
- ts = 0;
- }
-
- if (c)
- c->SetModesInternal(source, params[1], ts);
- }
- else
- {
- User *u = User::Find(params[0]);
- if (u)
- u->SetModesInternal("%s", params[1].c_str());
- }
- }
-};
-
-struct IRCDMessageNick : IRCDMessage
-{
- ServiceReference<NickServService> NSService;
-
- IRCDMessageNick(Module *creator) : IRCDMessage(creator, "NICK", 1), NSService("NickServService", "NickServ") { SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
-
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
- {
- if (params.size() == 8 && source.GetServer())
- {
- time_t ts = Anope::string(params[0]).is_pos_number_only() ? convertTo<time_t>(params[0]) : Anope::CurTime;
-
- User *user = new User(params[1], params[4], params[2], params[3], params[6], source.GetServer(), params[7], ts, params[5]);
- if (NSService)
- {
- NickAlias *na = NickAlias::Find(user->nick);
- Anope::string *svidbuf = na ? na->nc->GetExt<ExtensibleItemClass<Anope::string> *>("authenticationtoken") : NULL;
- if (na && svidbuf && *svidbuf == params[0])
- NSService->Login(user, na);
- }
- }
- else if (params.size() == 1 && source.GetUser())
- source.GetUser()->ChangeNick(params[0]);
- }
-};
-
-struct IRCDMessageOperType : IRCDMessage
-{
- IRCDMessageOperType(Module *creator) : IRCDMessage(creator, "OPERTYPE", 0) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); SetFlag(IRCDMESSAGE_REQUIRE_USER); }
-
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
- {
- /* opertype is equivalent to mode +o because servers
- dont do this directly */
- User *u = source.GetUser();
- if (!u->HasMode("OPER"))
- u->SetModesInternal("+o");
- }
-};
-
-struct IRCDMessageRSQuit : IRCDMessage
-{
- IRCDMessageRSQuit(Module *creator) : IRCDMessage(creator, "RSQUIT", 0) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); SetFlag(IRCDMESSAGE_REQUIRE_SERVER); }
-
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
- {
- if (params.empty() || params.size() > 3)
- return;
-
- Server *s;
- /* Horrible workaround to an insp bug (#) in how RSQUITs are sent - mark */
- if (params.size() > 1 && params[0] == Me->GetName())
- s = Server::Find(params[1]);
- else
- s = Server::Find(params[0]);
-
- source.GetServer()->Delete(source.GetServer()->GetName() + " " + (s ? s->GetName() : "<unknown>"));
- }
-};
-
-struct IRCDMessageServer : IRCDMessage
-{
- IRCDMessageServer(Module *creator) : IRCDMessage(creator, "SERVER", 4) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); }
-
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
- {
- unsigned int hops = Anope::string(params[1]).is_pos_number_only() ? convertTo<unsigned>(params[1]) : 0;
- new Server(source.GetServer() == NULL ? Me : source.GetServer(), params[0], hops, params[2]);
- }
-};
-
-class ProtoInspIRCd : public Module
-{
- InspIRCdProto ircd_proto;
-
- /* Core message handlers */
- Message::Away message_away;
- Message::Error message_error;
- Message::Invite message_invite;
- Message::Join message_join;
- Message::Kick message_kick;
- Message::Kill message_kill;
- Message::MOTD message_motd;
- Message::Part message_part;
- Message::Ping message_ping;
- Message::Privmsg message_privmsg;
- Message::Quit message_quit;
- Message::SQuit message_squit;
- Message::Stats message_stats;
- Message::Time message_time;
- Message::Topic message_topic;
- Message::Version message_version;
-
- /* Our message handlers */
- IRCDMessageCapab message_capab;
- IRCDMessageChgIdent message_chgident, message_setident;
- IRCDMessageChgName message_chgname, message_setname;
- IRCDMessageEndBurst message_endburst;
- IRCDMessageFHost message_fhost, message_sethost;
- IRCDMessageFJoin message_fjoin;
- IRCDMessageFMode message_fmode;
- IRCDMessageFTopic message_ftopic;
- IRCDMessageIdle message_idle;
- IRCDMessageMode message_mode;
- IRCDMessageNick message_nick;
- IRCDMessageOperType message_opertype;
- IRCDMessageRSQuit message_rsquit;
- IRCDMessageServer message_server;
-
- void AddModes()
- {
- ModeManager::AddUserMode(new UserMode("CALLERID", 'g'));
- ModeManager::AddUserMode(new UserMode("HELPOP", 'h'));
- ModeManager::AddUserMode(new UserMode("INVIS", 'i'));
- ModeManager::AddUserMode(new UserMode("OPER", 'o'));
- ModeManager::AddUserMode(new UserMode("REGISTERED", 'r'));
- ModeManager::AddUserMode(new UserMode("WALLOPS", 'w'));
- ModeManager::AddUserMode(new UserMode("CLOAK", 'x'));
- }
-
- public:
- ProtoInspIRCd(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PROTOCOL | VENDOR),
- ircd_proto(this),
- message_away(this), message_error(this), message_invite(this), message_join(this), message_kick(this),
- message_kill(this), message_motd(this), message_part(this), message_ping(this), message_privmsg(this),
- message_quit(this), message_squit(this), message_stats(this), message_time(this), message_topic(this),
- message_version(this),
-
- message_capab(this), message_chgident(this, "CHGIDENT"), message_setident(this, "SETIDENT"),
- message_chgname(this, "CHGNAME"), message_setname(this, "SETNAME"), message_endburst(this),
- message_fhost(this, "FHOST"), message_sethost(this, "SETHOST"), message_fjoin(this),
- message_fmode(this), message_ftopic(this), message_idle(this), message_mode(this),
- message_nick(this), message_opertype(this), message_rsquit(this), message_server(this)
- {
-
- Servers::Capab.insert("NOQUIT");
-
- this->AddModes();
-
- ModuleManager::Attach(I_OnUserNickChange, this);
- }
-
- void OnUserNickChange(User *u, const Anope::string &) anope_override
- {
- u->RemoveModeInternal(ModeManager::FindUserModeByName("REGISTERED"));
- }
-};
-
-MODULE_INIT(ProtoInspIRCd)
diff --git a/modules/protocol/inspircd12.cpp b/modules/protocol/inspircd12.cpp
index d46d8733e..f4a29bc50 100644
--- a/modules/protocol/inspircd12.cpp
+++ b/modules/protocol/inspircd12.cpp
@@ -9,8 +9,6 @@
* Based on the original code of Services by Andy Church.
*/
-/*************************************************************************/
-
#include "module.h"
class ChannelModeFlood : public ChannelModeParam
@@ -46,7 +44,7 @@ class InspIRCd12Proto : public IRCDProto
if (!Servers::Capab.count("CHGIDENT"))
Log() << "CHGIDENT not loaded!";
else
- UplinkSocket::Message(HostServ) << "CHGIDENT " << nick << " " << vIdent;
+ UplinkSocket::Message(Me) << "CHGIDENT " << nick << " " << vIdent;
}
void SendChgHostInternal(const Anope::string &nick, const Anope::string &vhost)
@@ -176,7 +174,7 @@ class InspIRCd12Proto : public IRCDProto
x = new XLine("*@" + u->host, old->by, old->expires, old->reason, old->id);
old->manager->AddXLine(x);
- Log(OperServ, "akill") << "AKILL: Added an akill for " << x->mask << " because " << u->GetMask() << "#" << u->realname << " matches " << old->mask;
+ Log(Config->GetClient("OperServ"), "akill") << "AKILL: Added an akill for " << x->mask << " because " << u->GetMask() << "#" << u->realname << " matches " << old->mask;
}
/* ZLine if we can instead */
@@ -277,13 +275,13 @@ class InspIRCd12Proto : public IRCDProto
/* SVSHOLD - set */
void SendSVSHold(const Anope::string &nick, time_t t) anope_override
{
- UplinkSocket::Message(NickServ) << "SVSHOLD " << nick << " " << t << " :Being held for registered user";
+ UplinkSocket::Message(Config->GetClient("NickServ")) << "SVSHOLD " << nick << " " << t << " :Being held for registered user";
}
/* SVSHOLD - release */
void SendSVSHoldDel(const Anope::string &nick) anope_override
{
- UplinkSocket::Message(NickServ) << "SVSHOLD " << nick;
+ UplinkSocket::Message(Config->GetClient("NickServ")) << "SVSHOLD " << nick;
}
/* UNSZLINE */
@@ -929,9 +927,7 @@ struct IRCDMessageMetadata : IRCDMessage
{
u->Login(nc);
- const NickAlias *user_na = NickAlias::Find(u->nick);
- if (!Config->GetBlock("options")->Get<bool>("nonicknameownership") && user_na && user_na->nc == nc && user_na->nc->HasExt("UNCONFIRMED") == false)
- u->SetMode(NickServ, "REGISTERED");
+ BotInfo *NickServ = Config->GetClient("nickserv");
/* Sometimes a user connects, we send them the usual "this nickname is registered" mess (if
* their server isn't syncing) and then we receive this.. so tell them about it.
@@ -1234,7 +1230,7 @@ class ProtoInspIRCd : public Module
/* InspIRCd 1.2 doesn't set -r on nick change, remove -r here. Note that if we have to set +r later
* this will cancel out this -r, resulting in no mode changes.
*/
- u->RemoveMode(NickServ, "REGISTERED");
+ u->RemoveMode(Config->GetClient("NickServ"), "REGISTERED");
}
};
diff --git a/modules/protocol/inspircd20.cpp b/modules/protocol/inspircd20.cpp
index 993c43b7a..2d7b4ef29 100644
--- a/modules/protocol/inspircd20.cpp
+++ b/modules/protocol/inspircd20.cpp
@@ -9,8 +9,6 @@
* Based on the original code of Services by Andy Church.
*/
-/*************************************************************************/
-
#include "module.h"
static bool sasl = true;
@@ -663,7 +661,7 @@ struct IRCDMessageEncap : IRCDMessage
{
UplinkSocket::Message(Me) << "ENCAP " << this->uid.substr(0, 3) << " SASL " << Me->GetSID() << " " << this->uid << " " << " D F";
- Log(NickServ) << "A user failed to identify for account " << this->GetAccount() << " using SASL";
+ Log(Config->GetClient("NickServ")) << "A user failed to identify for account " << this->GetAccount() << " using SASL";
}
};
diff --git a/modules/protocol/ngircd.cpp b/modules/protocol/ngircd.cpp
index 3d1a727e7..139c7e5c4 100644
--- a/modules/protocol/ngircd.cpp
+++ b/modules/protocol/ngircd.cpp
@@ -150,7 +150,7 @@ class ngIRCdProto : public IRCDProto
UplinkSocket::Message(Me) << "METADATA " << u->nick << " cloakhost :" << vhost;
if (!u->HasMode("CLOAK"))
{
- u->SetMode(HostServ, "CLOAK");
+ u->SetMode(Config->GetClient("HostServ"), "CLOAK");
ModeManager::ProcessModes();
}
}
diff --git a/modules/protocol/plexus.cpp b/modules/protocol/plexus.cpp
index 484f6a4bc..9f7e094a2 100644
--- a/modules/protocol/plexus.cpp
+++ b/modules/protocol/plexus.cpp
@@ -83,7 +83,7 @@ class PlexusProto : public IRCDProto
void SendVhostDel(User *u) anope_override
{
if (u->HasMode("CLOAK"))
- u->RemoveMode(HostServ, "CLOAK");
+ u->RemoveMode(Config->GetClient("HostServ"), "CLOAK");
else
this->SendVhost(u, u->GetIdent(), u->chost);
}
@@ -186,8 +186,6 @@ struct IRCDMessageEncap : IRCDMessage
if (u && nc)
{
u->Login(nc);
- if (!Config->GetBlock("options")->Get<bool>("nonicknameownership") && user_na && user_na->nc == nc && user_na->nc->HasExt("UNCONFIRMED") == false)
- u->SetMode(NickServ, "REGISTERED");
}
}
@@ -239,9 +237,7 @@ struct IRCDMessageServer : IRCDMessage
struct IRCDMessageUID : IRCDMessage
{
- ServiceReference<NickServService> NSService;
-
- IRCDMessageUID(Module *creator) : IRCDMessage(creator, "UID", 11), NSService("NickServService", "NickServ") { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); }
+ IRCDMessageUID(Module *creator) : IRCDMessage(creator, "UID", 11) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); }
/*
params[0] = nick
@@ -277,11 +273,11 @@ struct IRCDMessageUID : IRCDMessage
User *user = new User(params[0], params[4], params[9], params[5], ip, source.GetServer(), params[10], ts, params[3], params[7]);
try
{
- if (NSService && params[8].is_pos_number_only() && convertTo<time_t>(params[8]) == user->timestamp)
+ if (params[8].is_pos_number_only() && convertTo<time_t>(params[8]) == user->timestamp)
{
NickAlias *na = NickAlias::Find(user->nick);
if (na)
- NSService->Login(user, na);
+ user->Login(na->nc);
}
}
catch (const ConvertException &) { }
diff --git a/modules/protocol/ratbox.cpp b/modules/protocol/ratbox.cpp
index 2b971b23f..fe4caabdf 100644
--- a/modules/protocol/ratbox.cpp
+++ b/modules/protocol/ratbox.cpp
@@ -105,10 +105,6 @@ struct IRCDMessageEncap : IRCDMessage
if (!nc)
return;
u->Login(nc);
-
- const NickAlias *user_na = NickAlias::Find(u->nick);
- if (!Config->GetBlock("options")->Get<bool>("nonicknameownership") && user_na && user_na->nc == nc && user_na->nc->HasExt("UNCONFIRMED") == false)
- u->SetMode(NickServ, "REGISTERED");
}
}
};
diff --git a/modules/protocol/unreal.cpp b/modules/protocol/unreal.cpp
index 6ca10af14..6cf07342e 100644
--- a/modules/protocol/unreal.cpp
+++ b/modules/protocol/unreal.cpp
@@ -9,8 +9,6 @@
* Based on the original code of Services by Andy Church.
*/
-/*************************************************************************/
-
#include "module.h"
static bool sasl = true;
@@ -76,6 +74,7 @@ class UnrealIRCdProto : public IRCDProto
void SendVhostDel(User *u) anope_override
{
+ BotInfo *HostServ = Config->GetClient("HostServ");
u->RemoveMode(HostServ, "CLOAK");
u->RemoveMode(HostServ, "VHOST");
ModeManager::ProcessModes();
@@ -105,7 +104,7 @@ class UnrealIRCdProto : public IRCDProto
old->manager->AddXLine(xline);
x = xline;
- Log(OperServ, "akill") << "AKILL: Added an akill for " << x->mask << " because " << u->GetMask() << "#" << u->realname << " matches " << old->mask;
+ Log(Config->GetClient("OperServ"), "akill") << "AKILL: Added an akill for " << x->mask << " because " << u->GetMask() << "#" << u->realname << " matches " << old->mask;
}
/* ZLine if we can instead */
@@ -347,14 +346,14 @@ class UnrealIRCdProto : public IRCDProto
return;
if (Servers::Capab.count("ESVID") > 0)
- IRCD->SendMode(NickServ, u, "+d %s", u->Account()->display.c_str());
+ IRCD->SendMode(Config->GetClient("NickServ"), u, "+d %s", u->Account()->display.c_str());
else
- IRCD->SendMode(NickServ, u, "+d %d", u->signon);
+ IRCD->SendMode(Config->GetClient("NickServ"), u, "+d %d", u->signon);
}
void SendLogout(User *u) anope_override
{
- IRCD->SendMode(NickServ, u, "+d 0");
+ IRCD->SendMode(Config->GetClient("NickServ"), u, "+d 0");
}
void SendChannel(Channel *c) anope_override
@@ -754,9 +753,7 @@ struct IRCDMessageNetInfo : IRCDMessage
struct IRCDMessageNick : IRCDMessage
{
- ServiceReference<NickServService> NSService;
-
- IRCDMessageNick(Module *creator) : IRCDMessage(creator, "NICK", 2), NSService("NickServService", "NickServ") { SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
+ IRCDMessageNick(Module *creator) : IRCDMessage(creator, "NICK", 2) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
/*
** NICK - new
@@ -822,8 +819,8 @@ struct IRCDMessageNick : IRCDMessage
na = NickAlias::Find(params[6]);
}
- if (na && NSService)
- NSService->Login(user, na);
+ if (na)
+ user->Login(na->nc);
}
else
source.GetUser()->ChangeNick(params[0]);
@@ -877,7 +874,7 @@ struct IRCDMessageSASL : IRCDMessage
UplinkSocket::Message() << "SASL " << this->uid.substr(0, p) << " " << this->uid << " D F";
- Log(NickServ) << "A user failed to identify for account " << this->GetAccount() << " using SASL";
+ Log(Config->GetClient("NickServ")) << "A user failed to identify for account " << this->GetAccount() << " using SASL";
}
};
diff --git a/modules/pseudoclients/botserv.cpp b/modules/pseudoclients/botserv.cpp
index 5a84d1e7f..828f3b0e2 100644
--- a/modules/pseudoclients/botserv.cpp
+++ b/modules/pseudoclients/botserv.cpp
@@ -9,40 +9,35 @@
* Based on the original code of Services by Andy Church.
*/
-/*************************************************************************/
-
#include "module.h"
class BotServCore : public Module
{
+ Reference<BotInfo> BotServ;
+
public:
BotServCore(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PSEUDOCLIENT | VENDOR)
{
- Implementation i[] = { I_OnReload, I_OnSetCorrectModes, I_OnBotAssign, I_OnBotDelete, I_OnPrivmsg, I_OnJoinChannel, I_OnLeaveChannel,
+ Implementation i[] = { I_OnReload, I_OnSetCorrectModes, I_OnBotAssign, I_OnPrivmsg, I_OnJoinChannel, I_OnLeaveChannel,
I_OnPreHelp, I_OnPostHelp, I_OnChannelModeSet, I_OnCreateChan, I_OnUserKicked, I_OnCreateBot };
ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation));
}
- ~BotServCore()
- {
- BotServ = NULL;
- }
-
void OnReload(Configuration::Conf *conf) anope_override
{
const Anope::string &bsnick = conf->GetModule(this)->Get<const Anope::string>("client");
if (bsnick.empty())
- throw ConfigException(this->name + ": <client> must be defined");
+ throw ConfigException(Module::name + ": <client> must be defined");
BotInfo *bi = BotInfo::Find(bsnick, true);
if (!bi)
- throw ConfigException(this->name + ": no bot named " + bsnick);
+ throw ConfigException(Module::name + ": no bot named " + bsnick);
BotServ = bi;
}
- void OnSetCorrectModes(User *user, Channel *chan, AccessGroup &access, bool give_modes) anope_override
+ void OnSetCorrectModes(User *user, Channel *chan, AccessGroup &access, bool &give_modes, bool &take_modes) anope_override
{
/* Do not allow removing bot modes on our service bots */
if (chan->ci && chan->ci->bi == user)
@@ -62,12 +57,6 @@ class BotServCore : public Module
}
}
- void OnBotDelete(BotInfo *bi) anope_override
- {
- if (bi == BotServ)
- BotServ = NULL;
- }
-
void OnPrivmsg(User *u, Channel *c, Anope::string &msg) anope_override
{
if (!u || !c || !c->ci || !c->ci->bi || msg.empty())
@@ -256,7 +245,7 @@ class BotServCore : public Module
/* Channel is syncing from a netburst, don't destroy it as more users are probably wanting to join immediatly
* We also don't part the bot here either, if necessary we will part it after the sync
*/
- if (c->HasExt("SYNCING"))
+ if (c->syncing)
return;
/* Additionally, do not delete this channel if ChanServ/a BotServ bot is inhabiting it */
@@ -305,7 +294,7 @@ class BotServCore : public Module
void OnPostHelp(CommandSource &source, const std::vector<Anope::string> &params) anope_override
{
- if (!params.empty() || source.c || source.service != BotServ)
+ if (!params.empty() || source.c || source.service != *BotServ)
return;
source.Reply(_(" \n"
diff --git a/modules/pseudoclients/chanserv.cpp b/modules/pseudoclients/chanserv.cpp
index 7b0234d2e..5a1fed00b 100644
--- a/modules/pseudoclients/chanserv.cpp
+++ b/modules/pseudoclients/chanserv.cpp
@@ -9,65 +9,23 @@
* Based on the original code of Services by Andy Church.
*/
-/*************************************************************************/
-
#include "module.h"
-class ExpireCallback : public Timer
+class ChanServCore : public Module, public ChanServService
{
- public:
- ExpireCallback(Module *o) : Timer(o, Config->GetBlock("options")->Get<time_t>("expiretimeout"), Anope::CurTime, true) { }
+ Reference<BotInfo> ChanServ;
+ std::vector<Anope::string> defaults;
- void Tick(time_t) anope_override
+ public:
+ ChanServCore(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PSEUDOCLIENT | VENDOR),
+ ChanServService(this)
{
- time_t chanserv_expire = Config->GetModule("chanserv")->Get<time_t>("expire", "14d");
-
- if (!chanserv_expire || Anope::NoExpire || Anope::ReadOnly)
- return;
-
- for (registered_channel_map::const_iterator it = RegisteredChannelList->begin(), it_end = RegisteredChannelList->end(); it != it_end; )
- {
- ChannelInfo *ci = it->second;
- ++it;
-
- bool expire = false;
-
- if (Anope::CurTime - ci->last_used >= chanserv_expire)
- {
- if (ci->c)
- {
- time_t last_used = ci->last_used;
- for (Channel::ChanUserList::const_iterator cit = ci->c->users.begin(), cit_end = ci->c->users.end(); cit != cit_end && last_used == ci->last_used; ++cit)
- ci->AccessFor(cit->second->user);
- expire = last_used == ci->last_used;
- }
- else
- expire = true;
- }
-
- if (ci->HasExt("NO_EXPIRE"))
- expire = false;
-
- FOREACH_MOD(I_OnPreChanExpire, OnPreChanExpire(ci, expire));
-
- if (expire)
- {
- Anope::string extra;
- if (ci->HasExt("SUSPENDED"))
- extra = "suspended ";
-
- Log(LOG_NORMAL, "chanserv/expire") << "Expiring " << extra << "channel " << ci->name << " (founder: " << (ci->GetFounder() ? ci->GetFounder()->display : "(none)") << ")";
- FOREACH_MOD(I_OnChanExpire, OnChanExpire(ci));
- delete ci;
- }
- }
+ Implementation i[] = { I_OnReload, I_OnBotDelete, I_OnBotPrivmsg, I_OnDelCore,
+ I_OnPreHelp, I_OnPostHelp, I_OnCheckModes, I_OnCreateChan, I_OnCanSet,
+ I_OnChannelSync, I_OnBotKick, I_OnExpireTick, I_OnCheckDelete, I_OnPreUplinkSync,
+ I_OnChanRegistered, I_OnTopicUpdated };
+ ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation));
}
-};
-
-class MyChanServService : public ChanServService
-{
- public:
- MyChanServService(Module *m) : ChanServService(m) { }
void Hold(Channel *c) anope_override
{
@@ -76,13 +34,14 @@ class MyChanServService : public ChanServService
*/
class ChanServTimer : public Timer
{
+ Reference<BotInfo> &ChanServ;
Reference<Channel> c;
public:
/** Constructor
* @param chan The channel
*/
- ChanServTimer(Module *m, Channel *chan) : Timer(m, Config->GetModule(m)->Get<time_t>("inhabit", "15s")), c(chan)
+ ChanServTimer(Reference<BotInfo> &cs, Module *m, Channel *chan) : Timer(m, Config->GetModule(m)->Get<time_t>("inhabit", "15s")), ChanServ(cs), c(chan)
{
if (!ChanServ || !c)
return;
@@ -122,29 +81,7 @@ class MyChanServService : public ChanServService
if (c->HasExt("INHABIT"))
return;
- new ChanServTimer(this->owner, c);
- }
-};
-
-class ChanServCore : public Module
-{
- MyChanServService chanserv;
- ExpireCallback expires;
- std::vector<Anope::string> defaults;
-
- public:
- ChanServCore(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PSEUDOCLIENT | VENDOR),
- chanserv(this), expires(this)
- {
- Implementation i[] = { I_OnReload, I_OnBotDelete, I_OnBotPrivmsg, I_OnDelCore,
- I_OnPreHelp, I_OnPostHelp, I_OnCheckModes, I_OnCreateChan, I_OnCanSet,
- I_OnChannelSync, I_OnBotKick };
- ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation));
- }
-
- ~ChanServCore()
- {
- ChanServ = NULL;
+ new ChanServTimer(ChanServ, this->owner, c);
}
void OnReload(Configuration::Conf *conf) anope_override
@@ -152,11 +89,11 @@ class ChanServCore : public Module
const Anope::string &channick = conf->GetModule(this)->Get<const Anope::string>("client");
if (channick.empty())
- throw ConfigException(this->name + ": <client> must be defined");
+ throw ConfigException(Module::name + ": <client> must be defined");
BotInfo *bi = BotInfo::Find(channick, true);
if (!bi)
- throw ConfigException(this->name + ": no bot named " + channick);
+ throw ConfigException(Module::name + ": no bot named " + channick);
ChanServ = bi;
@@ -265,7 +202,7 @@ class ChanServCore : public Module
EventReturn OnPreHelp(CommandSource &source, const std::vector<Anope::string> &params) anope_override
{
- if (!params.empty() || source.c || source.service != ChanServ)
+ if (!params.empty() || source.c || source.service != *ChanServ)
return EVENT_CONTINUE;
source.Reply(_("\002%s\002 allows you to register and control various\n"
"aspects of channels. %s can often prevent\n"
@@ -280,7 +217,7 @@ class ChanServCore : public Module
void OnPostHelp(CommandSource &source, const std::vector<Anope::string> &params) anope_override
{
- if (!params.empty() || source.c || source.service != ChanServ)
+ if (!params.empty() || source.c || source.service != *ChanServ)
return;
time_t expire = Config->GetModule(this)->Get<time_t>("expire", "14d");
if (expire >= 86400)
@@ -354,14 +291,20 @@ class ChanServCore : public Module
bool perm = c->HasMode("PERM") || (c->ci && c->ci->HasExt("PERSIST"));
if (!perm && !c->HasExt("BOTCHANNEL") && (c->users.empty() || (c->users.size() == 1 && c->users.begin()->second->user->server == Me)))
{
- chanserv.Hold(c);
+ this->Hold(c);
}
if (c->ci)
{
c->CheckModes();
if (Me && Me->IsSynced())
- c->ci->RestoreTopic();
+ {
+ /* Update channel topic */
+ if ((c->ci->HasExt("KEEPTOPIC") || c->ci->HasExt("TOPICLOCK")) && c->ci->last_topic != c->topic)
+ {
+ c->ChangeTopic(!c->ci->last_topic_setter.empty() ? c->ci->last_topic_setter : c->ci->WhoSends()->nick, c->ci->last_topic, c->ci->last_topic_time ? c->ci->last_topic_time : Anope::CurTime);
+ }
+ }
}
}
@@ -372,14 +315,142 @@ class ChanServCore : public Module
* ChanServ always enforces channels like this to keep people from deleting bots etc
* that are holding channels.
*/
- if (c->ci && c->users.size() == (c->ci->bi && c->FindUser(c->ci->bi) ? 2 : 1) && !c->HasExt("INHABIT") && !c->HasExt("SYNCING"))
+ if (c->ci && c->users.size() == (c->ci->bi && c->FindUser(c->ci->bi) ? 2 : 1) && !c->HasExt("INHABIT") && !c->syncing)
{
/* Join ChanServ and set a timer for this channel to part ChanServ later */
- chanserv.Hold(c);
+ this->Hold(c);
}
return EVENT_CONTINUE;
}
+
+ void OnLog(Log *l) anope_override
+ {
+ if (l->type == LOG_CHANNEL)
+ l->bi = ChanServ;
+ }
+
+ void OnExpireTick() anope_override
+ {
+ time_t chanserv_expire = Config->GetModule(this)->Get<time_t>("expire", "14d");
+
+ if (!chanserv_expire || Anope::NoExpire || Anope::ReadOnly)
+ return;
+
+ for (registered_channel_map::const_iterator it = RegisteredChannelList->begin(), it_end = RegisteredChannelList->end(); it != it_end; )
+ {
+ ChannelInfo *ci = it->second;
+ ++it;
+
+ bool expire = false;
+
+ if (Anope::CurTime - ci->last_used >= chanserv_expire)
+ {
+ if (ci->c)
+ {
+ time_t last_used = ci->last_used;
+ for (Channel::ChanUserList::const_iterator cit = ci->c->users.begin(), cit_end = ci->c->users.end(); cit != cit_end && last_used == ci->last_used; ++cit)
+ ci->AccessFor(cit->second->user);
+ expire = last_used == ci->last_used;
+ }
+ else
+ expire = true;
+ }
+
+ if (ci->HasExt("NO_EXPIRE"))
+ expire = false;
+
+ FOREACH_MOD(I_OnPreChanExpire, OnPreChanExpire(ci, expire));
+
+ if (expire)
+ {
+ Anope::string extra;
+ if (ci->HasExt("SUSPENDED"))
+ extra = "suspended ";
+
+ Log(LOG_NORMAL, "chanserv/expire") << "Expiring " << extra << "channel " << ci->name << " (founder: " << (ci->GetFounder() ? ci->GetFounder()->display : "(none)") << ")";
+ FOREACH_MOD(I_OnChanExpire, OnChanExpire(ci));
+ delete ci;
+ }
+ }
+ }
+
+ EventReturn OnCheckDelete(Channel *c) anope_override
+ {
+ /* Do not delete this channel if ChanServ/a BotServ bot is inhabiting it */
+ if (c->HasExt("INHABIT"))
+ return EVENT_STOP;
+
+ /* Channel is persistent, it shouldn't be deleted and the service bot should stay */
+ if (c->ci && c->ci->HasExt("PERSIST"))
+ return EVENT_STOP;
+
+ return EVENT_CONTINUE;
+ }
+
+ void OnPreUplinkSync(Server *serv) anope_override
+ {
+ /* Find all persistent channels and create them, as we are about to finish burst to our uplink */
+ for (registered_channel_map::iterator it = RegisteredChannelList->begin(), it_end = RegisteredChannelList->end(); it != it_end; ++it)
+ {
+ ChannelInfo *ci = it->second;
+ if (ci->HasExt("PERSIST"))
+ {
+ bool created;
+ ci->c = Channel::FindOrCreate(ci->name, created, ci->time_registered);
+
+ if (ModeManager::FindChannelModeByName("PERM") != NULL)
+ {
+ if (created)
+ IRCD->SendChannel(ci->c);
+ ci->c->SetMode(NULL, "PERM");
+ }
+ else
+ {
+ if (!ci->bi)
+ ci->WhoSends()->Assign(NULL, ci);
+ if (ci->c->FindUser(ci->bi) == NULL)
+ {
+ ChannelStatus status(Config->GetModule("botserv")->Get<const Anope::string>("botmodes"));
+ ci->bi->Join(ci->c, &status);
+ }
+ }
+ }
+ }
+
+ }
+
+ void OnChanRegistered(ChannelInfo *ci) anope_override
+ {
+ /* Mark the channel as persistent */
+ if (ci->c->HasMode("PERM"))
+ ci->ExtendMetadata("PERSIST");
+ /* Persist may be in def cflags, set it here */
+ else if (ci->HasExt("PERSIST"))
+ ci->c->SetMode(NULL, "PERM");
+ }
+
+ void OnTopicUpdated(Channel *c, const Anope::string &user, const Anope::string &topic) anope_override
+ {
+ if (!c->ci)
+ return;
+
+ /* We only compare the topics here, not the time or setter. This is because some (old) IRCds do not
+ * allow us to set the topic as someone else, meaning we have to bump the TS and change the setter to us.
+ * This desyncs what is really set with what we have stored, and we end up resetting the topic often when
+ * it is not required
+ */
+ if (c->ci->HasExt("TOPICLOCK") && c->ci->last_topic != c->topic)
+ {
+ c->ChangeTopic(c->ci->last_topic_setter, c->ci->last_topic, c->ci->last_topic_time);
+ }
+ else
+ {
+ c->ci->last_topic = c->topic;
+ c->ci->last_topic_setter = c->topic_setter;
+ c->ci->last_topic_time = c->topic_ts;
+ }
+ }
};
MODULE_INIT(ChanServCore)
diff --git a/modules/pseudoclients/global.cpp b/modules/pseudoclients/global.cpp
index 67cb594c5..224cbeea1 100644
--- a/modules/pseudoclients/global.cpp
+++ b/modules/pseudoclients/global.cpp
@@ -9,12 +9,12 @@
* Based on the original code of Services by Andy Church.
*/
-/*************************************************************************/
-
#include "module.h"
-class MyGlobalService : public GlobalService
+class GlobalCore : public Module, public GlobalService
{
+ Reference<BotInfo> Global;
+
void ServerGlobal(const BotInfo *sender, Server *s, const Anope::string &message)
{
if (s != Me && !s->IsJuped())
@@ -24,12 +24,21 @@ class MyGlobalService : public GlobalService
}
public:
- MyGlobalService(Module *m) : GlobalService(m) { }
+ GlobalCore(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PSEUDOCLIENT | VENDOR),
+ GlobalService(this)
+ {
+ Implementation i[] = { I_OnReload, I_OnRestart, I_OnShutdown, I_OnNewServer, I_OnPreHelp };
+ ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation));
+ }
void SendGlobal(const BotInfo *sender, const Anope::string &source, const Anope::string &message) anope_override
{
if (Me->GetLinks().empty())
return;
+ if (!sender)
+ sender = Global;
+ if (!sender)
+ return;
Anope::string rmessage;
@@ -40,57 +49,33 @@ class MyGlobalService : public GlobalService
this->ServerGlobal(sender, Servers::GetUplink(), rmessage);
}
-};
-
-class GlobalCore : public Module
-{
- MyGlobalService global;
-
- public:
- GlobalCore(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PSEUDOCLIENT | VENDOR),
- global(this)
- {
- Implementation i[] = { I_OnReload, I_OnBotDelete, I_OnRestart, I_OnShutdown, I_OnNewServer, I_OnPreHelp };
- ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation));
- }
-
- ~GlobalCore()
- {
- Global = NULL;
- }
void OnReload(Configuration::Conf *conf) anope_override
{
const Anope::string &glnick = conf->GetModule(this)->Get<const Anope::string>("client");
if (glnick.empty())
- throw ConfigException(this->name + ": <client> must be defined");
+ throw ConfigException(Module::name + ": <client> must be defined");
BotInfo *bi = BotInfo::Find(glnick, true);
if (!bi)
- throw ConfigException(this->name + ": no bot named " + glnick);
+ throw ConfigException(Module::name + ": no bot named " + glnick);
Global = bi;
}
- void OnBotDelete(BotInfo *bi) anope_override
- {
- if (bi == Global)
- Global = NULL;
- }
-
void OnRestart() anope_override
{
const Anope::string &gl = Config->GetModule(this)->Get<const Anope::string>("globaloncycledown");
if (!gl.empty())
- this->global.SendGlobal(Global, "", gl);
+ this->SendGlobal(Global, "", gl);
}
void OnShutdown() anope_override
{
const Anope::string &gl = Config->GetModule(this)->Get<const Anope::string>("globaloncycledown");
if (!gl.empty())
- this->global.SendGlobal(Global, "", gl);
+ this->SendGlobal(Global, "", gl);
}
void OnNewServer(Server *s) anope_override
@@ -102,7 +87,7 @@ class GlobalCore : public Module
EventReturn OnPreHelp(CommandSource &source, const std::vector<Anope::string> &params) anope_override
{
- if (!params.empty() || source.c || source.service != Global)
+ if (!params.empty() || source.c || source.service != *Global)
return EVENT_CONTINUE;
source.Reply(_("%s commands:"), Global->nick.c_str());
return EVENT_CONTINUE;
diff --git a/modules/pseudoclients/hostserv.cpp b/modules/pseudoclients/hostserv.cpp
index e3afa37d3..7c98c7344 100644
--- a/modules/pseudoclients/hostserv.cpp
+++ b/modules/pseudoclients/hostserv.cpp
@@ -9,12 +9,11 @@
* Based on the original code of Services by Andy Church.
*/
-/*************************************************************************/
-
#include "module.h"
class HostServCore : public Module
{
+ Reference<BotInfo> HostServ;
public:
HostServCore(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PSEUDOCLIENT | VENDOR)
{
@@ -22,36 +21,25 @@ class HostServCore : public Module
if (!IRCD || !IRCD->CanSetVHost)
throw ModuleException("Your IRCd does not support vhosts");
- Implementation i[] = { I_OnReload, I_OnBotDelete, I_OnNickIdentify, I_OnNickUpdate, I_OnPreHelp,
+ Implementation i[] = { I_OnReload, I_OnNickIdentify, I_OnNickUpdate, I_OnPreHelp,
I_OnSetVhost, I_OnDeleteVhost };
ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation));
}
- ~HostServCore()
- {
- HostServ = NULL;
- }
-
void OnReload(Configuration::Conf *conf) anope_override
{
const Anope::string &hsnick = conf->GetModule(this)->Get<const Anope::string>("client");
if (hsnick.empty())
- throw ConfigException(this->name + ": <client> must be defined");
+ throw ConfigException(Module::name + ": <client> must be defined");
BotInfo *bi = BotInfo::Find(hsnick, true);
if (!bi)
- throw ConfigException(this->name + ": no bot named " + hsnick);
+ throw ConfigException(Module::name + ": no bot named " + hsnick);
HostServ = bi;
}
- void OnBotDelete(BotInfo *bi) anope_override
- {
- if (bi == HostServ)
- HostServ = NULL;
- }
-
void OnNickIdentify(User *u) anope_override
{
const NickAlias *na = NickAlias::Find(u->nick);
@@ -87,7 +75,7 @@ class HostServCore : public Module
EventReturn OnPreHelp(CommandSource &source, const std::vector<Anope::string> &params) anope_override
{
- if (!params.empty() || source.c || source.service != HostServ)
+ if (!params.empty() || source.c || source.service != *HostServ)
return EVENT_CONTINUE;
source.Reply(_("%s commands:"), HostServ->nick.c_str());
return EVENT_CONTINUE;
diff --git a/modules/pseudoclients/memoserv.cpp b/modules/pseudoclients/memoserv.cpp
index 1988961cd..5136e2af0 100644
--- a/modules/pseudoclients/memoserv.cpp
+++ b/modules/pseudoclients/memoserv.cpp
@@ -9,34 +9,39 @@
* Based on the original code of Services by Andy Church.
*/
-/*************************************************************************/
-
#include "module.h"
-static bool SendMemoMail(NickCore *nc, MemoInfo *mi, Memo *m)
+class MemoServCore : public Module, public MemoServService
{
- Anope::string subject = Language::Translate(nc, Config->GetBlock("mail")->Get<const Anope::string>("memo_subject").c_str()),
- message = Language::Translate(Config->GetBlock("mail")->Get<const Anope::string>("memo_message").c_str());
-
- subject = subject.replace_all_cs("%n", nc->display);
- subject = subject.replace_all_cs("%s", m->sender);
- subject = subject.replace_all_cs("%d", stringify(mi->GetIndex(m) + 1));
- subject = subject.replace_all_cs("%t", m->text);
- subject = subject.replace_all_cs("%N", Config->GetBlock("networkinfo")->Get<const Anope::string>("networkname"));
-
- message = message.replace_all_cs("%n", nc->display);
- message = message.replace_all_cs("%s", m->sender);
- message = message.replace_all_cs("%d", stringify(mi->GetIndex(m) + 1));
- message = message.replace_all_cs("%t", m->text);
- message = message.replace_all_cs("%N", Config->GetBlock("networkinfo")->Get<const Anope::string>("networkname"));
+ Reference<BotInfo> MemoServ;
- return Mail::Send(nc, subject, message);
-}
+ bool SendMemoMail(NickCore *nc, MemoInfo *mi, Memo *m)
+ {
+ Anope::string subject = Language::Translate(nc, Config->GetBlock("mail")->Get<const Anope::string>("memo_subject").c_str()),
+ message = Language::Translate(Config->GetBlock("mail")->Get<const Anope::string>("memo_message").c_str());
+
+ subject = subject.replace_all_cs("%n", nc->display);
+ subject = subject.replace_all_cs("%s", m->sender);
+ subject = subject.replace_all_cs("%d", stringify(mi->GetIndex(m) + 1));
+ subject = subject.replace_all_cs("%t", m->text);
+ subject = subject.replace_all_cs("%N", Config->GetBlock("networkinfo")->Get<const Anope::string>("networkname"));
+
+ message = message.replace_all_cs("%n", nc->display);
+ message = message.replace_all_cs("%s", m->sender);
+ message = message.replace_all_cs("%d", stringify(mi->GetIndex(m) + 1));
+ message = message.replace_all_cs("%t", m->text);
+ message = message.replace_all_cs("%N", Config->GetBlock("networkinfo")->Get<const Anope::string>("networkname"));
+
+ return Mail::Send(nc, subject, message);
+ }
-class MyMemoServService : public MemoServService
-{
public:
- MyMemoServService(Module *m) : MemoServService(m) { }
+ MemoServCore(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PSEUDOCLIENT | VENDOR),
+ MemoServService(this)
+ {
+ Implementation i[] = { I_OnNickCoreCreate, I_OnCreateChan, I_OnReload, I_OnBotDelete, I_OnNickIdentify, I_OnJoinChannel, I_OnUserAway, I_OnNickUpdate, I_OnPreHelp, I_OnPostHelp };
+ ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation));
+ }
MemoResult Send(const Anope::string &source, const Anope::string &target, const Anope::string &message, bool force) anope_override
{
@@ -134,34 +139,17 @@ class MyMemoServService : public MemoServService
u->SendMessage(MemoServ, _("You have reached your maximum number of memos (%d). You will be unable to receive any new memos until you delete some of your current ones."), nc->memos.memomax);
}
}
-};
-
-class MemoServCore : public Module
-{
- MyMemoServService memoserv;
- public:
- MemoServCore(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PSEUDOCLIENT | VENDOR),
- memoserv(this)
- {
- Implementation i[] = { I_OnNickCoreCreate, I_OnCreateChan, I_OnReload, I_OnBotDelete, I_OnNickIdentify, I_OnJoinChannel, I_OnUserAway, I_OnNickUpdate, I_OnPreHelp, I_OnPostHelp };
- ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation));
- }
-
- ~MemoServCore()
- {
- MemoServ = NULL;
- }
void OnReload(Configuration::Conf *conf) anope_override
{
const Anope::string &msnick = conf->GetModule(this)->Get<const Anope::string>("client");
if (msnick.empty())
- throw ConfigException(this->name + ": <client> must be defined");
+ throw ConfigException(Module::name + ": <client> must be defined");
BotInfo *bi = BotInfo::Find(msnick, true);
if (!bi)
- throw ConfigException(this->name + ": no bot named " + msnick);
+ throw ConfigException(Module::name + ": no bot named " + msnick);
MemoServ = bi;
}
@@ -184,7 +172,7 @@ class MemoServCore : public Module
void OnNickIdentify(User *u) anope_override
{
- this->memoserv.Check(u);
+ this->Check(u);
}
void OnJoinChannel(User *u, Channel *c) anope_override
@@ -201,17 +189,17 @@ class MemoServCore : public Module
void OnUserAway(User *u, const Anope::string &message) anope_override
{
if (message.empty())
- this->memoserv.Check(u);
+ this->Check(u);
}
void OnNickUpdate(User *u) anope_override
{
- this->memoserv.Check(u);
+ this->Check(u);
}
EventReturn OnPreHelp(CommandSource &source, const std::vector<Anope::string> &params) anope_override
{
- if (!params.empty() || source.c || source.service != MemoServ)
+ if (!params.empty() || source.c || source.service != *MemoServ)
return EVENT_CONTINUE;
source.Reply(_("\002%s\002 is a utility allowing IRC users to send short\n"
"messages to other IRC users, whether they are online at\n"
@@ -224,14 +212,11 @@ class MemoServCore : public Module
void OnPostHelp(CommandSource &source, const std::vector<Anope::string> &params) anope_override
{
- if (!params.empty() || source.c || source.service != MemoServ)
+ if (!params.empty() || source.c || source.service != *MemoServ)
return;
source.Reply(_(" \n"
"Type \002%s%s HELP \037command\037\002 for help on any of the\n"
- "above commands.\n"
- "(*) By default, any user with at least level 10 access on a\n"
- " channel can read that channel's memos. This can be\n"
- " changed with the %s \002LEVELS\002 command."), Config->StrictPrivmsg.c_str(), MemoServ->nick.c_str(), ChanServ->nick.c_str());
+ "above commands."), Config->StrictPrivmsg.c_str(), MemoServ->nick.c_str());
}
};
diff --git a/modules/pseudoclients/nickserv.cpp b/modules/pseudoclients/nickserv.cpp
index be60f3982..642b22f2d 100644
--- a/modules/pseudoclients/nickserv.cpp
+++ b/modules/pseudoclients/nickserv.cpp
@@ -9,63 +9,116 @@
* Based on the original code of Services by Andy Church.
*/
-/*************************************************************************/
-
#include "module.h"
-class NickServCollide;
-
-typedef std::map<Anope::string, NickServCollide *> nickservcollides_map;
-
-static nickservcollides_map NickServCollides;
-
/** Timer for colliding nicks to force people off of nicknames
*/
class NickServCollide : public Timer
{
+ NickServService *service;
Reference<User> u;
+ Reference<NickAlias> na;
+
+ public:
+ NickServCollide(NickServService *nss, User *user, NickAlias *nick, time_t delay) : Timer(delay), service(nss), u(user), na(nick)
+ {
+ }
+
+ void Tick(time_t t) anope_override
+ {
+ if (!u || !na)
+ return;
+ /* If they identified or don't exist anymore, don't kill them. */
+ if (u->Account() == na->nc || u->timestamp > this->GetSetTime())
+ return;
+
+ service->Collide(u, na);
+ }
+};
+
+/** Timer for removing HELD status from nicks.
+ */
+class NickServHeld : public Timer
+{
+ Reference<NickAlias> na;
+ Anope::string nick;
+ public:
+ NickServHeld(NickAlias *n, long l) : Timer(l), na(n), nick(na->nick)
+ {
+ }
+
+ void Tick(time_t)
+ {
+ if (na)
+ na->Shrink("HELD");
+ }
+};
+
+/** Timer for releasing nicks to be available for use
+ */
+class CoreExport NickServRelease : public User, public Timer
+{
+ static std::map<Anope::string, NickServRelease *> NickServReleases;
Anope::string nick;
public:
- /** Constructor
- * @param nick The nick we're colliding
- * @param delay How long to delay before kicking the user off the nick
- */
- NickServCollide(User *user, time_t delay) : Timer(delay), u(user), nick(u->nick)
+ NickServRelease(NickAlias *na, time_t delay) : User(na->nick, Config->GetBlock("options")->Get<const Anope::string>("enforceruser"),
+ Config->GetBlock("options")->Get<const Anope::string>("enforcerhost"), "", "", Me, "Services Enforcer", Anope::CurTime, "", Servers::TS6_UID_Retrieve()), Timer(delay), nick(na->nick)
{
- /* Erase the current collide and use the new one */
- nickservcollides_map::iterator nit = NickServCollides.find(user->nick);
- if (nit != NickServCollides.end())
+ /* Erase the current release timer and use the new one */
+ std::map<Anope::string, NickServRelease *>::iterator nit = NickServReleases.find(this->nick);
+ if (nit != NickServReleases.end())
+ {
+ IRCD->SendQuit(nit->second, "");
delete nit->second;
+ }
- NickServCollides.insert(std::make_pair(nick, this));
+ NickServReleases.insert(std::make_pair(this->nick, this));
+
+ IRCD->SendClientIntroduction(this);
}
- virtual ~NickServCollide()
+ ~NickServRelease()
{
- NickServCollides.erase(this->nick);
+ NickServReleases.erase(this->nick);
}
- /** Called when the delay is up
- * @param t The current time
- */
- void Tick(time_t t) anope_override
+ void Tick(time_t t)
{
- if (!u)
- return;
- /* If they identified or don't exist anymore, don't kill them. */
- NickAlias *na = NickAlias::Find(u->nick);
- if (!na || u->Account() == na->nc || u->timestamp > this->GetSetTime())
- return;
-
- u->Collide(na);
+ IRCD->SendQuit(this, "");
}
};
+std::map<Anope::string, NickServRelease *> NickServRelease::NickServReleases;
-class MyNickServService : public NickServService
+class NickServCore : public Module, public NickServService
{
+ Reference<BotInfo> NickServ;
+ std::vector<Anope::string> defaults;
+
+ void OnCancel(User *u, NickAlias *na)
+ {
+ if (na->HasExt("COLLIDED"))
+ {
+ na->Extend("HELD");
+ na->Shrink("COLLIDED");
+
+ new NickServHeld(na, Config->GetBlock("options")->Get<time_t>("releasetimeout"));
+
+ if (IRCD->CanSVSHold)
+ IRCD->SendSVSHold(na->nick, Config->GetBlock("options")->Get<time_t>("releasetimeout"));
+ else
+ new NickServRelease(na, Config->GetBlock("options")->Get<time_t>("releasetimeout"));
+ }
+ }
+
public:
- MyNickServService(Module *m) : NickServService(m) { }
+ NickServCore(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PSEUDOCLIENT | VENDOR), NickServService(this)
+ {
+ Implementation i[] = { I_OnReload, I_OnDelNick, I_OnDelCore, I_OnChangeCoreDisplay, I_OnNickIdentify, I_OnNickGroup,
+ I_OnNickUpdate, I_OnUserConnect, I_OnPostUserLogoff, I_OnServerSync, I_OnUserNickChange, I_OnPreHelp, I_OnPostHelp,
+ I_OnNickCoreCreate, I_OnUserQuit, I_OnExpireTick, I_OnUserLogin };
+ ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation));
+ }
void Validate(User *u) anope_override
{
@@ -76,7 +129,7 @@ class MyNickServService : public NickServService
if (na->nc->HasExt("SUSPENDED"))
{
u->SendMessage(NickServ, NICK_X_SUSPENDED, u->nick.c_str());
- u->Collide(na);
+ this->Collide(u, na);
return;
}
@@ -113,98 +166,79 @@ class MyNickServService : public NickServService
if (na->nc->HasExt("KILL_IMMED"))
{
u->SendMessage(NickServ, FORCENICKCHANGE_NOW);
- u->Collide(na);
+ this->Collide(u, na);
}
else if (na->nc->HasExt("KILL_QUICK"))
{
time_t killquick = Config->GetModule("nickserv")->Get<time_t>("killquick", "60s");
u->SendMessage(NickServ, _("If you do not change within %s, I will change your nick."), Anope::Duration(killquick, u->Account()).c_str());
- new NickServCollide(u, killquick);
+ new NickServCollide(this, u, na, killquick);
}
else
{
time_t kill = Config->GetModule("nickserv")->Get<time_t>("kill", "20s");
u->SendMessage(NickServ, _("If you do not change within %s, I will change your nick."), Anope::Duration(kill, u->Account()).c_str());
- new NickServCollide(u, kill);
+ new NickServCollide(this, u, na, kill);
}
}
}
- void Login(User *user, NickAlias *na) anope_override
+ void OnUserLogin(User *u) anope_override
{
- const NickAlias *u_na = NickAlias::Find(user->nick);
- user->Login(na->nc);
- if (u_na && *u_na->nc == *na->nc && !Config->GetBlock("options")->Get<bool>("nonicknameownership") && na->nc->HasExt("UNCONFIRMED") == false)
- user->SetMode(NickServ, "REGISTERED");
+ NickAlias *na = NickAlias::Find(u->nick);
+ if (na && *na->nc == u->Account() && !Config->GetBlock("options")->Get<bool>("nonicknameownership") && na->nc->HasExt("UNCONFIRMED") == false)
+ u->SetMode(NickServ, "REGISTERED");
}
-};
-class ExpireCallback : public Timer
-{
- public:
- ExpireCallback(Module *o) : Timer(o, Config->GetBlock("options")->Get<time_t>("expiretimeout"), Anope::CurTime, true) { }
-
- void Tick(time_t) anope_override
+ void Collide(User *u, NickAlias *na) anope_override
{
- if (Anope::NoExpire || Anope::ReadOnly)
- return;
-
- time_t unconfirmed_expire = Config->GetModule(this->GetOwner())->Get<time_t>("unconfirmedexpire", "1d");
- time_t nickserv_expire = Config->GetModule(this->GetOwner())->Get<time_t>("expire");
+ if (na)
+ na->Extend("COLLIDED");
- for (nickalias_map::const_iterator it = NickAliasList->begin(), it_end = NickAliasList->end(); it != it_end; )
+ if (IRCD->CanSVSNick)
{
- NickAlias *na = it->second;
- ++it;
+ const Anope::string &guestprefix = Config->GetBlock("options")->Get<const Anope::string>("guestnickprefix");
+
+ Anope::string guestnick;
- User *u = User::Find(na->nick);
- if (u && (na->nc->HasExt("SECURE") ? u->IsIdentified(true) : u->IsRecognized()))
- na->last_seen = Anope::CurTime;
-
- bool expire = false;
-
- if (na->nc->HasExt("UNCONFIRMED"))
- if (unconfirmed_expire && Anope::CurTime - na->time_registered >= unconfirmed_expire)
- expire = true;
- if (nickserv_expire && Anope::CurTime - na->last_seen >= nickserv_expire)
- expire = true;
- if (na->HasExt("NO_EXPIRE"))
- expire = false;
+ int i = 0;
+ do
+ {
+ guestnick = guestprefix + stringify(static_cast<uint16_t>(rand()));
+ }
+ while (User::Find(guestnick) && i++ < 10);
- FOREACH_MOD(I_OnPreNickExpire, OnPreNickExpire(na, expire));
-
- if (expire)
+ if (i == 11)
+ u->Kill(NickServ ? NickServ->nick : "", "Services nickname-enforcer kill");
+ else
{
- Anope::string extra;
- if (na->nc->HasExt("SUSPENDED"))
- extra = "suspended ";
- Log(LOG_NORMAL, "expire") << "Expiring " << extra << "nickname " << na->nick << " (group: " << na->nc->display << ") (e-mail: " << (na->nc->email.empty() ? "none" : na->nc->email) << ")";
- FOREACH_MOD(I_OnNickExpire, OnNickExpire(na));
- delete na;
+ if (NickServ)
+ u->SendMessage(NickServ, _("Your nickname is now being changed to \002%s\002"), guestnick.c_str());
+ IRCD->SendForceNickChange(u, guestnick, Anope::CurTime);
}
}
+ else
+ u->Kill(NickServ ? NickServ->nick : "", "Services nickname-enforcer kill");
}
-};
-class NickServCore : public Module
-{
- MyNickServService nickserv;
- ExpireCallback expires;
- std::vector<Anope::string> defaults;
-
- public:
- NickServCore(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PSEUDOCLIENT | VENDOR), nickserv(this), expires(this)
+ void Release(NickAlias *na) anope_override
{
- Implementation i[] = { I_OnReload, I_OnBotDelete, I_OnDelNick, I_OnDelCore, I_OnChangeCoreDisplay, I_OnNickIdentify, I_OnNickGroup,
- I_OnNickUpdate, I_OnUserConnect, I_OnPostUserLogoff, I_OnServerSync, I_OnUserNickChange, I_OnPreHelp, I_OnPostHelp,
- I_OnNickCoreCreate, I_OnUserQuit };
- ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation));
- }
+ if (na->HasExt("HELD"))
+ {
+ if (IRCD->CanSVSHold)
+ IRCD->SendSVSHoldDel(na->nick);
+ else
+ {
+ User *u = User::Find(na->nick);
+ if (u && u->server == Me)
+ {
+ u->Quit();
+ }
+ }
- ~NickServCore()
- {
- NickServ = NULL;
+ na->Shrink("HELD");
+ }
}
void OnReload(Configuration::Conf *conf) anope_override
@@ -212,11 +246,11 @@ class NickServCore : public Module
const Anope::string &nsnick = conf->GetModule(this)->Get<const Anope::string>("client");
if (nsnick.empty())
- throw ConfigException(this->name + ": <client> must be defined");
+ throw ConfigException(Module::name + ": <client> must be defined");
BotInfo *bi = BotInfo::Find(nsnick, true);
if (!bi)
- throw ConfigException(this->name + ": no bot named " + nsnick);
+ throw ConfigException(Module::name + ": no bot named " + nsnick);
NickServ = bi;
@@ -229,12 +263,6 @@ class NickServCore : public Module
}
}
- void OnBotDelete(BotInfo *bi) anope_override
- {
- if (bi == NickServ)
- NickServ = NULL;
- }
-
void OnDelNick(NickAlias *na) anope_override
{
User *u = User::Find(na->nick);
@@ -284,7 +312,7 @@ class NickServCore : public Module
ChanUserContainer *cc = it->second;
Channel *c = cc->chan;
if (c)
- c->SetCorrectModes(u, true, true);
+ c->SetCorrectModes(u, true);
}
const Anope::string &modesonid = block->Get<const Anope::string>("modesonid");
@@ -325,7 +353,7 @@ class NickServCore : public Module
ChanUserContainer *cc = it->second;
Channel *c = cc->chan;
if (c)
- c->SetCorrectModes(u, true, true);
+ c->SetCorrectModes(u, true);
}
}
@@ -340,14 +368,14 @@ class NickServCore : public Module
if (!Config->GetBlock("options")->Get<bool>("nonicknameownership") && !unregistered_notice.empty() && !na)
u->SendMessage(NickServ, unregistered_notice);
else if (na)
- this->nickserv.Validate(u);
+ this->Validate(u);
}
void OnPostUserLogoff(User *u) anope_override
{
NickAlias *na = NickAlias::Find(u->nick);
if (na)
- na->OnCancel(u);
+ OnCancel(u, na);
}
void OnServerSync(Server *s) anope_override
@@ -356,7 +384,7 @@ class NickServCore : public Module
{
User *u = it->second;
if (u->server == s && !u->IsIdentified())
- this->nickserv.Validate(u);
+ this->Validate(u);
}
}
@@ -369,7 +397,7 @@ class NickServCore : public Module
/* Remove +r, but keep an account associated with the user */
u->RemoveMode(NickServ, "REGISTERED");
- this->nickserv.Validate(u);
+ this->Validate(u);
}
else
{
@@ -381,7 +409,7 @@ class NickServCore : public Module
}
if (!u->nick.equals_ci(oldnick) && old_na)
- old_na->OnCancel(u);
+ OnCancel(u, old_na);
}
void OnUserModeSet(User *u, const Anope::string &mname) anope_override
@@ -392,7 +420,7 @@ class NickServCore : public Module
EventReturn OnPreHelp(CommandSource &source, const std::vector<Anope::string> &params) anope_override
{
- if (!params.empty() || source.c || source.service != NickServ)
+ if (!params.empty() || source.c || source.service != *NickServ)
return EVENT_CONTINUE;
if (!Config->GetBlock("options")->Get<bool>("nonicknameownership"))
source.Reply(_("\002%s\002 allows you to register a nickname and\n"
@@ -412,7 +440,7 @@ class NickServCore : public Module
void OnPostHelp(CommandSource &source, const std::vector<Anope::string> &params) anope_override
{
- if (!params.empty() || source.c || source.service != NickServ)
+ if (!params.empty() || source.c || source.service != *NickServ)
return;
if (source.IsServicesOper())
source.Reply(_(" \n"
@@ -454,6 +482,47 @@ class NickServCore : public Module
na->last_quit = msg;
}
}
+
+ void OnExpireTick() anope_override
+ {
+ if (Anope::NoExpire || Anope::ReadOnly)
+ return;
+
+ time_t unconfirmed_expire = Config->GetModule(this)->Get<time_t>("unconfirmedexpire", "1d");
+ time_t nickserv_expire = Config->GetModule(this)->Get<time_t>("expire");
+
+ for (nickalias_map::const_iterator it = NickAliasList->begin(), it_end = NickAliasList->end(); it != it_end; )
+ {
+ NickAlias *na = it->second;
+ ++it;
+
+ User *u = User::Find(na->nick);
+ if (u && (na->nc->HasExt("SECURE") ? u->IsIdentified(true) : u->IsRecognized()))
+ na->last_seen = Anope::CurTime;
+
+ bool expire = false;
+
+ if (na->nc->HasExt("UNCONFIRMED"))
+ if (unconfirmed_expire && Anope::CurTime - na->time_registered >= unconfirmed_expire)
+ expire = true;
+ if (nickserv_expire && Anope::CurTime - na->last_seen >= nickserv_expire)
+ expire = true;
+ if (na->HasExt("NO_EXPIRE"))
+ expire = false;
+
+ FOREACH_MOD(I_OnPreNickExpire, OnPreNickExpire(na, expire));
+
+ if (expire)
+ {
+ Anope::string extra;
+ if (na->nc->HasExt("SUSPENDED"))
+ extra = "suspended ";
+ Log(LOG_NORMAL, "expire") << "Expiring " << extra << "nickname " << na->nick << " (group: " << na->nc->display << ") (e-mail: " << (na->nc->email.empty() ? "none" : na->nc->email) << ")";
+ FOREACH_MOD(I_OnNickExpire, OnNickExpire(na));
+ delete na;
+ }
+ }
+ }
};
MODULE_INIT(NickServCore)
diff --git a/modules/pseudoclients/operserv.cpp b/modules/pseudoclients/operserv.cpp
index c514536fa..85984327c 100644
--- a/modules/pseudoclients/operserv.cpp
+++ b/modules/pseudoclients/operserv.cpp
@@ -9,8 +9,6 @@
* Based on the original code of Services by Andy Church.
*/
-/*************************************************************************/
-
#include "module.h"
class SGLineManager : public XLineManager
@@ -25,7 +23,7 @@ class SGLineManager : public XLineManager
void OnExpire(const XLine *x) anope_override
{
- Log(OperServ, "expire/akill") << "AKILL on \002" << x->mask << "\002 has expired";
+ Log(Config->GetClient("OperServ"), "expire/akill") << "AKILL on \002" << x->mask << "\002 has expired";
}
void Send(User *u, XLine *x) anope_override
@@ -80,7 +78,7 @@ class SQLineManager : public XLineManager
void OnExpire(const XLine *x) anope_override
{
- Log(OperServ, "expire/sqline") << "SQLINE on \002" << x->mask << "\002 has expired";
+ Log(Config->GetClient("OperServ"), "expire/sqline") << "SQLINE on \002" << x->mask << "\002 has expired";
}
void Send(User *u, XLine *x) anope_override
@@ -129,7 +127,7 @@ class SNLineManager : public XLineManager
void OnExpire(const XLine *x) anope_override
{
- Log(OperServ, "expire/snline") << "SNLINE on \002" << x->mask << "\002 has expired";
+ Log(Config->GetClient("OperServ"), "expire/snline") << "SNLINE on \002" << x->mask << "\002 has expired";
}
void Send(User *u, XLine *x) anope_override
@@ -152,6 +150,7 @@ class SNLineManager : public XLineManager
class OperServCore : public Module
{
+ Reference<BotInfo> OperServ;
SGLineManager sglines;
SQLineManager sqlines;
SNLineManager snlines;
@@ -160,7 +159,7 @@ class OperServCore : public Module
OperServCore(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PSEUDOCLIENT | VENDOR),
sglines(this), sqlines(this), snlines(this)
{
- Implementation i[] = { I_OnReload, I_OnBotDelete, I_OnBotPrivmsg, I_OnServerQuit, I_OnUserModeSet, I_OnUserModeUnset, I_OnUserConnect, I_OnUserNickChange, I_OnPreHelp };
+ Implementation i[] = { I_OnReload, I_OnBotPrivmsg, I_OnServerQuit, I_OnUserModeSet, I_OnUserModeUnset, I_OnUserConnect, I_OnUserNickChange, I_OnPreHelp, I_OnLog };
ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation));
/* Yes, these are in this order for a reason. Most violent->least violent. */
@@ -171,8 +170,6 @@ class OperServCore : public Module
~OperServCore()
{
- OperServ = NULL;
-
this->sglines.Clear();
this->sqlines.Clear();
this->snlines.Clear();
@@ -196,18 +193,12 @@ class OperServCore : public Module
OperServ = bi;
}
- void OnBotDelete(BotInfo *bi) anope_override
- {
- if (bi == OperServ)
- OperServ = NULL;
- }
-
EventReturn OnBotPrivmsg(User *u, BotInfo *bi, Anope::string &message) anope_override
{
if (bi == OperServ && !u->HasMode("OPER") && Config->GetModule(this)->Get<bool>("opersonly"))
{
u->SendMessage(bi, ACCESS_DENIED);
- Log(OperServ, "bados") << "Denied access to " << bi->nick << " from " << u->GetMask() << " (non-oper)";
+ Log(bi, "bados") << "Denied access to " << bi->nick << " from " << u->GetMask() << " (non-oper)";
return EVENT_STOP;
}
@@ -258,11 +249,17 @@ class OperServCore : public Module
EventReturn OnPreHelp(CommandSource &source, const std::vector<Anope::string> &params) anope_override
{
- if (!params.empty() || source.c || source.service != OperServ)
+ if (!params.empty() || source.c || source.service != *OperServ)
return EVENT_CONTINUE;
source.Reply(_("%s commands:"), OperServ->nick.c_str());
return EVENT_CONTINUE;
}
+
+ void OnLog(Log *l) anope_override
+ {
+ if (l->type == LOG_SERVER)
+ l->bi = OperServ;
+ }
};
MODULE_INIT(OperServCore)
diff --git a/src/bots.cpp b/src/bots.cpp
index 05dfdbe43..3ea2ef485 100644
--- a/src/bots.cpp
+++ b/src/bots.cpp
@@ -21,8 +21,6 @@
Serialize::Checker<botinfo_map> BotListByNick("BotInfo"), BotListByUID("BotInfo");
-BotInfo *BotServ = NULL, *ChanServ = NULL, *Global = NULL, *HostServ = NULL, *MemoServ = NULL, *NickServ = NULL, *OperServ = NULL;
-
BotInfo::BotInfo(const Anope::string &nnick, const Anope::string &nuser, const Anope::string &nhost, const Anope::string &nreal, const Anope::string &bmodes) : User(nnick, nuser, nhost, "", "", Me, nreal, Anope::CurTime, "", Servers::TS6_UID_Retrieve()), Serializable("BotInfo"), channels("ChannelInfo"), botmodes(bmodes)
{
this->lastmsg = this->created = Anope::CurTime;
diff --git a/src/channels.cpp b/src/channels.cpp
index bc32781de..d774b8c8d 100644
--- a/src/channels.cpp
+++ b/src/channels.cpp
@@ -34,6 +34,7 @@ Channel::Channel(const Anope::string &nname, time_t ts)
this->name = nname;
this->creation_time = ts;
+ this->syncing = false;
this->server_modetime = this->chanserv_modetime = 0;
this->server_modecount = this->chanserv_modecount = this->bouncy_modes = this->topic_ts = this->topic_time = 0;
@@ -79,7 +80,7 @@ void Channel::Reset()
}
for (ChanUserList::const_iterator it = this->users.begin(), it_end = this->users.end(); it != it_end; ++it)
- this->SetCorrectModes(it->second->user, true, false);
+ this->SetCorrectModes(it->second->user, true);
this->Sync();
}
@@ -152,21 +153,20 @@ void Channel::CheckModes()
bool Channel::CheckDelete()
{
- /* Channel is persistent, it shouldn't be deleted and the service bot should stay */
- if (this->HasExt("PERSIST") || (this->ci && this->ci->HasExt("PERSIST")))
- return false;
-
/* Channel is syncing from a netburst, don't destroy it as more users are probably wanting to join immediatly
* We also don't part the bot here either, if necessary we will part it after the sync
*/
- if (this->HasExt("SYNCING"))
+ if (this->syncing)
return false;
-
- /* Additionally, do not delete this channel if ChanServ/a BotServ bot is inhabiting it */
- if (this->HasExt("INHABIT"))
+
+ /* Permanent channels never get deleted */
+ if (this->HasMode("PERM"))
return false;
- return this->users.empty();
+ EventReturn MOD_RESULT;
+ FOREACH_RESULT(I_OnCheckDelete, OnCheckDelete(this));
+
+ return MOD_RESULT != EVENT_STOP && this->users.empty();
}
ChanUserContainer* Channel::JoinUser(User *user)
@@ -180,14 +180,6 @@ ChanUserContainer* Channel::JoinUser(User *user)
user->chans[this] = cuc;
this->users[user] = cuc;
- if (this->ci && this->ci->HasExt("PERSIST") && this->creation_time > this->ci->time_registered)
- {
- Log(LOG_DEBUG) << "Changing TS of " << this->name << " from " << this->creation_time << " to " << this->ci->time_registered;
- this->creation_time = this->ci->time_registered;
- IRCD->SendChannel(this);
- this->Reset();
- }
-
return cuc;
}
@@ -323,7 +315,7 @@ void Channel::SetModeInternal(MessageSource &setter, ChannelMode *cm, const Anop
/* Enforce secureops, etc */
if (enforce_mlock && MOD_RESULT != EVENT_STOP)
- this->SetCorrectModes(u, false, false);
+ this->SetCorrectModes(u, false);
return;
}
@@ -343,14 +335,6 @@ void Channel::SetModeInternal(MessageSource &setter, ChannelMode *cm, const Anop
cml->OnAdd(this, param);
}
- /* Channel mode +P or so was set, mark this channel as persistent */
- if (cm->name == "PERM")
- {
- this->Extend("PERSIST");
- if (this->ci)
- this->ci->ExtendMetadata("PERSIST");
- }
-
FOREACH_RESULT(I_OnChannelModeSet, OnChannelModeSet(this, setter, cm->name, param));
/* Check if we should enforce mlock */
@@ -395,7 +379,7 @@ void Channel::RemoveModeInternal(MessageSource &setter, ChannelMode *cm, const A
FOREACH_RESULT(I_OnChannelModeUnset, OnChannelModeUnset(this, setter, cm->name, param));
if (enforce_mlock && MOD_RESULT != EVENT_STOP)
- this->SetCorrectModes(u, false, false);
+ this->SetCorrectModes(u, false);
return;
}
@@ -419,20 +403,6 @@ void Channel::RemoveModeInternal(MessageSource &setter, ChannelMode *cm, const A
cml->OnDel(this, param);
}
- if (cm->name == "PERM")
- {
- this->Shrink("PERSIST");
-
- if (this->ci)
- this->ci->Shrink("PERSIST");
-
- if (this->users.empty() && !this->HasExt("SYNCING") && !this->HasExt("INHABIT"))
- {
- delete this;
- return;
- }
- }
-
FOREACH_RESULT(I_OnChannelModeUnset, OnChannelModeUnset(this, setter, cm->name, param));
/* Check for mlock */
@@ -828,9 +798,6 @@ void Channel::ChangeTopicInternal(const Anope::string &user, const Anope::string
Log(LOG_DEBUG) << "Topic of " << this->name << " changed by " << (u ? u->nick : user) << " to " << newtopic;
FOREACH_MOD(I_OnTopicUpdated, OnTopicUpdated(this, user, this->topic));
-
- if (this->ci)
- this->ci->CheckTopic();
}
void Channel::ChangeTopic(const Anope::string &user, const Anope::string &newtopic, time_t ts)
@@ -847,12 +814,9 @@ void Channel::ChangeTopic(const Anope::string &user, const Anope::string &newtop
this->topic_time = Anope::CurTime;
FOREACH_MOD(I_OnTopicUpdated, OnTopicUpdated(this, user, this->topic));
-
- if (this->ci)
- this->ci->CheckTopic();
}
-void Channel::SetCorrectModes(User *user, bool give_modes, bool check_noop)
+void Channel::SetCorrectModes(User *user, bool give_modes)
{
if (user == NULL)
return;
@@ -865,14 +829,17 @@ void Channel::SetCorrectModes(User *user, bool give_modes, bool check_noop)
AccessGroup u_access = ci->AccessFor(user);
ChannelMode *registered = ModeManager::FindChannelModeByName("REGISTERED");
- /* Only give modes if autoop isn't set */
- give_modes &= (!user->Account() || user->Account()->HasExt("AUTOOP")) && (!check_noop || !ci->HasExt("NOAUTOOP"));
/* If this channel has secureops, or the registered channel mode exists and the channel does not have +r set (aka the channel
* was created just now or while we were off), or the registered channel mode does not exist and channel is syncing (aka just
* created *to us*) and the user's server is synced (aka this isn't us doing our initial uplink - without this we would be deopping all
* users with no access on a non-secureops channel on startup), and the user's server isn't ulined, then set negative modes.
*/
- bool take_modes = (ci->HasExt("SECUREOPS") || (registered && !this->HasMode("REGISTERED")) || (!registered && this->HasExt("SYNCING") && user->server->IsSynced())) && !user->server->IsULined();
+ bool take_modes = (registered && !this->HasMode("REGISTERED")) || (!registered && this->syncing && user->server->IsSynced());
+
+ FOREACH_MOD(I_OnSetCorrectModes, OnSetCorrectModes(user, this, u_access, give_modes, take_modes));
+
+ /* Never take modes from ulines */
+ take_modes &= !user->server->IsULined();
bool given = false;
for (unsigned i = 0; i < ModeManager::GetStatusChannelModesByRank().size(); ++i)
@@ -911,8 +878,6 @@ void Channel::SetCorrectModes(User *user, bool give_modes, bool check_noop)
}
}
}
-
- FOREACH_MOD(I_OnSetCorrectModes, OnSetCorrectModes(user, this, u_access, give_modes));
}
bool Channel::Unban(User *u, bool full)
diff --git a/src/config.cpp b/src/config.cpp
index 52469c75a..d90c9728c 100644
--- a/src/config.cpp
+++ b/src/config.cpp
@@ -589,6 +589,18 @@ Block *Conf::GetModule(const Anope::string &mname)
return GetModule(mname);
}
+BotInfo *Conf::GetClient(const Anope::string &cname)
+{
+ Anope::map<Anope::string>::iterator it = bots.find(cname);
+ if (it != bots.end())
+ return BotInfo::Find(!it->second.empty() ? it->second : cname, true);
+
+ Block *block = GetModule(cname.lower());
+ const Anope::string &client = block->Get<const Anope::string>("client");
+ bots[cname] = client;
+ return GetClient(cname);
+}
+
File::File(const Anope::string &n, bool e) : name(n), executable(e), fp(NULL)
{
}
diff --git a/src/init.cpp b/src/init.cpp
index 205fb2501..0a93c07f5 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -464,9 +464,9 @@ void Anope::Init(int ac, char **av)
Log() << "Loading databases...";
EventReturn MOD_RESULT;
FOREACH_RESULT(I_OnLoadDatabase, OnLoadDatabase());
+ static_cast<void>(MOD_RESULT);
Log() << "Databases loaded";
Serialize::CheckTypes();
}
-/*************************************************************************/
diff --git a/src/logger.cpp b/src/logger.cpp
index 380e94b14..3873c1dee 100644
--- a/src/logger.cpp
+++ b/src/logger.cpp
@@ -98,9 +98,6 @@ Log::Log(const User *_u, Channel *ch, const Anope::string &cat) : bi(NULL), u(_u
{
if (!chan)
throw CoreException("Invalid pointers passed to Log::Log");
-
- if (Config)
- this->bi = ChanServ;
}
Log::Log(const User *_u, const Anope::string &cat, const BotInfo *_bi) : bi(_bi), u(_u), nc(NULL), c(NULL), chan(NULL), ci(NULL), s(NULL), m(NULL), type(LOG_USER), category(cat)
@@ -113,9 +110,6 @@ Log::Log(Server *serv, const Anope::string &cat, const BotInfo *_bi) : bi(_bi),
{
if (!s)
throw CoreException("Invalid pointer passed to Log::Log");
-
- if (!this->bi)
- this->bi = OperServ;
}
Log::Log(const BotInfo *b, const Anope::string &cat) : bi(b), u(NULL), nc(NULL), c(NULL), chan(NULL), ci(NULL), s(NULL), m(NULL), type(LOG_NORMAL), category(cat)
@@ -134,13 +128,13 @@ Log::~Log()
std::cout << GetTimeStamp() << " " << this->BuildPrefix() << this->buf.str() << std::endl;
else if (this->type == LOG_TERMINAL)
std::cout << this->BuildPrefix() << this->buf.str() << std::endl;
+
+ FOREACH_MOD(I_OnLog, OnLog(this));
if (Config)
for (unsigned i = 0; i < Config->LogInfos.size(); ++i)
if (Config->LogInfos[i].HasType(this->type, this->category))
Config->LogInfos[i].ProcessMessage(this);
-
- FOREACH_MOD(I_OnLog, OnLog(this));
}
Anope::string Log::BuildPrefix() const
diff --git a/src/main.cpp b/src/main.cpp
index 99174279b..576df28a6 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -47,20 +47,30 @@ class UpdateTimer : public Timer
public:
UpdateTimer(time_t timeout) : Timer(timeout, Anope::CurTime, true) { }
- void Tick(time_t)
+ void Tick(time_t) anope_override
{
Anope::SaveDatabases();
}
};
+class ExpireTimer : public Timer
+{
+ public:
+ ExpireTimer(time_t timeout) : Timer(timeout, Anope::CurTime, true) { }
+
+ void Tick(time_t) anope_override
+ {
+ FOREACH_MOD(I_OnExpireTick, OnExpireTick());
+ }
+};
+
void Anope::SaveDatabases()
{
if (Anope::ReadOnly)
return;
- EventReturn MOD_RESULT;
- FOREACH_RESULT(I_OnSaveDatabase, OnSaveDatabase());
Log(LOG_DEBUG) << "Saving databases";
+ FOREACH_MOD(I_OnSaveDatabase, OnSaveDatabase());
}
/** The following comes from InspIRCd to get the full path of the Anope executable
@@ -100,8 +110,6 @@ static Anope::string GetFullProgDir(const Anope::string &argv0)
return "/";
}
-/*************************************************************************/
-
/* Main routine. (What does it look like? :-) ) */
int main(int ac, char **av, char **envp)
@@ -150,6 +158,7 @@ int main(int ac, char **av, char **envp)
/* Set up timers */
time_t last_check = Anope::CurTime;
UpdateTimer updateTimer(Config->GetBlock("options")->Get<time_t>("updatetimeout"));
+ ExpireTimer expireTimer(Config->GetBlock("options")->Get<time_t>("expiretimeout"));
/*** Main loop. ***/
while (!Anope::Quitting)
diff --git a/src/memos.cpp b/src/memos.cpp
index b3f044e1e..a6cd6031a 100644
--- a/src/memos.cpp
+++ b/src/memos.cpp
@@ -75,7 +75,7 @@ Serializable* Memo::Unserialize(Serializable *obj, Serialize::Data &data)
return m;
}
-MemoInfo::MemoInfo() : memos("Memo")
+MemoInfo::MemoInfo() : memomax(0), memos("Memo")
{
}
diff --git a/src/messages.cpp b/src/messages.cpp
index 5a688a89c..d9a89ef46 100644
--- a/src/messages.cpp
+++ b/src/messages.cpp
@@ -49,7 +49,7 @@ void Error::Run(MessageSource &source, const std::vector<Anope::string> &params)
Anope::Quitting = true;
}
-void Invite::Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+void Invite::Run(MessageSource &source, const std::vector<Anope::string> &params)
{
User *targ = User::Find(params[0]);
Channel *c = Channel::Find(params[1]);
@@ -101,7 +101,7 @@ void Join::SJoin(MessageSource &source, const Anope::string &chan, time_t ts, co
bool keep_their_modes = true;
if (created)
- c->Extend("SYNCING");
+ c->syncing = true;
/* Some IRCds do not include a TS */
else if (!ts)
;
@@ -120,7 +120,7 @@ void Join::SJoin(MessageSource &source, const Anope::string &chan, time_t ts, co
/* If we are syncing, mlock is checked later in Channel::Sync. It is important to not check it here
* so that Channel::SetCorrectModes can correctly detect the presence of channel mode +r.
*/
- c->SetModesInternal(source, modes, ts, !c->HasExt("SYNCING"));
+ c->SetModesInternal(source, modes, ts, !c->syncing);
for (std::list<SJoinUser>::const_iterator it = users.begin(), it_end = users.end(); it != it_end; ++it)
{
@@ -137,16 +137,16 @@ void Join::SJoin(MessageSource &source, const Anope::string &chan, time_t ts, co
/* Set whatever modes the user should have, and remove any that
* they aren't allowed to have (secureops etc).
*/
- c->SetCorrectModes(u, true, true);
+ c->SetCorrectModes(u, true);
if (c->ci)
c->ci->CheckKick(u);
}
/* Channel is done syncing */
- if (c->HasExt("SYNCING"))
+ if (c->syncing)
{
- c->Shrink("SYNCING");
+ c->syncing = false;
/* Sync the channel (mode lock, topic, etc) */
/* the channel is synced when the netmerge is complete */
if (Me && Me->IsSynced())
@@ -444,7 +444,6 @@ void Version::Run(MessageSource &source, const std::vector<Anope::string> &param
{
Module *enc = ModuleManager::FindFirstOf(ENCRYPTION);
IRCD->SendNumeric(351, source.GetSource(), "Anope-%s %s :%s -(%s) -- %s", Anope::Version().c_str(), Me->GetName().c_str(), IRCD->GetProtocolName().c_str(), enc ? enc->name.c_str() : "(none)", Anope::VersionBuildString().c_str());
- return;
}
void Whois::Run(MessageSource &source, const std::vector<Anope::string> &params)
@@ -464,7 +463,5 @@ void Whois::Run(MessageSource &source, const std::vector<Anope::string> &params)
}
else
IRCD->SendNumeric(401, source.GetSource(), "%s :No such user.", params[0].c_str());
-
- return;
}
diff --git a/src/misc.cpp b/src/misc.cpp
index b446ea711..6fb9e8c91 100644
--- a/src/misc.cpp
+++ b/src/misc.cpp
@@ -478,6 +478,7 @@ void Anope::Encrypt(const Anope::string &src, Anope::string &dest)
{
EventReturn MOD_RESULT;
FOREACH_RESULT(I_OnEncrypt, OnEncrypt(src, dest));
+ static_cast<void>(MOD_RESULT);
}
bool Anope::Decrypt(const Anope::string &src, Anope::string &dest)
diff --git a/src/modes.cpp b/src/modes.cpp
index 651fbafd9..2e9a49f09 100644
--- a/src/modes.cpp
+++ b/src/modes.cpp
@@ -14,9 +14,11 @@
#include "protocol.h"
#include "channels.h"
+struct StackerInfo;
+
/* List of pairs of user/channels and their stacker info */
-std::map<User *, StackerInfo *> ModeManager::UserStackerObjects;
-std::map<Channel *, StackerInfo *> ModeManager::ChannelStackerObjects;
+static std::map<User *, StackerInfo *> UserStackerObjects;
+static std::map<Channel *, StackerInfo *> ChannelStackerObjects;
/* List of all modes Anope knows about */
std::vector<ChannelMode *> ModeManager::ChannelModes;
@@ -31,6 +33,25 @@ static std::vector<ChannelModeStatus *> ChannelModesByStatus;
/* Number of generic modes we support */
unsigned ModeManager::GenericChannelModes = 0, ModeManager::GenericUserModes = 0;
+struct StackerInfo
+{
+ /* Modes to be added */
+ std::list<std::pair<Mode *, Anope::string> > AddModes;
+ /* Modes to be deleted */
+ std::list<std::pair<Mode *, Anope::string> > DelModes;
+ /* Bot this is sent from */
+ const BotInfo *bi;
+
+ StackerInfo() : bi(NULL) { }
+
+ /** 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 &param);
+};
+
ChannelStatus::ChannelStatus()
{
}
@@ -255,7 +276,11 @@ static StackerInfo *GetInfo(List &l, Object *o)
return s;
}
-std::list<Anope::string> ModeManager::BuildModeStrings(StackerInfo *info)
+/** 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<Anope::string> BuildModeStrings(StackerInfo *info)
{
std::list<Anope::string> ret;
std::list<std::pair<Mode *, Anope::string> >::iterator it, it_end;
@@ -521,8 +546,6 @@ void ModeManager::StackerAdd(const BotInfo *bi, User *u, UserMode *um, bool Set,
s->AddMode(um, Set, Param);
if (bi)
s->bi = bi;
- else
- s->bi = NULL;
if (!modePipe)
modePipe = new ModePipe();
diff --git a/src/nickalias.cpp b/src/nickalias.cpp
index 4e7d5b46a..327340a1d 100644
--- a/src/nickalias.cpp
+++ b/src/nickalias.cpp
@@ -77,115 +77,6 @@ NickAlias::~NickAlias()
NickAliasList->erase(this->nick);
}
-void NickAlias::Release()
-{
- if (this->HasExt("HELD"))
- {
- if (IRCD->CanSVSHold)
- IRCD->SendSVSHoldDel(this->nick);
- else
- {
- User *u = User::Find(this->nick);
- if (u && u->server == Me)
- {
- u->Quit();
- }
- }
-
- this->Shrink("HELD");
- }
-}
-
-/** Timers for removing HELD status from nicks.
- */
-class NickServHeld : public Timer
-{
- static std::map<Anope::string, NickServHeld *> NickServHelds;
-
- Reference<NickAlias> na;
- Anope::string nick;
- public:
- NickServHeld(NickAlias *n, long l) : Timer(l), na(n), nick(na->nick)
- {
- std::map<Anope::string, NickServHeld *>::iterator nit = NickServHelds.find(na->nick);
- if (nit != NickServHelds.end())
- delete nit->second;
-
- NickServHelds[na->nick] = this;
- }
-
- ~NickServHeld()
- {
- NickServHelds.erase(this->nick);
- }
-
- void Tick(time_t)
- {
- if (na)
- na->Shrink("HELD");
- }
-};
-std::map<Anope::string, NickServHeld *> NickServHeld::NickServHelds;
-
-/** Timers for releasing nicks to be available for use
- */
-class CoreExport NickServRelease : public User, public Timer
-{
- static std::map<Anope::string, NickServRelease *> NickServReleases;
- Anope::string nick;
-
- public:
- /** Constructor
- * @param na The nick
- * @param delay The delay before the nick is released
- */
- NickServRelease(NickAlias *na, time_t delay) : User(na->nick, Config->GetBlock("options")->Get<const Anope::string>("enforceruser"),
- Config->GetBlock("options")->Get<const Anope::string>("enforcerhost"), "", "", Me, "Services Enforcer", Anope::CurTime, "", Servers::TS6_UID_Retrieve()), Timer(delay), nick(na->nick)
- {
- /* Erase the current release timer and use the new one */
- std::map<Anope::string, NickServRelease *>::iterator nit = NickServReleases.find(this->nick);
- if (nit != NickServReleases.end())
- {
- IRCD->SendQuit(nit->second, "");
- delete nit->second;
- }
-
- NickServReleases.insert(std::make_pair(this->nick, this));
-
- IRCD->SendClientIntroduction(this);
- }
-
- virtual ~NickServRelease()
- {
- NickServReleases.erase(this->nick);
- }
-
- /** Called when the delay is up
- * @param t The current time
- */
- void Tick(time_t t)
- {
- IRCD->SendQuit(this, "");
- }
-};
-std::map<Anope::string, NickServRelease *> NickServRelease::NickServReleases;
-
-void NickAlias::OnCancel(User *)
-{
- if (this->HasExt("COLLIDED"))
- {
- this->Extend("HELD");
- this->Shrink("COLLIDED");
-
- new NickServHeld(this, Config->GetBlock("options")->Get<time_t>("releasetimeout"));
-
- if (IRCD->CanSVSHold)
- IRCD->SendSVSHold(this->nick, Config->GetBlock("options")->Get<time_t>("releasetimeout"));
- else
- new NickServRelease(this, Config->GetBlock("options")->Get<time_t>("releasetimeout"));
- }
-}
-
void NickAlias::SetVhost(const Anope::string &ident, const Anope::string &host, const Anope::string &creator, time_t created)
{
this->vhost_ident = ident;
diff --git a/src/nickcore.cpp b/src/nickcore.cpp
index e2b47e953..9e2ff8dbb 100644
--- a/src/nickcore.cpp
+++ b/src/nickcore.cpp
@@ -25,7 +25,6 @@ NickCore::NickCore(const Anope::string &coredisplay) : Serializable("NickCore"),
this->o = NULL;
this->channelcount = 0;
this->lastmail = 0;
- this->memos.memomax = 0;
this->display = coredisplay;
@@ -51,10 +50,8 @@ NickCore::~NickCore()
}
this->users.clear();
- /* Remove the core from the list */
NickCoreList->erase(this->display);
- /* Clear access before deleting display name, we want to be able to use the display name in the clear access event */
this->ClearAccess();
if (!this->memos.memos->empty())
diff --git a/src/protocol.cpp b/src/protocol.cpp
index 052ebd8fc..ccd58c95f 100644
--- a/src/protocol.cpp
+++ b/src/protocol.cpp
@@ -372,7 +372,7 @@ bool IRCDProto::IsHostValid(const Anope::string &host)
void IRCDProto::SendOper(User *u)
{
SendNumericInternal(381, u->GetUID(), ":You are now an IRC operator (set by services)");
- u->SetMode(OperServ, "OPER");
+ u->SetMode(NULL, "OPER");
}
unsigned IRCDProto::GetMaxListFor(Channel *c)
diff --git a/src/regchannel.cpp b/src/regchannel.cpp
index 4ed7b4d86..2fcb3ca14 100644
--- a/src/regchannel.cpp
+++ b/src/regchannel.cpp
@@ -359,8 +359,6 @@ ChannelInfo::~ChannelInfo()
if (this->c)
{
- this->Shrink("PERSIST");
-
if (this->bi && this->c->FindUser(this->bi))
this->bi->Part(this->c);
@@ -565,10 +563,14 @@ BotInfo *ChannelInfo::WhoSends() const
{
if (this && this->bi)
return this->bi;
- else if (ChanServ)
+
+ BotInfo *ChanServ = Config->GetClient("ChanServ");
+ if (ChanServ)
return ChanServ;
- else if (!BotListByNick->empty())
+
+ if (!BotListByNick->empty())
return BotListByNick->begin()->second;
+
return NULL;
}
@@ -1041,39 +1043,6 @@ bool ChannelInfo::CheckKick(User *user)
return true;
}
-void ChannelInfo::CheckTopic()
-{
- if (!this->c)
- return;
-
- /* We only compare the topics here, not the time or setter. This is because some (old) IRCds do not
- * allow us to set the topic as someone else, meaning we have to bump the TS and change the setter to us.
- * This desyncs what is really set with what we have stored, and we end up resetting the topic often when
- * it is not required
- */
- if (this->HasExt("TOPICLOCK") && this->last_topic != this->c->topic)
- {
- this->c->ChangeTopic(this->last_topic_setter, this->last_topic, this->last_topic_time);
- }
- else
- {
- this->last_topic = this->c->topic;
- this->last_topic_setter = this->c->topic_setter;
- this->last_topic_time = this->c->topic_ts;
- }
-}
-
-void ChannelInfo::RestoreTopic()
-{
- if (!this->c)
- return;
-
- if ((this->HasExt("KEEPTOPIC") || this->HasExt("TOPICLOCK")) && this->last_topic != this->c->topic)
- {
- this->c->ChangeTopic(!this->last_topic_setter.empty() ? this->last_topic_setter : this->WhoSends()->nick, this->last_topic, this->last_topic_time ? this->last_topic_time : Anope::CurTime);
- }
-}
-
int16_t ChannelInfo::GetLevel(const Anope::string &priv) const
{
if (PrivilegeManager::FindPrivilege(priv) == NULL)
diff --git a/src/servers.cpp b/src/servers.cpp
index 0c1019216..d8fc84a81 100644
--- a/src/servers.cpp
+++ b/src/servers.cpp
@@ -247,33 +247,6 @@ void Server::Sync(bool sync_links)
if (this->GetUplink() && this->GetUplink() == Me)
{
- for (registered_channel_map::iterator it = RegisteredChannelList->begin(), it_end = RegisteredChannelList->end(); it != it_end; ++it)
- {
- ChannelInfo *ci = it->second;
- if (ci->HasExt("PERSIST"))
- {
- bool created;
- ci->c = Channel::FindOrCreate(ci->name, created, ci->time_registered);
-
- if (ModeManager::FindChannelModeByName("PERM") != NULL)
- {
- if (created)
- IRCD->SendChannel(ci->c);
- ci->c->SetMode(NULL, "PERM");
- }
- else
- {
- if (!ci->bi)
- ci->WhoSends()->Assign(NULL, ci);
- if (ci->c->FindUser(ci->bi) == NULL)
- {
- ChannelStatus status(Config->GetModule("botserv")->Get<const Anope::string>("botmodes"));
- ci->bi->Join(ci->c, &status);
- }
- }
- }
- }
-
FOREACH_MOD(I_OnPreUplinkSync, OnPreUplinkSync(this));
for (channel_map::const_iterator it = ChannelList.begin(), it_end = ChannelList.end(); it != it_end; ++it)
@@ -347,8 +320,6 @@ Server *Server::Find(const Anope::string &name, bool name_only)
return NULL;
}
-/*************************************************************************/
-
static inline char& nextID(char &c)
{
if (c == 'Z')
diff --git a/src/tools/anopesmtp.cpp b/src/tools/anopesmtp.cpp
index 9d94564a9..c14f2ca23 100644
--- a/src/tools/anopesmtp.cpp
+++ b/src/tools/anopesmtp.cpp
@@ -65,8 +65,6 @@ extern int connect(int, struct sockaddr *, int);
# endif
#endif
-/*************************************************************************/
-
#ifdef _WIN32
typedef SOCKET ano_socket_t;
#define ano_sockclose(fd) closesocket(fd)
@@ -141,8 +139,6 @@ void alog(const char *fmt, ...)
file.close();
}
-/*************************************************************************/
-
/* Remove a trailing \r\n */
std::string strip(const std::string &buf)
{
@@ -156,8 +152,6 @@ std::string strip(const std::string &buf)
return newbuf;
}
-/*************************************************************************/
-
/* Is the buffer a header? */
bool smtp_is_header(const std::string &buf)
{
@@ -171,8 +165,6 @@ bool smtp_is_header(const std::string &buf)
return false;
}
-/*************************************************************************/
-
/* Parse a header into a name and value */
void smtp_parse_header(const std::string &buf, std::string &header, std::string &value)
{
@@ -191,8 +183,6 @@ void smtp_parse_header(const std::string &buf, std::string &header, std::string
}
}
-/*************************************************************************/
-
/* Have we reached the end of input? */
bool smtp_is_end(const std::string &buf)
{
@@ -203,8 +193,6 @@ bool smtp_is_end(const std::string &buf)
return false;
}
-/*************************************************************************/
-
/* Set who the email is to */
void smtp_set_to(const std::string &to)
{
@@ -217,8 +205,6 @@ void smtp_set_to(const std::string &to)
}
}
-/*************************************************************************/
-
/* Establish a connection to the SMTP server */
int smtp_connect(const char *host, unsigned short port)
{
@@ -245,8 +231,6 @@ int smtp_connect(const char *host, unsigned short port)
return 1;
}
-/*************************************************************************/
-
/* Send a line of text */
int smtp_send(const char *text)
{
@@ -260,8 +244,6 @@ int smtp_send(const char *text)
return result;
}
-/*************************************************************************/
-
/* Read a line of text */
int smtp_read(char *buf, int len)
{
@@ -276,8 +258,6 @@ int smtp_read(char *buf, int len)
return result;
}
-/*************************************************************************/
-
/* Retrieve a response code */
int smtp_get_code(const std::string &text)
{
@@ -289,8 +269,6 @@ int smtp_get_code(const std::string &text)
return atol(text.substr(0, tmp).c_str());
}
-/*************************************************************************/
-
/* Send the email */
int smtp_send_email()
{
@@ -424,16 +402,12 @@ int smtp_send_email()
return 1;
}
-/*************************************************************************/
-
void smtp_disconnect()
{
smtp_send("QUIT\r\n");
ano_sockclose(smail.sock);
}
-/*************************************************************************/
-
int main(int argc, char *argv[])
{
/* Win32 stuff */
diff --git a/src/users.cpp b/src/users.cpp
index 8d0606ab1..cba624104 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -150,7 +150,7 @@ const Anope::string &User::GetDisplayedHost() const
void User::SetCloakedHost(const Anope::string &newhost)
{
if (newhost.empty())
- throw "empty host in User::SetCloakedHost";
+ throw CoreException("empty host in User::SetCloakedHost");
chost = newhost;
@@ -278,88 +278,23 @@ void User::SendMessage(const BotInfo *source, const Anope::string &msg)
* - The user is not registered and NSDefMsg is enabled
* - The user is registered and has set /ns set msg on
*/
+ bool send_privmsg = Config->UsePrivmsg && ((!this->nc && Config->DefPrivmsg) || (this->nc && this->nc->HasExt("MSG")));
sepstream sep(translated_message, '\n', true);
for (Anope::string tok; sep.GetToken(tok);)
{
- if (Config->UsePrivmsg && ((!this->nc && Config->DefPrivmsg) || (this->nc && this->nc->HasExt("MSG"))))
+ if (send_privmsg)
IRCD->SendPrivmsg(source, this->GetUID(), "%s", tok.c_str());
else
IRCD->SendNotice(source, this->GetUID(), "%s", tok.c_str());
}
}
-/** Collides a nick.
- *
- * First, it marks the nick as COLLIDED, this is checked in NickAlias::OnCancel.
- *
- * Then it does one of two things.
- *
- * 1. This will force change the users nick to the guest nick. This gets processed by the IRCd and comes
- * back as a nick change, which calls NickAlias::OnCancel
- * with the users old nick's nickalias (if there is one).
- *
- * 2. Calls User::Kill, which kills the user and deletes the user at the end of the I/O loop.
- * Users destructor then calls NickAlias::OnCancel
- *
- * NickAlias::OnCancel checks for NS_COLLIDED, it then does one of two things.
- *
- * 1. If supported, we send a SVSHold for the user. We are done here, the IRCds expires this at the time we give it.
- *
- * 2. We create a new client with SendClientIntroduction(). Note that is it important that this is called either after the
- * user has been removed from our internal list of user or after the users nick has been updated completely internally.
- * We then create a release timer for this new client that waits and later on sends a QUIT for the client. Release timers
- * are never used for SVSHolds. Ever.
- *
- *
- * Note that now for the timers we only store the users name, not the NickAlias* pointer. We never remove timers when
- * a user changes nick or a nick is deleted, the timers must assume that either of these may have happend.
- *
- * Adam
- */
-void User::Collide(NickAlias *na)
-{
- if (na)
- na->Extend("COLLIDED");
-
- if (IRCD->CanSVSNick)
- {
- const Anope::string &guestprefix = Config->GetBlock("options")->Get<const Anope::string>("guestnickprefix");
-
- Anope::string guestnick;
-
- int i = 0;
- do
- {
- guestnick = guestprefix + stringify(static_cast<uint16_t>(rand()));
- } while (User::Find(guestnick) && i++ < 10);
-
- if (i == 11)
- this->Kill(NickServ ? NickServ->nick : "", "Services nickname-enforcer kill");
- else
- {
- if (NickServ)
- this->SendMessage(NickServ, _("Your nickname is now being changed to \002%s\002"), guestnick.c_str());
- IRCD->SendForceNickChange(this, guestnick, Anope::CurTime);
- }
- }
- else
- this->Kill(NickServ ? NickServ->nick : "", "Services nickname-enforcer kill");
-}
-
void User::Identify(NickAlias *na)
{
- if (!na)
- {
- Log() << "User::Identify() called with NULL pointer";
- return;
- }
-
if (this->nick.equals_ci(na->nick))
{
- Anope::string last_usermask = this->GetIdent() + "@" + this->GetDisplayedHost();
- Anope::string last_realhost = this->GetIdent() + "@" + this->host;
- na->last_usermask = last_usermask;
- na->last_realhost = last_realhost;
+ na->last_usermask = this->GetIdent() + "@" + this->GetDisplayedHost();
+ na->last_realhost = this->GetIdent() + "@" + this->host;
na->last_realname = this->realname;
na->last_seen = Anope::CurTime;
}
@@ -367,27 +302,21 @@ void User::Identify(NickAlias *na)
this->Login(na->nc);
IRCD->SendLogin(this);
- const NickAlias *this_na = NickAlias::Find(this->nick);
- if (!Config->GetBlock("options")->Get<bool>("nonicknameownership") && this_na && this_na->nc == *na->nc && na->nc->HasExt("UNCONFIRMED") == false)
- this->SetMode(NickServ, "REGISTERED");
-
FOREACH_MOD(I_OnNickIdentify, OnNickIdentify(this));
if (this->IsServicesOper())
{
if (!this->nc->o->ot->modes.empty())
{
- this->SetModes(OperServ, "%s", this->nc->o->ot->modes.c_str());
- if (OperServ)
- this->SendMessage(OperServ, "Changing your usermodes to \002%s\002", this->nc->o->ot->modes.c_str());
+ this->SetModes(NULL, "%s", this->nc->o->ot->modes.c_str());
+ this->SendMessage(NULL, "Changing your usermodes to \002%s\002", this->nc->o->ot->modes.c_str());
UserMode *um = ModeManager::FindUserModeByName("OPER");
if (um && !this->HasMode("OPER") && this->nc->o->ot->modes.find(um->mchar) != Anope::string::npos)
IRCD->SendOper(this);
}
if (IRCD->CanSetVHost && !this->nc->o->vhost.empty())
{
- if (OperServ)
- this->SendMessage(OperServ, "Changing your vhost to \002%s\002", this->nc->o->vhost.c_str());
+ this->SendMessage(NULL, "Changing your vhost to \002%s\002", this->nc->o->vhost.c_str());
this->SetDisplayedHost(this->nc->o->vhost);
IRCD->SendVhost(this, "", this->nc->o->vhost);
}
@@ -408,6 +337,8 @@ void User::Login(NickCore *core)
if (this->server->IsSynced())
Log(this, "account") << "is now identified as " << this->nc->display;
+
+ FOREACH_MOD(I_OnUserLogin, OnUserLogin(this));
}
void User::Logout()
diff --git a/src/xline.cpp b/src/xline.cpp
index efe19411f..66bb6d308 100644
--- a/src/xline.cpp
+++ b/src/xline.cpp
@@ -44,7 +44,7 @@ void XLine::InitRegex()
}
}
-XLine::XLine(const Anope::string &ma, const Anope::string &r, const Anope::string &uid) : Serializable("XLine"), mask(ma), by(OperServ ? OperServ->nick : ""), created(0), expires(0), reason(r), id(uid)
+XLine::XLine(const Anope::string &ma, const Anope::string &r, const Anope::string &uid) : Serializable("XLine"), mask(ma), created(0), expires(0), reason(r), id(uid)
{
regex = NULL;
manager = NULL;