Skip to content

Commit

Permalink
Merge pull request #881 from Kriechi/improve-stickychan
Browse files Browse the repository at this point in the history
improve stickychan
  • Loading branch information
DarthGandalf committed Mar 7, 2015
2 parents 0179e85 + 8f3f5b4 commit 4549197
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
20 changes: 16 additions & 4 deletions modules/stickychan.cpp
Expand Up @@ -53,14 +53,28 @@ class CStickyChan : public CModule
return CONTINUE;
}

virtual void OnMode(const CNick& pOpNick, CChan& Channel, char uMode, const CString& sArg, bool bAdded, bool bNoChange) override {
if (uMode == CChan::M_Key) {
if (bAdded) {
// We ignore channel key "*" because of some broken nets.
if (sArg != "*")
{
SetNV(Channel.GetName(), sArg, true);
}
} else {
SetNV(Channel.GetName(), "", true);
}
}
}

void OnStickCommand(const CString& sCommand)
{
CString sChannel = sCommand.Token(1).AsLower();
if (sChannel.empty()) {
PutModule("Usage: Stick <#channel> [key]");
return;
}
SetNV(sChannel, sCommand.Token(2));
SetNV(sChannel, sCommand.Token(2), true);
PutModule("Stuck " + sChannel);
}

Expand All @@ -70,9 +84,7 @@ class CStickyChan : public CModule
PutModule("Usage: Unstick <#channel>");
return;
}
MCString::iterator it = FindNV(sChannel);
if (it != EndNV())
DelNV(it);
DelNV(sChannel, true);
PutModule("Unstuck " + sChannel);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Chan.cpp
Expand Up @@ -374,7 +374,7 @@ void CChan::ModeChange(const CString& sModes, const CNick* pOpNick) {
// This is called when we join (ZNC requests the channel modes
// on join) *and* when someone changes the channel keys.
// We ignore channel key "*" because of some broken nets.
if (uMode == 'k' && !bNoChange && bAdd && sArg != "*") {
if (uMode == M_Key && !bNoChange && bAdd && sArg != "*") {
SetKey(sArg);
}
}
Expand Down

0 comments on commit 4549197

Please sign in to comment.