]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_setidle.cpp
Remove unnecessary header traffic
[user/henk/code/inspircd.git] / src / modules / m_setidle.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2007 InspIRCd Development Team
6  * See: http://www.inspircd.org/wiki/index.php/Credits
7  *
8  * This program is free but copyrighted software; see
9  *            the file COPYING for details.
10  *
11  * ---------------------------------------------------
12  */
13
14 #include "inspircd.h"
15
16 /* $ModDesc: Allows opers to set their idle time */
17
18 /** Handle /SETIDLE
19  */
20 class cmd_setidle : public command_t
21 {
22  public:
23         cmd_setidle (InspIRCd* Instance) : command_t(Instance,"SETIDLE", 'o', 1)
24         {
25                 this->source = "m_setidle.so";
26                 syntax = "<duration>";
27         }
28
29         CmdResult Handle (const char** parameters, int pcnt, userrec *user)
30         {
31                 time_t idle = ServerInstance->Duration(parameters[0]);
32                 if (idle < 1)
33                 {
34                         user->WriteServ("948 %s :Invalid idle time.",user->nick);
35                         return CMD_FAILURE;
36                 }
37                 user->idle_lastmsg = (ServerInstance->Time() - idle);
38                 // minor tweak - we cant have signon time shorter than our idle time!
39                 if (user->signon > user->idle_lastmsg)
40                         user->signon = user->idle_lastmsg;
41                 ServerInstance->WriteOpers(std::string(user->nick)+" used SETIDLE to set their idle time to "+ConvToStr(idle)+" seconds");
42                 user->WriteServ("944 %s :Idle time set.",user->nick);
43
44                 return CMD_LOCALONLY;
45         }
46 };
47
48
49 class ModuleSetIdle : public Module
50 {
51         cmd_setidle*    mycommand;
52  public:
53         ModuleSetIdle(InspIRCd* Me)
54                 : Module(Me)
55         {
56                 
57                 mycommand = new cmd_setidle(ServerInstance);
58                 ServerInstance->AddCommand(mycommand);
59         }
60         
61         virtual ~ModuleSetIdle()
62         {
63         }
64         
65         virtual Version GetVersion()
66         {
67                 return Version(1, 1, 0, 0, VF_COMMON | VF_VENDOR, API_VERSION);
68         }
69 };
70
71 MODULE_INIT(ModuleSetIdle)