]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/extra/m_httpclienttest.cpp
Correctly allow all supporting versions of PostgreSQL to use secure string escaping.
[user/henk/code/inspircd.git] / src / modules / extra / m_httpclienttest.cpp
1 #include "users.h"
2 #include "channels.h"
3 #include "modules.h"
4 #include "inspircd.h"
5 #include "httpclient.h"
6
7 /* $ModDep: httpclient.h */
8
9 class MyModule : public Module
10 {
11 public:
12        MyModule(InspIRCd* Me)
13                : Module::Module(Me)
14        {
15        }
16
17        virtual ~MyModule()
18        {
19        }
20
21        virtual void Implements(char* List)
22        {
23                 List[I_OnRequest] = List[I_OnUserJoin] = List[I_OnUserPart] = 1;
24        }
25
26        virtual Version GetVersion()
27        {
28                return Version(1,0,0,1,0,API_VERSION);
29        }
30
31        virtual void OnUserJoin(userrec* user, chanrec* channel)
32        {
33                // method called when a user joins a channel
34
35                std::string chan = channel->name;
36                std::string nick = user->nick;
37 //               ServerInstance->Log(DEBUG,"User " + nick + " joined " + chan);
38
39                            Module* target = ServerInstance->FindModule("m_http_client.so");
40                            if(target) {
41                                    HTTPClientRequest req(ServerInstance, this, target, "http://znc.in/~psychon");
42                                    req.Send();
43                            }
44                            else
45                                    ServerInstance->Log(DEBUG,"module not found, load it!!");
46        }
47
48            char* OnRequest(Request* req)
49            {
50                    HTTPClientResponse* resp = (HTTPClientResponse*)req;
51                    if(!strcmp(resp->GetId(), HTTP_CLIENT_RESPONSE))
52                    {
53                           ServerInstance->Log(DEBUG, resp->GetData()); 
54                    }
55                    return NULL;
56            }
57
58        virtual void OnUserPart(userrec* user, chanrec* channel, const std::string &partmessage)
59        {
60        }
61
62 };
63
64 class MyModuleFactory : public ModuleFactory
65 {
66 public:
67        MyModuleFactory()
68        {
69        }
70
71        ~MyModuleFactory()
72        {
73        }
74
75        virtual Module * CreateModule(InspIRCd* Me)
76        {
77                return new MyModule(Me);
78        }
79
80 };
81
82 extern "C" void * init_module( void )
83 {
84        return new MyModuleFactory;
85 }
86