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