summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2005-04-13 13:02:20 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2005-04-13 13:02:20 +0000
commit409e3a5c8439b0d22524aeb802b04be3b9983fc5 (patch)
tree8cd9b75269d012785f4ccb50c3ebe599b7f765b8
parentc0f731e19d61a971af5cf26d073ccd25bfc5c91c (diff)
Added Module::OnSendList
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@1072 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r--include/modules.h12
-rw-r--r--src/mode.cpp10
-rw-r--r--src/modules.cpp1
-rw-r--r--src/modules/m_chanprotect.cpp29
4 files changed, 51 insertions, 1 deletions
diff --git a/include/modules.h b/include/modules.h
index 44c91a47c..0e8a6a865 100644
--- a/include/modules.h
+++ b/include/modules.h
@@ -374,6 +374,16 @@ class Module : public classbase
* any five second period, directly from the main loop of the server.
*/
virtual void OnBackgroundTimer(time_t curtime);
+
+ /** Called whenever a list is needed for a listmode.
+ * For example, when a /MODE #channel +b (without any other parameters) is called,
+ * if a module was handling +b this function would be called. The function can then
+ * output any lists it wishes to. Please note that all modules will see all mode
+ * characters to provide the ability to extend each other, so please only output
+ * a list if the mode character given matches the one(s) you want to handle.
+ */
+ virtual void OnSendList(userrec* user, chanrec* channel, char mode);
+
};
@@ -538,7 +548,7 @@ class Server : public classbase
* so the above example would become '+aa one three' after processing.
*/
virtual bool AddExtendedListMode(char modechar);
-
+
/** Adds a command to the command table.
* This allows modules to add extra commands into the command table. You must place a function within your
* module which is is of type handlerfunc:
diff --git a/src/mode.cpp b/src/mode.cpp
index 3d25e6c06..467b3d09b 100644
--- a/src/mode.cpp
+++ b/src/mode.cpp
@@ -1283,6 +1283,16 @@ void handle_mode(char **parameters, int pcnt, userrec *user)
WriteServ(user->fd,"368 %s %s :End of channel ban list",user->nick, Ptr->name);
return;
}
+ char* mode = parameters[1];
+ if (*mode == '+')
+ mode++;
+ if ((ModeDefined(*mode,MT_CHANNEL)) && (ModeIsListMode(*mode,MT_CHANNEL)))
+ {
+ // list of items for an extmode
+ log(DEBUG,"Calling OnSendList for all modules, list output for mode %c",*mode);
+ FOREACH_MOD OnSendList(user,Ptr,*mode);
+ return;
+ }
}
if ((Ptr) && (!has_channel(user,Ptr)))
diff --git a/src/modules.cpp b/src/modules.cpp
index 5d75ea20d..1bed5bd18 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -331,6 +331,7 @@ void Module::On005Numeric(std::string &output) { };
int Module::OnKill(userrec* source, userrec* dest, std::string reason) { return 0; };
void Module::OnLoadModule(Module* mod,std::string name) { };
void Module::OnBackgroundTimer(time_t curtime) { };
+void Module::OnSendList(userrec* user, chanrec* channel, char mode) { };
// server is a wrapper class that provides methods to all of the C-style
// exports in the core
diff --git a/src/modules/m_chanprotect.cpp b/src/modules/m_chanprotect.cpp
index 65a7b0e84..5a8e40a36 100644
--- a/src/modules/m_chanprotect.cpp
+++ b/src/modules/m_chanprotect.cpp
@@ -279,6 +279,35 @@ class ModuleChanProtect : public Module
}
return 0;
}
+
+ virtual void OnSendList(userrec* user, chanrec* channel, char mode)
+ {
+ if (mode == 'q')
+ {
+ chanuserlist cl = Srv->GetUsers(channel);
+ for (int i = 0; i < cl.size(); i++)
+ {
+ if (cl[i]->GetExt("cm_founder_"+std::string(channel->name)))
+ {
+ WriteServ(user->fd,"386 %s %s %s",user->nick, channel->name,cl[i]->nick);
+ }
+ }
+ WriteServ(user->fd,"387 %s %s :End of channel founder list",user->nick, channel->name);
+ }
+ if (mode == 'a')
+ {
+ chanuserlist cl = Srv->GetUsers(channel);
+ for (int i = 0; i < cl.size(); i++)
+ {
+ if (cl[i]->GetExt("cm_protect_"+std::string(channel->name)))
+ {
+ WriteServ(user->fd,"388 %s %s %s",user->nick, channel->name,cl[i]->nick);
+ }
+ }
+ WriteServ(user->fd,"389 %s %s :End of channel protected user list",user->nick, channel->name);
+ }
+
+ }
virtual ~ModuleChanProtect()
{