The InspIRCd Project
Home | Developers | Wiki | Forums | Bug Tracker | SVN | Download
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

m_foobar.cpp

Go to the documentation of this file.
00001 /*       +------------------------------------+
00002  *       | Inspire Internet Relay Chat Daemon |
00003  *       +------------------------------------+
00004  *
00005  *  InspIRCd: (C) 2002-2008 InspIRCd Development Team
00006  * See: http://www.inspircd.org/wiki/index.php/Credits
00007  *
00008  * This program is free but copyrighted software; see
00009  *            the file COPYING for details.
00010  *
00011  * ---------------------------------------------------
00012  */
00013 
00014 #include "inspircd.h"
00015 
00016 /* $ModDesc: A dummy module for testing */
00017 
00018 // Class ModuleFoobar inherits from Module
00019 // It just outputs simple debug strings to show its methods are working.
00020 
00021 class ModuleFoobar : public Module
00022 {
00023  private:
00024 
00025          // It is recommended that your class makes use of one or more Server
00026          // objects. A server object is a class which contains methods which
00027          // encapsulate the exports from the core of the ircd.
00028          // such methods include Debug, SendChannel, etc.
00029 
00030 
00031  public:
00032         ModuleFoobar(InspIRCd* Me)
00033                 : Module(Me)
00034         {
00035                 // The constructor just makes a copy of the server class
00036 
00037 
00038                 Implementation eventlist[] = { I_OnUserConnect, I_OnUserQuit, I_OnUserJoin, I_OnUserPart, I_OnUserPreJoin };
00039                 ServerInstance->Modules->Attach(eventlist, this, 5);
00040         }
00041 
00042         virtual ~ModuleFoobar()
00043         {
00044         }
00045 
00046         virtual Version GetVersion()
00047         {
00048                 // this method instantiates a class of type Version, and returns
00049                 // the modules version information using it.
00050 
00051                 return Version("$Id: m_foobar.cpp 10291 2008-08-25 20:35:51Z w00t $", VF_VENDOR, API_VERSION);
00052         }
00053 
00054 
00055         virtual void OnUserConnect(User* user)
00056         {
00057                 // method called when a user connects
00058 
00059                 std::string b = user->nick;
00060                 ServerInstance->Logs->Log("m_foobar",DEBUG,"Foobar: User connecting: "+b);
00061         }
00062 
00063         virtual void OnUserQuit(User* user, const std::string &reason, const std::string &oper_message)
00064         {
00065                 // method called when a user disconnects
00066 
00067                 std::string b = user->nick;
00068                 ServerInstance->Logs->Log("m_foobar",DEBUG,"Foobar: User quitting: "+b);
00069         }
00070 
00071         virtual void OnUserJoin(User* user, Channel* channel, bool sync, bool &silent)
00072         {
00073                 // method called when a user joins a channel
00074 
00075                 std::string c = channel->name;
00076                 std::string b = user->nick;
00077                 ServerInstance->Logs->Log("m_foobar",DEBUG,"Foobar: User "+b+" joined "+c);
00078         }
00079 
00080         virtual void OnUserPart(User* user, Channel* channel, std::string &partreason, bool &silent)
00081         {
00082                 // method called when a user parts a channel
00083 
00084                 std::string c = channel->name;
00085                 std::string b = user->nick;
00086                 ServerInstance->Logs->Log("m_foobar",DEBUG,"Foobar: User "+b+" parted "+c);
00087         }
00088 
00089         virtual int OnUserPreJoin(User* user, Channel* chan, const char* cname, std::string &privs, const std::string &keygiven)
00090         {
00091                 return 0;
00092         }
00093 };
00094 
00095 
00096 MODULE_INIT(ModuleFoobar)
00097