]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_alltime.cpp
Change module versions to use a string instead of fixed digits, and use propset ID...
[user/henk/code/inspircd.git] / src / modules / m_alltime.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2008 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 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 for " +
35                         ServerInstance->Config->ServerName + " is: " + fmtdate;
36
37                 if (IS_LOCAL(user))
38                 {
39                         user->Write(msg);
40                 }
41                 else
42                 {
43                         ServerInstance->PI->PushToClient(user, ":" + msg);
44                 }
45
46                 /* we want this routed out! */
47                 return CMD_SUCCESS;
48         }
49 };
50
51
52 class Modulealltime : public Module
53 {
54         CommandAlltime *mycommand;
55  public:
56         Modulealltime(InspIRCd *Me)
57                 : Module(Me)
58         {
59                 mycommand = new CommandAlltime(ServerInstance);
60                 ServerInstance->AddCommand(mycommand);
61
62         }
63
64         virtual ~Modulealltime()
65         {
66         }
67
68         virtual Version GetVersion()
69         {
70                 return Version("$Id$", VF_COMMON | VF_VENDOR, API_VERSION);
71         }
72
73 };
74
75 MODULE_INIT(Modulealltime)