]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_setidle.cpp
c4d812d0068f022104e7f0b9f51b6f178a411dfe
[user/henk/code/inspircd.git] / src / modules / m_setidle.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  Inspire is copyright (C) 2002-2004 ChatSpike-Dev.
6  *                       E-mail:
7  *                <brain@chatspike.net>
8  *                <Craig@chatspike.net>
9  *     
10  * Written by Craig Edwards, Craig McLure, and others.
11  * This program is free but copyrighted software; see
12  *            the file COPYING for details.
13  *
14  * ---------------------------------------------------
15  */
16
17 #include <stdio.h>
18 #include <string>
19 #include "users.h"
20 #include "channels.h"
21 #include "modules.h"
22
23 /* $ModDesc: Allows opers to set their idle time */
24
25 Server *Srv = NULL;
26          
27 void handle_setidle(char **parameters, int pcnt, userrec *user)
28 {
29         user->idle_lastmsg = time(NULL) - atoi(parameters[0]);
30         // minor tweak - we cant have signon time shorter than our idle time!
31         if (user->signon > user->idle_lastmsg)
32                 user->signon = user->idle_lastmsg;
33         Srv->SendOpers(std::string(user->nick)+" used SETIDLE to set their idle time to "+std::string(parameters[0])+" seconds");
34         WriteServ(user->fd,"944 %s :Idle time set.",user->nick);
35 }
36
37
38 class ModuleSetIdle : public Module
39 {
40  public:
41         ModuleSetIdle()
42         {
43                 Srv = new Server;
44                 Srv->AddCommand("SETIDLE",handle_setidle,'o',1,"m_setidle.so");
45         }
46         
47         virtual ~ModuleSetIdle()
48         {
49                 if (Srv)
50                         delete Srv;
51         }
52         
53         virtual Version GetVersion()
54         {
55                 return Version(1,0,0,1,VF_VENDOR);
56         }
57         
58 };
59
60 // stuff down here is the module-factory stuff. For basic modules you can ignore this.
61
62 class ModuleSetIdleFactory : public ModuleFactory
63 {
64  public:
65         ModuleSetIdleFactory()
66         {
67         }
68         
69         ~ModuleSetIdleFactory()
70         {
71         }
72         
73         virtual Module * CreateModule()
74         {
75                 return new ModuleSetIdle;
76         }
77         
78 };
79
80
81 extern "C" void * init_module( void )
82 {
83         return new ModuleSetIdleFactory;
84 }
85