diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2007-05-03 21:57:58 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2007-05-03 21:57:58 +0000 |
commit | 3ec7995bf4981119115d14ce2cfce0cb5795f803 (patch) | |
tree | 358fa606d92ba5d6002021c7fe7ad14f4f9995cd | |
parent | 2c04423995da525bd762dea2bbde9d3bb522f8c2 (diff) |
DO NOT USE THIS COMMIT - if you do, most of the modules wont work.
DEVS: Please fix all modules that have warnings to use the new parameters to OnUserJoin, OnUserPart and OnUserKick (bool &silent)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@6858 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r-- | include/modules.h | 14 | ||||
-rw-r--r-- | src/channels.cpp | 34 | ||||
-rw-r--r-- | src/cull_list.cpp | 2 | ||||
-rw-r--r-- | src/modules.cpp | 6 |
4 files changed, 39 insertions, 17 deletions
diff --git a/include/modules.h b/include/modules.h index 1f8f0fb5e..7655517ea 100644 --- a/include/modules.h +++ b/include/modules.h @@ -75,7 +75,7 @@ enum MessageType { * ipv4 servers, so this value will be ten times as * high on ipv6 servers. */ -#define NATIVE_API_VERSION 11019 +#define NATIVE_API_VERSION 11020 #ifdef IPV6 #define API_VERSION (NATIVE_API_VERSION * 10) #else @@ -496,8 +496,10 @@ class Module : public Extensible * and the details of the channel they have joined is available in the variable chanrec *channel * @param user The user who is joining * @param channel The channel being joined + * @param silent Change this to true if you want to conceal the JOIN command from the other users + * of the channel (useful for modules such as auditorium) */ - virtual void OnUserJoin(userrec* user, chanrec* channel); + virtual void OnUserJoin(userrec* user, chanrec* channel, bool &silent); /** Called after a user joins a channel * Identical to OnUserJoin, but called immediately afterwards, when any linking module has @@ -513,8 +515,10 @@ class Module : public Extensible * @param user The user who is parting * @param channel The channel being parted * @param partmessage The part message, or an empty string + * @param silent Change this to true if you want to conceal the PART command from the other users + * of the channel (useful for modules such as auditorium) */ - virtual void OnUserPart(userrec* user, chanrec* channel, const std::string &partmessage); + virtual void OnUserPart(userrec* user, chanrec* channel, const std::string &partmessage, bool &silent); /** Called on rehash. * This method is called prior to a /REHASH or when a SIGHUP is received from the operating @@ -580,8 +584,10 @@ class Module : public Extensible * @param user The user being kicked * @param chan The channel the user is being kicked from * @param reason The kick reason + * @param silent Change this to true if you want to conceal the PART command from the other users + * of the channel (useful for modules such as auditorium) */ - virtual void OnUserKick(userrec* source, userrec* user, chanrec* chan, const std::string &reason); + virtual void OnUserKick(userrec* source, userrec* user, chanrec* chan, const std::string &reason, bool &silent); /** Called whenever a user opers locally. * The userrec will contain the oper mode 'o' as this function is called after any modifications diff --git a/src/channels.cpp b/src/channels.cpp index ce7cbb45c..23aeb32a1 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -341,6 +341,7 @@ chanrec* chanrec::ForceChan(InspIRCd* Instance, chanrec* Ptr, userrec* user, con { userrec* dummyuser = new userrec(Instance); std::string nick = user->nick; + bool silent = false; dummyuser->SetFd(FD_MAGIC_NUMBER); Ptr->AddUser(user); @@ -383,7 +384,10 @@ chanrec* chanrec::ForceChan(InspIRCd* Instance, chanrec* Ptr, userrec* user, con delete dummyuser; - Ptr->WriteChannel(user,"JOIN :%s",Ptr->name); + FOREACH_MOD_I(Instance,I_OnUserJoin,OnUserJoin(user, Ptr, silent)); + + if (!silent) + Ptr->WriteChannel(user,"JOIN :%s",Ptr->name); /* Theyre not the first ones in here, make sure everyone else sees the modes we gave the user */ std::string ms = Instance->Modes->ModeString(user, Ptr); @@ -400,8 +404,7 @@ chanrec* chanrec::ForceChan(InspIRCd* Instance, chanrec* Ptr, userrec* user, con } Ptr->UserList(user); } - FOREACH_MOD_I(Instance,I_OnUserJoin,OnUserJoin(user,Ptr)); - FOREACH_MOD_I(Instance,I_OnPostJoin,OnPostJoin(user,Ptr)); + FOREACH_MOD_I(Instance,I_OnPostJoin,OnPostJoin(user, Ptr)); return Ptr; } @@ -434,14 +437,19 @@ bool chanrec::IsBanned(userrec* user) */ long chanrec::PartUser(userrec *user, const char* reason) { + bool silent = false; + if (!user) return this->GetUserCounter(); UCListIter i = user->chans.find(this); if (i != user->chans.end()) { - FOREACH_MOD(I_OnUserPart,OnUserPart(user, this, reason ? reason : "")); - this->WriteChannel(user, "PART %s%s%s", this->name, reason ? " :" : "", reason ? reason : ""); + FOREACH_MOD(I_OnUserPart,OnUserPart(user, this, reason ? reason : "", silent)); + + if (!silent) + this->WriteChannel(user, "PART %s%s%s", this->name, reason ? " :" : "", reason ? reason : ""); + user->chans.erase(i); this->RemoveAllPrefixes(user); } @@ -463,6 +471,8 @@ long chanrec::PartUser(userrec *user, const char* reason) long chanrec::ServerKickUser(userrec* user, const char* reason, bool triggerevents) { + bool silent = false; + if (!user || !reason) return this->GetUserCounter(); @@ -477,13 +487,15 @@ long chanrec::ServerKickUser(userrec* user, const char* reason, bool triggereven if (triggerevents) { - FOREACH_MOD(I_OnUserKick,OnUserKick(NULL,user,this,reason)); + FOREACH_MOD(I_OnUserKick,OnUserKick(NULL, user, this, reason, silent)); } UCListIter i = user->chans.find(this); if (i != user->chans.end()) { - this->WriteChannelWithServ(ServerInstance->Config->ServerName, "KICK %s %s :%s", this->name, user->nick, reason); + if (!silent) + this->WriteChannelWithServ(ServerInstance->Config->ServerName, "KICK %s %s :%s", this->name, user->nick, reason); + user->chans.erase(i); this->RemoveAllPrefixes(user); } @@ -505,6 +517,8 @@ long chanrec::ServerKickUser(userrec* user, const char* reason, bool triggereven long chanrec::KickUser(userrec *src, userrec *user, const char* reason) { + bool silent = false; + if (!src || !user || !reason) return this->GetUserCounter(); @@ -549,13 +563,15 @@ long chanrec::KickUser(userrec *src, userrec *user, const char* reason) } } - FOREACH_MOD(I_OnUserKick,OnUserKick(src,user,this,reason)); + FOREACH_MOD(I_OnUserKick,OnUserKick(src, user, this, reason, silent)); UCListIter i = user->chans.find(this); if (i != user->chans.end()) { /* zap it from the channel list of the user */ - this->WriteChannel(src, "KICK %s %s :%s", this->name, user->nick, reason); + if (!silent) + this->WriteChannel(src, "KICK %s %s :%s", this->name, user->nick, reason); + user->chans.erase(i); this->RemoveAllPrefixes(user); } diff --git a/src/cull_list.cpp b/src/cull_list.cpp index f6ea2e0f1..b0bf74ccb 100644 --- a/src/cull_list.cpp +++ b/src/cull_list.cpp @@ -109,9 +109,9 @@ int CullList::Apply() if (a->GetUser()->registered == REG_ALL) { + FOREACH_MOD_I(ServerInstance,I_OnUserQuit,OnUserQuit(a->GetUser(), reason, oper_reason)); a->GetUser()->PurgeEmptyChannels(); a->GetUser()->WriteCommonQuit(reason, oper_reason); - FOREACH_MOD_I(ServerInstance,I_OnUserQuit,OnUserQuit(a->GetUser(), reason, oper_reason)); } FOREACH_MOD_I(ServerInstance,I_OnUserDisconnect,OnUserDisconnect(a->GetUser())); diff --git a/src/modules.cpp b/src/modules.cpp index aa2d5f82a..f4cc5d3b9 100644 --- a/src/modules.cpp +++ b/src/modules.cpp @@ -106,9 +106,9 @@ std::string Event::GetEventID() void Module::OnUserConnect(userrec* user) { } void Module::OnUserQuit(userrec* user, const std::string& message, const std::string &oper_message) { } void Module::OnUserDisconnect(userrec* user) { } -void Module::OnUserJoin(userrec* user, chanrec* channel) { } +void Module::OnUserJoin(userrec* user, chanrec* channel, bool &silent) { } void Module::OnPostJoin(userrec* user, chanrec* channel) { } -void Module::OnUserPart(userrec* user, chanrec* channel, const std::string &partmessage) { } +void Module::OnUserPart(userrec* user, chanrec* channel, const std::string &partmessage, bool &silent) { } void Module::OnRehash(userrec* user, const std::string ¶meter) { } void Module::OnServerRaw(std::string &raw, bool inbound, userrec* user) { } int Module::OnUserPreJoin(userrec* user, chanrec* chan, const char* cname, std::string &privs) { return 0; } @@ -134,7 +134,7 @@ void Module::OnPostCommand(const std::string &command, const char** parameters, bool Module::OnCheckReady(userrec* user) { return true; }; int Module::OnUserRegister(userrec* user) { return 0; }; int Module::OnUserPreKick(userrec* source, userrec* user, chanrec* chan, const std::string &reason) { return 0; }; -void Module::OnUserKick(userrec* source, userrec* user, chanrec* chan, const std::string &reason) { }; +void Module::OnUserKick(userrec* source, userrec* user, chanrec* chan, const std::string &reason, bool &silent) { }; int Module::OnCheckInvite(userrec* user, chanrec* chan) { return 0; }; int Module::OnCheckKey(userrec* user, chanrec* chan, const std::string &keygiven) { return 0; }; int Module::OnCheckLimit(userrec* user, chanrec* chan) { return 0; }; |