]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_alltime.cpp
Remote user messaging fixes
[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                 ServerInstance->DumpText(user, msg);
36
37                 /* we want this routed out! */
38                 return CMD_SUCCESS;
39         }
40 };
41
42
43 class Modulealltime : public Module
44 {
45         CommandAlltime mycommand;
46  public:
47         Modulealltime(InspIRCd *Me)
48                 : Module(Me), mycommand(Me, this)
49         {
50                 ServerInstance->AddCommand(&mycommand);
51         }
52
53         virtual ~Modulealltime()
54         {
55         }
56
57         virtual Version GetVersion()
58         {
59                 return Version("$Id$", VF_COMMON | VF_VENDOR, API_VERSION);
60         }
61
62 };
63
64 MODULE_INIT(Modulealltime)