]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_setidle.cpp
WHEEEEE!!!!!
[user/henk/code/inspircd.git] / src / modules / m_setidle.cpp
index 3ec1719da36ae9ef3177e0a333c99e425900e804..f17f69e09e20139590e6cd4e7f828f657bddea5d 100644 (file)
@@ -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:
  *                <brain@chatspike.net>
  *               <Craig@chatspike.net>
@@ -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 = "<idle-seconds>";
        }
-       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()