X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_setidle.cpp;h=f17f69e09e20139590e6cd4e7f828f657bddea5d;hb=fea1a27cb96a114f698eedcf90401b78406108fb;hp=20863500918eb1fa2224636b36eafb14b55d0c54;hpb=eb4229deed0281ae566ef7e55a144e5d3183a4b2;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_setidle.cpp b/src/modules/m_setidle.cpp index 208635009..f17f69e09 100644 --- a/src/modules/m_setidle.cpp +++ b/src/modules/m_setidle.cpp @@ -2,7 +2,7 @@ * | Inspire Internet Relay Chat Daemon | * +------------------------------------+ * - * Inspire is copyright (C) 2002-2004 ChatSpike-Dev. + * InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev. * E-mail: * * @@ -14,6 +14,8 @@ * --------------------------------------------------- */ +using namespace std; + #include #include #include "users.h" @@ -23,37 +25,48 @@ /* $ModDesc: Allows opers to set their idle time */ -Server *Srv = NULL; - -void handle_setidle(char **parameters, int pcnt, userrec *user) +static Server *Srv = NULL; + +class cmd_setidle : public command_t { - if (atoi(parameters[0]) < 1) + public: + cmd_setidle () : command_t("SETIDLE", 'o', 1) { - WriteServ(user->fd,"948 %s :Invalid idle time.",user->nick); - return; + this->source = "m_setidle.so"; + syntax = ""; } - user->idle_lastmsg = time(NULL) - atoi(parameters[0]); - // minor tweak - we cant have signon time shorter than our idle time! - if (user->signon > user->idle_lastmsg) - user->signon = user->idle_lastmsg; - Srv->SendOpers(std::string(user->nick)+" used SETIDLE to set their idle time to "+std::string(parameters[0])+" seconds"); - WriteServ(user->fd,"944 %s :Idle time set.",user->nick); -} + + void Handle (const char** parameters, int pcnt, userrec *user) + { + if (atoi(parameters[0]) < 1) + { + user->WriteServ("948 %s :Invalid idle time.",user->nick); + return; + } + user->idle_lastmsg = time(NULL) - atoi(parameters[0]); + // minor tweak - we cant have signon time shorter than our idle time! + if (user->signon > user->idle_lastmsg) + user->signon = user->idle_lastmsg; + Srv->SendOpers(std::string(user->nick)+" used SETIDLE to set their idle time to "+std::string(parameters[0])+" seconds"); + user->WriteServ("944 %s :Idle time set.",user->nick); + } +}; class ModuleSetIdle : public Module { + cmd_setidle* mycommand; public: - ModuleSetIdle() + ModuleSetIdle(Server* Me) + : Module::Module(Me) { - Srv = new Server; - Srv->AddCommand("SETIDLE",handle_setidle,'o',1,"m_setidle.so"); + Srv = Me; + mycommand = new cmd_setidle(); + Srv->AddCommand(mycommand); } virtual ~ModuleSetIdle() { - if (Srv) - delete Srv; } virtual Version GetVersion() @@ -76,9 +89,9 @@ class ModuleSetIdleFactory : public ModuleFactory { } - virtual Module * CreateModule() + virtual Module * CreateModule(Server* Me) { - return new ModuleSetIdle; + return new ModuleSetIdle(Me); } };