Permalink
Browse files

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>
  • Loading branch information...
1 parent 087f01e commit a533066dc675ffa004379032e707630263d4b842 @psychon psychon committed Feb 16, 2011
Showing with 12 additions and 4 deletions.
  1. +10 −2 Chan.cpp
  2. +1 −1 Chan.h
  3. +1 −1 IRCSock.cpp
View
@@ -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);
View
@@ -66,7 +66,7 @@ class CChan {
// 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;
View
@@ -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;

0 comments on commit a533066

Please sign in to comment.