* ---------------------------------------------------
*/
-#include <string>
+#include "inspircd.h"
#include "users.h"
#include "channels.h"
#include "modules.h"
-#include "inspircd.h"
#include "configreader.h"
#include "m_sqlv2.h"
class ModuleSQLOper : public Module
{
- InspIRCd* Srv;
Module* SQLutils;
Module* HashModule;
std::string databaseid;
public:
ModuleSQLOper(InspIRCd* Me)
- : Module::Module(Me), Srv(Me)
+ : Module::Module(Me)
{
- ServerInstance->UseInterface("SQLutils");
- ServerInstance->UseInterface("SQL");
- ServerInstance->UseInterface("HashRequest");
+ ServerInstance->Modules->UseInterface("SQLutils");
+ ServerInstance->Modules->UseInterface("SQL");
+ ServerInstance->Modules->UseInterface("HashRequest");
/* Attempt to locate the md5 service provider, bail if we can't find it */
- HashModule = ServerInstance->FindModule("m_md5.so");
+ HashModule = ServerInstance->Modules->Find("m_md5.so");
if (!HashModule)
throw ModuleException("Can't find m_md5.so. Please load m_md5.so before m_sqloper.so.");
- SQLutils = ServerInstance->FindModule("m_sqlutils.so");
+ SQLutils = ServerInstance->Modules->Find("m_sqlutils.so");
if (!SQLutils)
throw ModuleException("Can't find m_sqlutils.so. Please load m_sqlutils.so before m_sqloper.so.");
virtual ~ModuleSQLOper()
{
- ServerInstance->DoneWithInterface("SQL");
- ServerInstance->DoneWithInterface("SQLutils");
- ServerInstance->DoneWithInterface("HashRequest");
+ ServerInstance->Modules->DoneWithInterface("SQL");
+ ServerInstance->Modules->DoneWithInterface("SQLutils");
+ ServerInstance->Modules->DoneWithInterface("HashRequest");
}
void Implements(char* List)
virtual void OnRehash(userrec* user, const std::string ¶meter)
{
- ConfigReader Conf(Srv);
+ ConfigReader Conf(ServerInstance);
databaseid = Conf.ReadValue("sqloper", "dbid", 0); /* Database ID of a database configured for the service provider module */
}
{
Module* target;
- target = Srv->FindFeature("SQL");
+ target = ServerInstance->Modules->FindFeature("SQL");
if (target)
{
bool OperUser(userrec* user, const std::string &username, const std::string &password, const std::string &pattern, const std::string &type)
{
- ConfigReader Conf(Srv);
+ ConfigReader Conf(ServerInstance);
for (int j = 0; j < Conf.Enumerate("type"); j++)
{
if (operhost.size())
user->ChangeDisplayedHost(operhost.c_str());
- Srv->SNO->WriteToSnoMask('o',"%s (%s@%s) is now an IRC operator of type %s", user->nick, user->ident, user->host, type.c_str());
- user->WriteServ("381 %s :You are now an IRC operator of type %s", user->nick, type.c_str());
+ ServerInstance->SNO->WriteToSnoMask('o',"%s (%s@%s) is now an IRC operator of type %s", user->nick, user->ident, user->host, type.c_str());
+ user->WriteServ("381 %s :You are now %s %s",user->nick, strchr("aeiouAEIOU", type[0]) ? "an" : "a", irc::Spacify(type.c_str()));
if (!user->modes[UM_OPERATOR])
user->Oper(type);
};
-class ModuleSQLOperFactory : public ModuleFactory
-{
- public:
- ModuleSQLOperFactory()
- {
- }
-
- ~ModuleSQLOperFactory()
- {
- }
-
- virtual Module * CreateModule(InspIRCd* Me)
- {
- return new ModuleSQLOper(Me);
- }
-
-};
-
-
-extern "C" void * init_module( void )
-{
- return new ModuleSQLOperFactory;
-}
-
+MODULE_INIT(ModuleSQLOper);