]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/extra/m_httpclienttest.cpp
a75414368c84e6e3e8ae6653a59bd41ee55e5391
[user/henk/code/inspircd.git] / src / modules / extra / m_httpclienttest.cpp
1 /*      +------------------------------------+
2  *      | Inspire Internet Relay Chat Daemon |
3  *      +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2007 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 #include "users.h"
16 #include "channels.h"
17 #include "modules.h"
18 #include "httpclient.h"
19
20 /* $ModDep: httpclient.h */
21
22 class MyModule : public Module
23 {
24
25 public:
26
27         MyModule(InspIRCd* Me)
28                 : Module::Module(Me)
29         {
30                 Implementation eventlist[] = { I_OnRequest, I_OnUserJoin, I_OnUserPart };
31                 ServerInstance->Modules->Attach(eventlist, this, 3);
32         }
33
34         virtual ~MyModule()
35         {
36         }
37
38
39         virtual Version GetVersion()
40         {
41                 return Version(1,0,0,1,VF_VENDOR,API_VERSION);
42         }
43
44         virtual void OnUserJoin(User* user, Channel* channel, bool &silent)
45         {
46                 // method called when a user joins a channel
47
48                 std::string chan = channel->name;
49                 std::string nick = user->nick;
50                 ServerInstance->Log(DEBUG,"User " + nick + " joined " + chan);
51
52                 Module* target = ServerInstance->Modules->Find("m_http_client.so");
53                 if(target)
54                 {
55                         HTTPClientRequest req(ServerInstance, this, target, "http://znc.in/~psychon");
56                         req.Send();
57                 }
58                 else
59                         ServerInstance->Log(DEBUG,"module not found, load it!!");
60         }
61
62         char* OnRequest(Request* req)
63         {
64                 HTTPClientResponse* resp = (HTTPClientResponse*)req;
65                 if(!strcmp(resp->GetId(), HTTP_CLIENT_RESPONSE))
66                 {
67                         ServerInstance->Log(DEBUG, resp->GetData()); 
68                 }
69                 return NULL;
70         }
71
72         virtual void OnUserPart(User* user, Channel* channel, const std::string &partmessage, bool &silent)
73         {
74         }
75
76 };
77
78 MODULE_INIT(MyModule)
79