]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_alltime.cpp
5a05e3339f0fce9f34b61c5808c5134c6f2f805d
[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(Module* Creator) : Command(Creator, "ALLTIME", 0)
22         {
23                 flags_needed = 'o'; syntax.clear();
24                 translation.push_back(TR_END);
25         }
26
27         CmdResult Handle(const std::vector<std::string> &parameters, User *user)
28         {
29                 char fmtdate[64];
30                 time_t now = ServerInstance->Time();
31                 strftime(fmtdate, sizeof(fmtdate), "%Y-%m-%d %H:%M:%S", gmtime(&now));
32
33                 std::string msg = ":" + std::string(ServerInstance->Config->ServerName) + " NOTICE " + user->nick + " :System time is " + fmtdate + "(" + ConvToStr(ServerInstance->Time()) + ") on " + ServerInstance->Config->ServerName;
34
35                 ServerInstance->DumpText(user, msg);
36
37                 /* we want this routed out! */
38                 return CMD_SUCCESS;
39         }
40
41         RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters)
42         {
43                 return ROUTE_BROADCAST;
44         }
45 };
46
47
48 class Modulealltime : public Module
49 {
50         CommandAlltime mycommand;
51  public:
52         Modulealltime(InspIRCd *Me)
53                 : Module(Me), mycommand(this)
54         {
55                 ServerInstance->AddCommand(&mycommand);
56         }
57
58         virtual ~Modulealltime()
59         {
60         }
61
62         virtual Version GetVersion()
63         {
64                 return Version("Display timestamps from all servers connected to the network", VF_COMMON | VF_VENDOR, API_VERSION);
65         }
66
67 };
68
69 MODULE_INIT(Modulealltime)