]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_setidle.cpp
91cfed9507e92c97b6ceba7ab3d7fc795d5fdaa4
[user/henk/code/inspircd.git] / src / modules / m_setidle.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2008 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 CommandSetidle : public Command
21 {
22  public:
23         CommandSetidle (InspIRCd* Instance) : Command(Instance,"SETIDLE", "o", 1)
24         {
25                 this->source = "m_setidle.so";
26                 syntax = "<duration>";
27                 TRANSLATE2(TR_TEXT, TR_END);
28         }
29
30         CmdResult Handle (const std::vector<std::string>& parameters, User *user)
31         {
32                 time_t idle = ServerInstance->Duration(parameters[0]);
33                 if (idle < 1)
34                 {
35                         user->WriteNumeric(948, "%s :Invalid idle time.",user->nick.c_str());
36                         return CMD_FAILURE;
37                 }
38                 user->idle_lastmsg = (ServerInstance->Time() - idle);
39                 // minor tweak - we cant have signon time shorter than our idle time!
40                 if (user->signon > user->idle_lastmsg)
41                         user->signon = user->idle_lastmsg;
42                 ServerInstance->SNO->WriteToSnoMask('A', std::string(user->nick)+" used SETIDLE to set their idle time to "+ConvToStr(idle)+" seconds");
43                 user->WriteNumeric(944, "%s :Idle time set.",user->nick.c_str());
44
45                 return CMD_LOCALONLY;
46         }
47 };
48
49
50 class ModuleSetIdle : public Module
51 {
52         CommandSetidle* mycommand;
53  public:
54         ModuleSetIdle(InspIRCd* Me)
55                 : Module(Me)
56         {
57
58                 mycommand = new CommandSetidle(ServerInstance);
59                 ServerInstance->AddCommand(mycommand);
60
61         }
62
63         virtual ~ModuleSetIdle()
64         {
65         }
66
67         virtual Version GetVersion()
68         {
69                 return Version("$Id$", VF_VENDOR, API_VERSION);
70         }
71 };
72
73 MODULE_INIT(ModuleSetIdle)