]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_alltime.cpp
Added <options:notimesync> to the example config
[user/henk/code/inspircd.git] / src / modules / m_alltime.cpp
1 /* Written by Special (john@yarbbles.com) */
2
3 using namespace std;
4
5 #include <stdio.h>
6 #include <string>
7 #include "inspircd.h"
8 #include "modules.h"
9
10 /* $ModDesc: Display timestamps from all servers connected to the network */
11
12 class cmd_alltime : public command_t
13 {
14  public:
15         cmd_alltime(InspIRCd *Instance) : command_t(Instance, "ALLTIME", 'o', 0)
16         {
17                 this->source = "m_alltime.so";
18                 syntax = "";
19         }
20
21         CmdResult Handle(const char **parameters, int pcnt, userrec *user)
22         {
23                 char fmtdate[64];
24                 time_t time = ServerInstance->Time();
25                 strftime(fmtdate, sizeof(fmtdate), "%F %T", gmtime(&time));
26                 
27                 string msg = ":" + string(ServerInstance->Config->ServerName) + " NOTICE " + user->nick + " :Time for " +
28                         ServerInstance->Config->ServerName + " is: " + fmtdate;
29                 
30                 if (IS_LOCAL(user))
31                 {
32                         user->Write(msg);
33                 }
34                 else
35                 {
36                         deque<string> params;
37                         params.push_back(user->nick);
38                         params.push_back(msg);
39                         Event ev((char *) &params, NULL, "send_push");
40                         ev.Send(ServerInstance);
41                 }
42                 
43                 return CMD_SUCCESS;
44         }
45 };
46
47 class Modulealltime : public Module
48 {
49         cmd_alltime *mycommand;
50  public:
51         Modulealltime(InspIRCd *Me)
52                 : Module::Module(Me)
53         {
54                 mycommand = new cmd_alltime(ServerInstance);
55                 ServerInstance->AddCommand(mycommand);
56         }
57         
58         virtual ~Modulealltime()
59         {
60         }
61         
62         virtual Version GetVersion()
63         {
64                 return Version(1, 0, 0, 0, VF_COMMON | VF_VENDOR, API_VERSION);
65         }
66         
67 };
68
69 class ModulealltimeFactory : public ModuleFactory
70 {
71  public:
72         ModulealltimeFactory()
73         {
74         }
75         
76         ~ModulealltimeFactory()
77         {
78         }
79         
80         virtual Module *CreateModule(InspIRCd *Me)
81         {
82                 return new Modulealltime(Me);
83         }
84 };
85
86
87 extern "C" void *init_module(void)
88 {
89         return new ModulealltimeFactory;
90 }