Call modules for /MODE done by not-in-channel nicks

When ChanServ ops someone in a channel without joining first, znc didn't call
modules for this event, because it couldn't figure out a CNick* instance to use

Instead, the module hooks are now executed with a temporary CNick instance which
is created by CIRCSock anyway.

Big thanks to Robby for reporting this and helping me test it!

Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
Uli Schlachter
2011-02-16 12:53:06 +01:00
parent 087f01e99b
commit a533066dc6
3 changed files with 12 additions and 4 deletions
+10 -2
View File
@@ -220,12 +220,20 @@ void CChan::OnWho(const CString& sNick, const CString& sIdent, const CString& sH
}
}
void CChan::ModeChange(const CString& sModes, const CString& sOpNick) {
void CChan::ModeChange(const CString& sModes, const CNick* pOpNick) {
CString sModeArg = sModes.Token(0);
CString sArgs = sModes.Token(1, true);
bool bAdd = true;
CNick* pOpNick = FindNick(sOpNick);
/* Try to find a CNick* from this channel so that pOpNick->HasPerm()
* works as expected. */
if (pOpNick) {
CNick* OpNick = FindNick(pOpNick->GetNick());
/* If nothing was found, use the original pOpNick, else use the
* CNick* from FindNick() */
if (OpNick)
pOpNick = OpNick;
}
if (pOpNick) {
MODULECALL(OnRawMode(*pOpNick, *this, sModeArg, sArgs), m_pUser, NULL, NOTHING);
+1 -1
View File
@@ -66,7 +66,7 @@ public:
// Modes
void SetModes(const CString& s);
void ModeChange(const CString& sModes, const CString& sNick = "");
void ModeChange(const CString& sModes, const CNick* OpNick = NULL);
bool AddMode(unsigned char uMode, const CString& sArg);
bool RemMode(unsigned char uMode);
CString GetModeString() const;
+1 -1
View File
@@ -500,7 +500,7 @@ void CIRCSock::ReadLine(const CString& sData) {
CChan* pChan = m_pUser->FindChan(sTarget);
if (pChan) {
pChan->ModeChange(sModes, Nick.GetNick());
pChan->ModeChange(sModes, &Nick);
if (pChan->IsDetached()) {
return;