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

ModuleBlockColour Class Reference

Inheritance diagram for ModuleBlockColour:

Inheritance graph
[legend]
Collaboration diagram for ModuleBlockColour:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 ModuleBlockColour (InspIRCd *Me)
void Implements (char *List)
 The Implements function specifies which methods a module should receive events for.
virtual int OnUserPreMessage (userrec *user, void *dest, int target_type, std::string &text, char status, CUList &exempt_list)
 Called whenever a user is about to PRIVMSG A user or a channel, before any processing is done.
virtual int OnUserPreNotice (userrec *user, void *dest, int target_type, std::string &text, char status, CUList &exempt_list)
 Called whenever a user is about to NOTICE A user or a channel, before any processing is done.
virtual ~ModuleBlockColour ()
virtual Version GetVersion ()
 Returns the version number of a Module.

Private Attributes

bool AllowChanOps
BlockColorbc

Detailed Description

Definition at line 51 of file m_blockcolor.cpp.


Constructor & Destructor Documentation

ModuleBlockColour::ModuleBlockColour InspIRCd Me  )  [inline]
 

Definition at line 57 of file m_blockcolor.cpp.

References InspIRCd::AddMode(), bc, and Module::ServerInstance.

00057                                         : Module(Me)
00058         {
00059                 bc = new BlockColor(ServerInstance);
00060                 if (!ServerInstance->AddMode(bc, 'c'))
00061                         throw ModuleException("Could not add new modes!");
00062         }

virtual ModuleBlockColour::~ModuleBlockColour  )  [inline, virtual]
 

Definition at line 106 of file m_blockcolor.cpp.

References bc, DELETE(), ModeParser::DelMode(), InspIRCd::Modes, and Module::ServerInstance.

00107         {
00108                 ServerInstance->Modes->DelMode(bc);
00109                 DELETE(bc);
00110         }


Member Function Documentation

virtual Version ModuleBlockColour::GetVersion  )  [inline, virtual]
 

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 112 of file m_blockcolor.cpp.

References API_VERSION, VF_COMMON, and VF_VENDOR.

00113         {
00114                 return Version(1,1,0,0,VF_COMMON|VF_VENDOR,API_VERSION);
00115         }

void ModuleBlockColour::Implements char *  List  )  [inline, virtual]
 

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;

Parameters:
The implement list

Reimplemented from Module.

Definition at line 64 of file m_blockcolor.cpp.

References I_OnUserPreMessage, and I_OnUserPreNotice.

00065         {
00066                 List[I_OnUserPreMessage] = List[I_OnUserPreNotice] = 1;
00067         }

virtual int ModuleBlockColour::OnUserPreMessage userrec user,
void *  dest,
int  target_type,
std::string text,
char  status,
CUList exempt_list
[inline, virtual]
 

Called whenever a user is about to PRIVMSG A user or a channel, before any processing is done.

Returning any nonzero value 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 filter or redirect messages. target_type can be one of TYPE_USER or TYPE_CHANNEL. If the target_type value is a user, you must cast dest to a userrec* otherwise you must cast it to a chanrec*, this is the details of where the message is destined to be sent.

Parameters:
user The user sending the message
dest The target of the message (chanrec* or userrec*)
target_type The type of target (TYPE_USER or TYPE_CHANNEL)
text Changeable text being sent by the user
status The status being used, e.g. PRIVMSG #chan has status== '@', 0 to send to everyone.
exempt_list A list of users not to send to. For channel messages, this will usually contain just the sender. It will be ignored for private messages.
Returns:
1 to deny the message, 0 to allow it

Reimplemented from Module.

Definition at line 70 of file m_blockcolor.cpp.

References CHANOPS_EXEMPT, chanrec::GetStatus(), IS_LOCAL, chanrec::IsModeSet(), chanrec::name, userrec::nick, Module::ServerInstance, STATUS_OP, TYPE_CHANNEL, and userrec::WriteServ().

Referenced by OnUserPreNotice().

00071         {
00072                 if ((target_type == TYPE_CHANNEL) && (IS_LOCAL(user)))
00073                 {
00074                         chanrec* c = (chanrec*)dest;
00075                         
00076                         if(c->IsModeSet('c'))
00077                         {
00078                                 if (!CHANOPS_EXEMPT(ServerInstance, 'c') || CHANOPS_EXEMPT(ServerInstance, 'c') && c->GetStatus(user) != STATUS_OP)
00079                                 {
00080                                         for (std::string::iterator i = text.begin(); i != text.end(); i++)
00081                                         {
00082                                                 switch (*i)
00083                                                 {
00084                                                         case 2:
00085                                                         case 3:
00086                                                         case 15:
00087                                                         case 21:
00088                                                         case 22:
00089                                                         case 31:
00090                                                                 user->WriteServ("404 %s %s :Can't send colours to channel (+c set)",user->nick, c->name);
00091                                                                 return 1;
00092                                                         break;
00093                                                 }
00094                                         }
00095                                 }
00096                         }
00097                 }
00098                 return 0;
00099         }

virtual int ModuleBlockColour::OnUserPreNotice userrec user,
void *  dest,
int  target_type,
std::string text,
char  status,
CUList exempt_list
[inline, virtual]
 

Called whenever a user is about to NOTICE A user or a channel, before any processing is done.

Returning any nonzero value 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 filter or redirect messages. target_type can be one of TYPE_USER or TYPE_CHANNEL. If the target_type value is a user, you must cast dest to a userrec* otherwise you must cast it to a chanrec*, this is the details of where the message is destined to be sent. You may alter the message text as you wish before relinquishing control to the next module in the chain, and if no other modules block the text this altered form of the text will be sent out to the user and possibly to other servers.

Parameters:
user The user sending the message
dest The target of the message (chanrec* or userrec*)
target_type The type of target (TYPE_USER or TYPE_CHANNEL)
text Changeable text being sent by the user
status The status being used, e.g. PRIVMSG #chan has status== '@', 0 to send to everyone.
exempt_list A list of users not to send to. For channel notices, this will usually contain just the sender. It will be ignored for private notices.
Returns:
1 to deny the NOTICE, 0 to allow it

Reimplemented from Module.

Definition at line 101 of file m_blockcolor.cpp.

References OnUserPreMessage().

00102         {
00103                 return