The InspIRCd Project
Home | Developers | Wiki | Forums | Bug Tracker | SVN | Download
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

m_setidle.cpp

Go to the documentation of this file.
00001 /*       +------------------------------------+
00002  *       | Inspire Internet Relay Chat Daemon |
00003  *       +------------------------------------+
00004  *
00005  *  InspIRCd: (C) 2002-2008 InspIRCd Development Team
00006  * See: http://www.inspircd.org/wiki/index.php/Credits
00007  *
00008  * This program is free but copyrighted software; see
00009  *            the file COPYING for details.
00010  *
00011  * ---------------------------------------------------
00012  */
00013 
00014 #include "inspircd.h"
00015 
00016 /* $ModDesc: Allows opers to set their idle time */
00017 
00020 class CommandSetidle : public Command
00021 {
00022  public:
00023         CommandSetidle (InspIRCd* Instance) : Command(Instance,"SETIDLE", "o", 1)
00024         {
00025                 this->source = "m_setidle.so";
00026                 syntax = "<duration>";
00027                 TRANSLATE2(TR_TEXT, TR_END);
00028         }
00029 
00030         CmdResult Handle (const std::vector<std::string>& parameters, User *user)
00031         {
00032                 time_t idle = ServerInstance->Duration(parameters[0]);
00033                 if (idle < 1)
00034                 {
00035                         user->WriteNumeric(948, "%s :Invalid idle time.",user->nick.c_str());
00036                         return CMD_FAILURE;
00037                 }
00038                 user->idle_lastmsg = (ServerInstance->Time() - idle);
00039                 // minor tweak - we cant have signon time shorter than our idle time!
00040                 if (user->signon > user->idle_lastmsg)
00041                         user->signon = user->idle_lastmsg;
00042                 ServerInstance->SNO->WriteToSnoMask('A', std::string(user->nick)+" used SETIDLE to set their idle time to "+ConvToStr(idle)+" seconds");
00043                 user->WriteNumeric(944, "%s :Idle time set.",user->nick.c_str());
00044 
00045                 return CMD_LOCALONLY;
00046         }
00047 };
00048 
00049 
00050 class ModuleSetIdle : public Module
00051 {
00052         CommandSetidle* mycommand;
00053  public:
00054         ModuleSetIdle(InspIRCd* Me)
00055                 : Module(Me)
00056         {
00057 
00058                 mycommand = new CommandSetidle(ServerInstance);
00059                 ServerInstance->AddCommand(mycommand);
00060 
00061         }
00062 
00063         virtual ~ModuleSetIdle()
00064         {
00065         }
00066 
00067         virtual Version GetVersion()
00068         {
00069                 return Version("$Id: m_setidle.cpp 10291 2008-08-25 20:35:51Z w00t $", VF_VENDOR, API_VERSION);
00070         }
00071 };
00072 
00073 MODULE_INIT(ModuleSetIdle)