]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/extra/m_httpclienttest.cpp
OOPS! We try again, since I'm smoking craq. LF is 0x0a NOT CR.
[user/henk/code/inspircd.git] / src / modules / extra / m_httpclienttest.cpp
index 3f74b549b888c13ecef2496e1dd03d36fb9d4755..90e7a51590d704c897b47fa6d699da000523eeb2 100644 (file)
@@ -1 +1,81 @@
-/*     +------------------------------------+\r *       | Inspire Internet Relay Chat Daemon |\r *       +------------------------------------+\r *\r *  InspIRCd: (C) 2002-2007 InspIRCd Development Team\r * See: http://www.inspircd.org/wiki/index.php/Credits\r *\r * This program is free but copyrighted software; see\r *          the file COPYING for details.\r *\r * ---------------------------------------------------\r */\r\r#include "inspircd.h"\r#include "users.h"\r#include "channels.h"\r#include "modules.h"\r#include "httpclient.h"\r\r/* $ModDep: httpclient.h */\r\rclass MyModule : public Module\r{\r\rpublic:\r\r  MyModule(InspIRCd* Me)\r         : Module::Module(Me)\r   {\r      }\r\r     virtual ~MyModule()\r    {\r      }\r\r     virtual void Implements(char* List)\r    {\r              List[I_OnRequest] = List[I_OnUserJoin] = List[I_OnUserPart] = 1;\r       }\r\r     virtual Version GetVersion()\r   {\r              return Version(1,0,0,1,VF_VENDOR,API_VERSION);\r }\r\r     virtual void OnUserJoin(userrec* user, chanrec* channel, bool &silent)\r {\r              // method called when a user joins a channel\r\r          std::string chan = channel->name;\r              std::string nick = user->nick;\r         ServerInstance->Log(DEBUG,"User " + nick + " joined " + chan);\r\r                Module* target = ServerInstance->FindModule("m_http_client.so");\r               if(target)\r             {\r                      HTTPClientRequest req(ServerInstance, this, target, "http://znc.in/~psychon");\r                 req.Send();\r            }\r              else\r                   ServerInstance->Log(DEBUG,"module not found, load it!!");\r      }\r\r     char* OnRequest(Request* req)\r  {\r              HTTPClientResponse* resp = (HTTPClientResponse*)req;\r           if(!strcmp(resp->GetId(), HTTP_CLIENT_RESPONSE))\r               {\r                      ServerInstance->Log(DEBUG, resp->GetData()); \r          }\r              return NULL;\r   }\r\r     virtual void OnUserPart(userrec* user, chanrec* channel, const std::string &partmessage, bool &silent)\r {\r      }\r\r};\r\rMODULE_INIT(MyModule);\r\r
\ No newline at end of file
+/*     +------------------------------------+
+ *     | Inspire Internet Relay Chat Daemon |
+ *     +------------------------------------+
+ *
+ *  InspIRCd: (C) 2002-2007 InspIRCd Development Team
+ * See: http://www.inspircd.org/wiki/index.php/Credits
+ *
+ * This program is free but copyrighted software; see
+ *         the file COPYING for details.
+ *
+ * ---------------------------------------------------
+ */
+
+#include "inspircd.h"
+#include "users.h"
+#include "channels.h"
+#include "modules.h"
+#include "httpclient.h"
+
+/* $ModDep: httpclient.h */
+
+class MyModule : public Module
+{
+
+public:
+
+       MyModule(InspIRCd* Me)
+               : Module::Module(Me)
+       {
+       }
+
+       virtual ~MyModule()
+       {
+       }
+
+       virtual void Implements(char* List)
+       {
+               List[I_OnRequest] = List[I_OnUserJoin] = List[I_OnUserPart] = 1;
+       }
+
+       virtual Version GetVersion()
+       {
+               return Version(1,0,0,1,VF_VENDOR,API_VERSION);
+       }
+
+       virtual void OnUserJoin(userrec* user, chanrec* channel, bool &silent)
+       {
+               // method called when a user joins a channel
+
+               std::string chan = channel->name;
+               std::string nick = user->nick;
+               ServerInstance->Log(DEBUG,"User " + nick + " joined " + chan);
+
+               Module* target = ServerInstance->FindModule("m_http_client.so");
+               if(target)
+               {
+                       HTTPClientRequest req(ServerInstance, this, target, "http://znc.in/~psychon");
+                       req.Send();
+               }
+               else
+                       ServerInstance->Log(DEBUG,"module not found, load it!!");
+       }
+
+       char* OnRequest(Request* req)
+       {
+               HTTPClientResponse* resp = (HTTPClientResponse*)req;
+               if(!strcmp(resp->GetId(), HTTP_CLIENT_RESPONSE))
+               {
+                       ServerInstance->Log(DEBUG, resp->GetData()); 
+               }
+               return NULL;
+       }
+
+       virtual void OnUserPart(userrec* user, chanrec* channel, const std::string &partmessage, bool &silent)
+       {
+       }
+
+};
+
+MODULE_INIT(MyModule);
+