]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/extra/m_httpclienttest.cpp
41a0b162eff2a50c6b46a6ea697ba42a6a062ecf
[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         }
31
32         virtual ~MyModule()
33         {
34         }
35
36         virtual void Implements(char* List)
37         {
38                 List[I_OnRequest] = List[I_OnUserJoin] = List[I_OnUserPart] = 1;
39         }
40
41         virtual Version GetVersion()
42         {
43                 return Version(1,0,0,1,VF_VENDOR,API_VERSION);
44         }
45
46         virtual void OnUserJoin(userrec* user, chanrec* channel, bool &silent)
47         {
48                 // method called when a user joins a channel
49
50                 std::string chan = channel->name;
51                 std::string nick = user->nick;
52                 ServerInstance->Log(DEBUG,"User " + nick + " joined " + chan);
53
54                 Module* target = ServerInstance->Modules->Find("m_http_client.so");
55                 if(target)
56                 {
57                         HTTPClientRequest req(ServerInstance, this, target, "http://znc.in/~psychon");
58                         req.Send();
59                 }
60                 else
61                         ServerInstance->Log(DEBUG,"module not found, load it!!");
62         }
63
64         char* OnRequest(Request* req)
65         {
66                 HTTPClientResponse* resp = (HTTPClientResponse*)req;
67                 if(!strcmp(resp->GetId(), HTTP_CLIENT_RESPONSE))
68                 {
69                         ServerInstance->Log(DEBUG, resp->GetData()); 
70                 }
71                 return NULL;
72         }
73
74         virtual void OnUserPart(userrec* user, chanrec* channel, const std::string &partmessage, bool &silent)
75         {
76         }
77
78 };
79
80 MODULE_INIT(MyModule);
81