]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_setidle.cpp
Added remote rehash (even to a mask)
[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 using namespace std;
18
19 #include <stdio.h>
20 #include <string>
21 #include "users.h"
22 #include "channels.h"
23 #include "modules.h"
24 #include "helperfuncs.h"
25
26 /* $ModDesc: Allows opers to set their idle time */
27
28 Server *Srv = NULL;
29          
30 void handle_setidle(char **parameters, int pcnt, userrec *user)
31 {
32         if (atoi(parameters[0]) < 1)
33         {
34                 WriteServ(user->fd,"948 %s :Invalid idle time.",user->nick);
35                 return;
36         }
37         user->idle_lastmsg = time(NULL) - atoi(parameters[0]);
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         Srv->SendOpers(std::string(user->nick)+" used SETIDLE to set their idle time to "+std::string(parameters[0])+" seconds");
42         WriteServ(user->fd,"944 %s :Idle time set.",user->nick);
43 }
44
45
46 class ModuleSetIdle : public Module
47 {
48  public:
49         ModuleSetIdle()
50         {
51                 Srv = new Server;
52                 Srv->AddCommand("SETIDLE",handle_setidle,'o',1,"m_setidle.so");
53         }
54         
55         virtual ~ModuleSetIdle()
56         {
57                 if (Srv)
58                         delete Srv;
59         }
60         
61         virtual Version GetVersion()
62         {
63                 return Version(1,0,0,1,VF_VENDOR);
64         }
65         
66 };
67
68 // stuff down here is the module-factory stuff. For basic modules you can ignore this.
69
70 class ModuleSetIdleFactory : public ModuleFactory
71 {
72  public:
73         ModuleSetIdleFactory()
74         {
75         }
76         
77         ~ModuleSetIdleFactory()
78         {
79         }
80         
81         virtual Module * CreateModule()
82         {
83                 return new ModuleSetIdle;
84         }
85         
86 };
87
88
89 extern "C" void * init_module( void )
90 {
91         return new ModuleSetIdleFactory;
92 }
93