mirror of
https://github.com/inspircd/inspircd.git
synced 2025-03-10 02:59:01 -04:00
Added ModeParser::AddModeWatcher() and ModeParser::DelModeWatcher()
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4266 e03df62e-2008-0410-955e-edbf42e46eb7
This commit is contained in:
parent
d8aba7e60b
commit
db75baa96d
@ -315,6 +315,24 @@ class ModeParser
|
||||
* @return True if the mode was successfully added.
|
||||
*/
|
||||
bool AddMode(ModeHandler* mh, unsigned const char modeletter);
|
||||
/**
|
||||
* Add a mode watcher.
|
||||
* A mode watcher is triggered before and after a mode handler is
|
||||
* triggered. See the documentation of class ModeWatcher for more
|
||||
* information.
|
||||
* @param mw The ModeWatcher you want to add
|
||||
* @return True if the ModeWatcher was added correctly
|
||||
*/
|
||||
bool AddModeWatcher(ModeWatcher* mw);
|
||||
/**
|
||||
* Delete a mode watcher.
|
||||
* A mode watcher is triggered before and after a mode handler is
|
||||
* triggered. See the documentation of class ModeWatcher for more
|
||||
* information.
|
||||
* @param mw The ModeWatcher you want to delete
|
||||
* @return True if the ModeWatcher was deleted correctly
|
||||
*/
|
||||
bool DelModeWatcher(ModeWatcher* mw);
|
||||
/**
|
||||
* Process a set of mode changes from a server or user.
|
||||
* @param parameters The parameters of the mode change, in the format
|
||||
|
51
src/mode.cpp
51
src/mode.cpp
@ -530,17 +530,62 @@ bool ModeParser::AddMode(ModeHandler* mh, unsigned const char modeletter)
|
||||
* If they do that, thats their problem, and if i ever EVER see an
|
||||
* official InspIRCd developer do that, i'll beat them with a paddle!
|
||||
*/
|
||||
if ((modeletter < 'A') || (modeletter > 'z'))
|
||||
if ((mh->GetModeChar() < 'A') || (mh->GetModeChar() > 'z'))
|
||||
return false;
|
||||
|
||||
mh->GetModeType() == MODETYPE_USER ? mask = MASK_USER : mask = MASK_CHANNEL;
|
||||
pos = (modeletter-65) | mask;
|
||||
pos = (mh->GetModeChar()-65) | mask;
|
||||
|
||||
if (modehandlers[pos])
|
||||
return false;
|
||||
|
||||
modehandlers[pos] = mh;
|
||||
log(DEBUG,"ModeParser::AddMode: added mode %c",modeletter);
|
||||
log(DEBUG,"ModeParser::AddMode: added mode %c",mh->GetModeChar());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ModeParser::AddModeWatcher(ModeWatcher* mw)
|
||||
{
|
||||
unsigned char mask = 0;
|
||||
unsigned char pos = 0;
|
||||
|
||||
if (!mw)
|
||||
return false;
|
||||
|
||||
if ((mw->GetModeChar() < 'A') || (mw->GetModeChar() > 'z'))
|
||||
return false;
|
||||
|
||||
mw->GetModeType() == MODETYPE_USER ? mask = MASK_USER : mask = MASK_CHANNEL;
|
||||
pos = (mw->GetModeChar()-65) | mask;
|
||||
|
||||
modewatchers[pos].push_back(mw);
|
||||
log(DEBUG,"ModeParser::AddModeWatcher: watching mode %c",mw->GetModeChar());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ModeParser::DelModeWatcher(ModeWatcher* mw)
|
||||
{
|
||||
unsigned char mask = 0;
|
||||
unsigned char pos = 0;
|
||||
|
||||
if (!mw)
|
||||
return false;
|
||||
|
||||
if ((mw->GetModeType() < 'A') || (mw->GetModeType() > 'z'))
|
||||
return false;
|
||||
|
||||
mw->GetModeType() == MODETYPE_USER ? mask = MASK_USER : mask = MASK_CHANNEL;
|
||||
pos = (mw->GetModeChar()-65) | mask;
|
||||
|
||||
ModeWatchIter a = find(modewatchers[pos].begin(),modewatchers[pos].end(),mw);
|
||||
|
||||
if (a == modewatchers[pos].end())
|
||||
return false;
|
||||
|
||||
modewatchers[pos].erase(a);
|
||||
log(DEBUG,"ModeParser::DelModeWatcher: stopped watching mode %c",mw->GetModeChar());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user