X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_setidle.cpp;h=f17f69e09e20139590e6cd4e7f828f657bddea5d;hb=fea1a27cb96a114f698eedcf90401b78406108fb;hp=3ec1719da36ae9ef3177e0a333c99e425900e804;hpb=2d821f2980825be73e3f90b47ffff365b0ec5ecb;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_setidle.cpp b/src/modules/m_setidle.cpp index 3ec1719da..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: * * @@ -25,32 +25,44 @@ using namespace std; /* $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(Server* Me) : Module::Module(Me) { Srv = Me; - Srv->AddCommand("SETIDLE",handle_setidle,'o',1,"m_setidle.so"); + mycommand = new cmd_setidle(); + Srv->AddCommand(mycommand); } virtual ~ModuleSetIdle()