]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_setidle.cpp
Add VF_COMMON to a lot modules which require it. Reported by danielg in bug #369...
[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 #include "users.h"
16 #include "channels.h"
17 #include "modules.h"
18
19 /* $ModDesc: Allows opers to set their idle time */
20
21 /** Handle /SETIDLE
22  */
23 class cmd_setidle : public command_t
24 {
25  public:
26         cmd_setidle (InspIRCd* Instance) : command_t(Instance,"SETIDLE", 'o', 1)
27         {
28                 this->source = "m_setidle.so";
29                 syntax = "<duration>";
30         }
31
32         CmdResult Handle (const char** parameters, int pcnt, userrec *user)
33         {
34                 time_t idle = ServerInstance->Duration(parameters[0]);
35                 if (idle < 1)
36                 {
37                         user->WriteServ("948 %s :Invalid idle time.",user->nick);
38                         return CMD_FAILURE;
39                 }
40                 user->idle_lastmsg = (ServerInstance->Time() - idle);
41                 // minor tweak - we cant have signon time shorter than our idle time!
42                 if (user->signon > user->idle_lastmsg)
43                         user->signon = user->idle_lastmsg;
44                 ServerInstance->WriteOpers(std::string(user->nick)+" used SETIDLE to set their idle time to "+ConvToStr(idle)+" seconds");
45                 user->WriteServ("944 %s :Idle time set.",user->nick);
46
47                 return CMD_LOCALONLY;
48         }
49 };
50
51
52 class ModuleSetIdle : public Module
53 {
54         cmd_setidle*    mycommand;
55  public:
56         ModuleSetIdle(InspIRCd* Me)
57                 : Module(Me)
58         {
59                 
60                 mycommand = new cmd_setidle(ServerInstance);
61                 ServerInstance->AddCommand(mycommand);
62         }
63         
64         virtual ~ModuleSetIdle()
65         {
66         }
67         
68         virtual Version GetVersion()
69         {
70                 return Version(1, 1, 0, 0, VF_COMMON | VF_VENDOR, API_VERSION);
71         }
72 };
73
74 MODULE_INIT(ModuleSetIdle)