|
|||
|
|||
|


Public Member Functions | |
| ModuleRestrictChans (InspIRCd *Me) | |
| virtual void | OnRehash (userrec *user, const std::string ¶meter) |
| Called on rehash. | |
| void | Implements (char *List) |
| The Implements function specifies which methods a module should receive events for. | |
| virtual int | OnUserPreJoin (userrec *user, chanrec *chan, const char *cname, std::string &privs) |
| Called whenever a user is about to join a channel, before any processing is done. | |
| virtual | ~ModuleRestrictChans () |
| virtual Version | GetVersion () |
| Returns the version number of a Module. | |
Private Member Functions | |
| void | ReadConfig () |
Private Attributes | |
| std::map< irc::string, int > | allowchans |
Definition at line 21 of file m_restrictchans.cpp.
|
|
Definition at line 42 of file m_restrictchans.cpp. References ReadConfig(). 00043 : Module(Me) 00044 { 00045 00046 ReadConfig(); 00047 }
|
|
|
Definition at line 79 of file m_restrictchans.cpp.
|
|
|
Returns the version number of a Module. The method should return a Version object with its version information assigned via Version::Version Reimplemented from Module. Definition at line 83 of file m_restrictchans.cpp. References API_VERSION, and VF_VENDOR. 00084 { 00085 return Version(1,1,0,1,VF_VENDOR,API_VERSION); 00086 }
|
|
|
The Implements function specifies which methods a module should receive events for. The char* parameter passed to this function contains a set of true or false values (1 or 0) which indicate wether each function is implemented. You must use the Iimplementation enum (documented elsewhere on this page) to mark functions as active. For example, to receive events for OnUserJoin(): Implements[I_OnUserJoin] = 1;
Reimplemented from Module. Definition at line 54 of file m_restrictchans.cpp. References I_OnRehash, and I_OnUserPreJoin. 00055 { 00056 List[I_OnUserPreJoin] = List[I_OnRehash] = 1; 00057 }
|
|
||||||||||||
|
Called on rehash. This method is called prior to a /REHASH or when a SIGHUP is received from the operating system. You should use it to reload any files so that your module keeps in step with the rest of the application. If a parameter is given, the core has done nothing. The module receiving the event can decide if this parameter has any relevence to it.
Reimplemented from Module. Definition at line 49 of file m_restrictchans.cpp. References ReadConfig(). 00050 { 00051 ReadConfig(); 00052 }
|
|
||||||||||||||||||||
|
Called whenever a user is about to join a channel, before any processing is done. Returning a value of 1 from this function stops the process immediately, causing no output to be sent to the user by the core. If you do this you must produce your own numerics, notices etc. This is useful for modules which may want to mimic +b, +k, +l etc. Returning -1 from this function forces the join to be allowed, bypassing restrictions such as banlists, invite, keys etc. IMPORTANT NOTE! If the user joins a NEW channel which does not exist yet, OnUserPreJoin will be called BEFORE the channel record is created. This will cause chanrec* chan to be NULL. There is very little you can do in form of processing on the actual channel record at this point, however the channel NAME will still be passed in char* cname, so that you could for example implement a channel blacklist or whitelist, etc.
Reimplemented from Module. Definition at line 59 of file m_restrictchans.cpp. References allowchans, IS_LOCAL, IS_OPER, userrec::nick, and userrec::WriteServ(). 00060 { 00061 irc::string x = cname; 00062 00063 if (!IS_LOCAL(user)) 00064 return 0; 00065 00066 // user is not an oper and its not in the allow list 00067 if ((!IS_OPER(user)) && (allowchans.find(x) == allowchans.end())) 00068 { 00069 // channel does not yet exist (record is null, about to be created IF we were to allow it) 00070 if (!chan) 00071 { 00072 user->WriteServ("530 %s %s :Only IRC operators may create new channels",user->nick,cname,cname); 00073 return 1; 00074 } 00075 } 00076 return 0; 00077 }
|
|
|
Definition at line 27 of file m_restrictchans.cpp. References allowchans, DELETE(), ConfigReader::ReadValue(), and Module::ServerInstance. Referenced by ModuleRestrictChans(), and OnRehash(). 00028 { 00029 ConfigReader* MyConf = new ConfigReader(ServerInstance); 00030 allowchans.clear(); 00031 for (int i = 0; i < MyConf->Enumerate("allowchannel"); i++) 00032 { 00033 std::string txt; 00034 txt = MyConf->ReadValue("allowchannel", "name", i); 00035 irc::string channel = txt.c_str(); 00036 allowchans[channel] = 1; 00037 } 00038 DELETE(MyConf); 00039 }
|
|
|
Definition at line 25 of file m_restrictchans.cpp. Referenced by OnUserPreJoin(), and ReadConfig(). |