]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_alltime.cpp
Update all wiki links to point to the new wiki. This was done automatically with...
[user/henk/code/inspircd.git] / src / modules / m_alltime.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2009 InspIRCd Development Team
6  * See: http://wiki.inspircd.org/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 CommandAlltime : public Command
19 {
20  public:
21         CommandAlltime(InspIRCd *Instance) : Command(Instance, "ALLTIME", "o", 0)
22         {
23                 this->source = "m_alltime.so";
24                 syntax.clear();
25                 translation.push_back(TR_END);
26         }
27
28         CmdResult Handle(const std::vector<std::string> &parameters, User *user)
29         {
30                 char fmtdate[64];
31                 time_t now = ServerInstance->Time();
32                 strftime(fmtdate, sizeof(fmtdate), "%Y-%m-%d %H:%M:%S", gmtime(&now));
33
34                 std::string msg = ":" + std::string(ServerInstance->Config->ServerName) + " NOTICE " + user->nick + " :System time is " + fmtdate + "(" + ConvToStr(ServerInstance->Time()) + ") on " + ServerInstance->Config->ServerName;
35
36                 if (IS_LOCAL(user))
37                 {
38                         user->Write(msg);
39                 }
40                 else
41                 {
42                         ServerInstance->PI->PushToClient(user, ":" + msg);
43                 }
44
45                 /* we want this routed out! */
46                 return CMD_SUCCESS;
47         }
48 };
49
50
51 class Modulealltime : public Module
52 {
53         CommandAlltime *mycommand;
54  public:
55         Modulealltime(InspIRCd *Me)
56                 : Module(Me)
57         {
58                 mycommand = new CommandAlltime(ServerInstance);
59                 ServerInstance->AddCommand(mycommand);
60
61         }
62
63         virtual ~Modulealltime()
64         {
65         }
66
67         virtual Version GetVersion()
68         {
69                 return Version("$Id$", VF_COMMON | VF_VENDOR, API_VERSION);
70         }
71
72 };
73
74 MODULE_INIT(Modulealltime)