]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_alltime.cpp
70773167b3969fbe45faf40c303daaab59e134fd
[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 "inspircd.h"
15
16 /* $ModDesc: Display timestamps from all servers connected to the network */
17
18 class cmd_alltime : public command_t
19 {
20  public:
21         cmd_alltime(InspIRCd *Instance) : command_t(Instance, "ALLTIME", 'o', 0)
22         {
23                 this->source = "m_alltime.so";
24                 syntax.clear();
25         }
26
27         CmdResult Handle(const char **parameters, int pcnt, userrec *user)
28         {
29                 char fmtdate[64];
30                 char fmtdate2[64];
31                 time_t now = ServerInstance->Time(false);
32                 strftime(fmtdate, sizeof(fmtdate), "%F %T", gmtime(&now));
33                 now = ServerInstance->Time(true);
34                 strftime(fmtdate2, sizeof(fmtdate2), "%F %T", gmtime(&now));
35                 
36                 int delta = ServerInstance->GetTimeDelta();
37                 
38                 string msg = ":" + string(ServerInstance->Config->ServerName) + " NOTICE " + user->nick + " :System time for " +
39                         ServerInstance->Config->ServerName + " is: " + fmtdate + " (delta " + ConvToStr(delta) + " seconds): Time with delta: "+ fmtdate2;
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                 /* we want this routed out! */
55                 return CMD_SUCCESS;
56         }
57 };
58
59
60 class Modulealltime : public Module
61 {
62         cmd_alltime *mycommand;
63  public:
64         Modulealltime(InspIRCd *Me)
65                 : Module(Me)
66         {
67                 mycommand = new cmd_alltime(ServerInstance);
68                 ServerInstance->AddCommand(mycommand);
69         }
70         
71         virtual ~Modulealltime()
72         {
73         }
74         
75         virtual Version GetVersion()
76         {
77                 return Version(1, 0, 0, 0, VF_COMMON | VF_VENDOR, API_VERSION);
78         }
79         
80 };
81
82 MODULE_INIT(Modulealltime)