* ---------------------------------------------------
*/
-#include <stdio.h>
-#include <vector>
+#include "inspircd.h"
#include "users.h"
#include "channels.h"
-#include "inspircd.h"
#include "modules.h"
/* $ModDesc: Sets (and unsets) modes on opers when they oper up */
if (!strcmp(typen.c_str(),user->oper))
{
std::string ThisOpersModes = Conf->ReadValue("type","modes",j);
- char first = *(ThisOpersModes.c_str());
- if ((first != '+') && (first != '-'))
- ThisOpersModes = "+" + ThisOpersModes;
- if (ThisOpersModes != "")
+ if (!ThisOpersModes.empty())
{
+ char first = *(ThisOpersModes.c_str());
+ if ((first != '+') && (first != '-'))
+ ThisOpersModes = "+" + ThisOpersModes;
+
std::string buf;
stringstream ss(ThisOpersModes);
-
vector<string> tokens;
// split ThisOperModes into modes and mode params
tokens.push_back(buf);
int size = tokens.size() + 1;
- char** modes = new char*[size];
+ const char** modes = new const char*[size];
modes[0] = user->nick;
- modes[1] = (char*)tokens[0].c_str();
- if (tokens.size() > 1)
+ // process mode params
+ int i = 1;
+ for (unsigned int k = 0; k < tokens.size(); k++)
{
- // process mode params
- int i = 2;
- for (unsigned int k = 1; k < tokens.size(); k++)
- {
- modes[i] = (char*)tokens[k].c_str();
- i++;
- }
+ modes[i] = tokens[k].c_str();
+ i++;
}
+
std::deque<std::string> n;
- Event rmode((char *)&n, NULL, "send_mode");
+ Event rmode((char *)&n, NULL, "send_mode_explicit");
for (unsigned int j = 0; j < tokens.size(); j++)
- {
n.push_back(modes[j]);
- }
+
rmode.Send(ServerInstance);
- ServerInstance->SendMode((const char**)modes, size, user);
+ ServerInstance->SendMode(modes, size, user);
delete [] modes;
}
break;
}
};
-// stuff down here is the module-factory stuff. For basic modules you can ignore this.
-
-class ModuleModesOnOperFactory : public ModuleFactory
-{
- public:
- ModuleModesOnOperFactory()
- {
- }
-
- ~ModuleModesOnOperFactory()
- {
- }
-
- virtual Module * CreateModule(InspIRCd* Me)
- {
- return new ModuleModesOnOper(Me);
- }
-
-};
-
-
-extern "C" DllExport void * init_module( void )
-{
- return new ModuleModesOnOperFactory;
-}
-
+MODULE_INIT(ModuleModesOnOper)