]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_alltime.cpp
Someone is getting slapped for this; the new hidesplits/hidebans behavior doesn't...
[user/henk/code/inspircd.git] / src / modules / m_alltime.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 <stdio.h>
15 #include <string>
16 #include "inspircd.h"
17 #include "modules.h"
18
19 /* $ModDesc: Display timestamps from all servers connected to the network */
20
21 class cmd_alltime : public command_t
22 {
23  public:
24         cmd_alltime(InspIRCd *Instance) : command_t(Instance, "ALLTIME", 'o', 0)
25         {
26                 this->source = "m_alltime.so";
27                 syntax = "";
28         }
29
30         CmdResult Handle(const char **parameters, int pcnt, userrec *user)
31         {
32                 char fmtdate[64];
33                 time_t now = ServerInstance->Time();
34                 strftime(fmtdate, sizeof(fmtdate), "%F %T", gmtime(&now));
35                 
36                 int delta = ServerInstance->GetTimeDelta();
37                 
38                 string msg = ":" + string(ServerInstance->Config->ServerName) + " NOTICE " + user->nick + " :Time for " +
39                         ServerInstance->Config->ServerName + " is: " + fmtdate + " (delta " + ConvToStr(delta) + " seconds)";
40                 
41                 if (IS_LOCAL(user))
42                 {
43                         user->Write(msg);
44                 }
45                 else
46                 {
47                         deque<string> params;
48                         params.push_back(user->nick);
49                         params.push_back(msg);
50                         Event ev((char *) &params, NULL, "send_push");
51                         ev.Send(ServerInstance);
52                 }
53                 
54                 return CMD_SUCCESS;
55         }
56 };
57
58 class Modulealltime : public Module
59 {
60         cmd_alltime *mycommand;
61  public:
62         Modulealltime(InspIRCd *Me)
63                 : Module::Module(Me)
64         {
65                 mycommand = new cmd_alltime(ServerInstance);
66                 ServerInstance->AddCommand(mycommand);
67         }
68         
69         virtual ~Modulealltime()
70         {
71         }
72         
73         virtual Version GetVersion()
74         {
75                 return Version(1, 0, 0, 0, VF_COMMON | VF_VENDOR, API_VERSION);
76         }
77         
78 };
79
80 class ModulealltimeFactory : public ModuleFactory
81 {
82  public:
83         ModulealltimeFactory()
84         {
85         }
86         
87         ~ModulealltimeFactory()
88         {
89         }
90         
91         virtual Module *CreateModule(InspIRCd *Me)
92         {
93                 return new Modulealltime(Me);
94         }
95 };
96
97
98 extern "C" void *init_module(void)
99 {
100         return new ModulealltimeFactory;
101 }