]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_alltime.cpp
Add modules to the VF_COMMON list in backwards compatability link mode, translate...
[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, Module* Creator) : Command(Instance, Creator, "ALLTIME", "o", 0)
22         {
23                 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                 if (IS_LOCAL(user))
36                 {
37                         user->Write(msg);
38                 }
39                 else
40                 {
41                         ServerInstance->PI->PushToClient(user, ":" + msg);
42                 }
43
44                 /* we want this routed out! */
45                 return CMD_SUCCESS;
46         }
47 };
48
49
50 class Modulealltime : public Module
51 {
52         CommandAlltime mycommand;
53  public:
54         Modulealltime(InspIRCd *Me)
55                 : Module(Me), mycommand(Me, this)
56         {
57                 ServerInstance->AddCommand(&mycommand);
58         }
59
60         virtual ~Modulealltime()
61         {
62         }
63
64         virtual Version GetVersion()
65         {
66                 return Version("$Id$", VF_COMMON | VF_VENDOR, API_VERSION);
67         }
68
69 };
70
71 MODULE_INIT(Modulealltime)