*/
#include "inspircd.h"
-#include <algorithm>
-#include "users.h"
-#include "channels.h"
-#include "modules.h"
-#include "configreader.h"
/* $ModDesc: Implements SVSHOLD. Like Q:Lines, but can only be added/removed by Services. */
/** Handle /SVSHold
*/
-class cmd_svshold : public command_t
+class CommandSvshold : public Command
{
public:
- cmd_svshold(InspIRCd* Me) : command_t(Me, "SVSHOLD", 'o', 1)
+ CommandSvshold(InspIRCd* Me) : Command(Me, "SVSHOLD", 'o', 1)
{
this->source = "m_svshold.so";
this->syntax = "<nickname> [<duration> :<reason>]";
+ TRANSLATE4(TR_NICK, TR_TEXT, TR_TEXT, TR_END);
}
- CmdResult Handle(const char** parameters, int pcnt, userrec *user)
+ CmdResult Handle(const char** parameters, int pcnt, User *user)
{
/* syntax: svshold nickname time :reason goes here */
/* 'time' is a human-readable timestring, like 2d3h2s. */
class ModuleSVSHold : public Module
{
- cmd_svshold *mycommand;
+ CommandSvshold *mycommand;
public:
ModuleSVSHold(InspIRCd* Me) : Module(Me)
{
- mycommand = new cmd_svshold(Me);
+ mycommand = new CommandSvshold(Me);
ServerInstance->AddCommand(mycommand);
}
List[I_OnUserPreNick] = List[I_OnSyncOtherMetaData] = List[I_OnDecodeMetaData] = List[I_OnStats] = 1;
}
- virtual int OnStats(char symbol, userrec* user, string_list &results)
+ virtual int OnStats(char symbol, User* user, string_list &results)
{
ExpireBans();
return 0;
}
- virtual int OnUserPreNick(userrec *user, const std::string &newnick)
+ virtual int OnUserPreNick(User *user, const std::string &newnick)
{
ExpireBans();
virtual Version GetVersion()
{
- return Version(1,1,0,1,VF_VENDOR|VF_COMMON,API_VERSION);
+ return Version(1, 1, 0, 1, VF_COMMON | VF_VENDOR, API_VERSION);
}
std::string EncodeSVSHold(const SVSHold* ban)
{
std::ostringstream stream;
- stream << ban->nickname << " " << ban->set_by << " " << ban->set_on << " " << ban->length << " " << ban->reason;
+ stream << ban->nickname << " " << ban->set_by << " " << ban->set_on << " " << ban->length << " :" << ban->reason;
return stream.str();
}
SVSHold* DecodeSVSHold(const std::string &data)
{
SVSHold* res = new SVSHold();
- std::istringstream stream(data);
- stream >> res->nickname;
- stream >> res->set_by;
- stream >> res->set_on;
- stream >> res->length;
- res->reason = stream.str();
+ int set_on;
+ irc::tokenstream tokens(data);
+ tokens.GetToken(res->nickname);
+ tokens.GetToken(res->set_by);
+ tokens.GetToken(set_on);
+ res->set_on = set_on;
+ tokens.GetToken(res->length);
+ tokens.GetToken(res->reason);
return res;
}
}
};
-class ModuleSVSHoldFactory : public ModuleFactory
-{
- public:
- ModuleSVSHoldFactory()
- {
- }
-
- ~ModuleSVSHoldFactory()
- {
- }
-
- virtual Module * CreateModule(InspIRCd* Me)
- {
- return new ModuleSVSHold(Me);
- }
-
-};
-
-
-extern "C" DllExport void * init_module( void )
-{
- return new ModuleSVSHoldFactory;
-}
+MODULE_INIT(ModuleSVSHold)