diff --git a/modules/q.cpp b/modules/q.cpp index 5551b7a8..7c403348 100644 --- a/modules/q.cpp +++ b/modules/q.cpp @@ -43,6 +43,7 @@ public: m_bUseCloakedHost = (sTmp = GetNV("UseCloakedHost")).empty() ? true : sTmp.ToBool(); m_bUseChallenge = (sTmp = GetNV("UseChallenge")).empty() ? true : sTmp.ToBool(); m_bRequestPerms = GetNV("RequestPerms").ToBool(); + m_bJoinOnInvite = (sTmp = GetNV("JoinOnInvite")).empty() ? true : sTmp.ToBool(); OnIRCDisconnected(); // reset module's state @@ -125,6 +126,10 @@ public: Table2.SetCell("Setting", "RequestPerms"); Table2.SetCell("Type", "Boolean"); Table2.SetCell("Description", "Whether to request voice/op from Q on join/devoice/deop."); + Table2.AddRow(); + Table2.SetCell("Setting", "JoinOnInvite"); + Table2.SetCell("Type", "Boolean"); + Table2.SetCell("Description", "Whether to join channels when Q invites you."); PutModule(Table2); PutModule("This module takes 2 optional parameters: "); @@ -152,6 +157,9 @@ public: } else if (sSetting == "requestperms") { SetRequestPerms(sValue.ToBool()); PutModule("RequestPerms set"); + } else if (sSetting == "joinoninvite") { + SetJoinOnInvite(sValue.ToBool()); + PutModule("JoinOnInvite set"); } else PutModule("Unknown setting: " + sSetting); @@ -174,6 +182,9 @@ public: Table.AddRow(); Table.SetCell("Setting", "RequestPerms"); Table.SetCell("Value", CString(m_bRequestPerms)); + Table.AddRow(); + Table.SetCell("Setting", "JoinOnInvite"); + Table.SetCell("Value", CString(m_bJoinOnInvite)); PutModule(Table); } else if (sCommand == "status") { @@ -242,6 +253,14 @@ public: HandleNeed(Channel, "v"); } + virtual EModRet OnInvite(const CNick& Nick, const CString& sChan) { + if (!Nick.NickEquals("Q") || !Nick.GetHost().Equals("CServe.quakenet.org")) + return CONTINUE; + if (m_bJoinOnInvite) + PutIRC("JOIN " + sChan); + return CONTINUE; + } + private: bool m_bCloaked; @@ -465,6 +484,7 @@ private: bool m_bUseCloakedHost; bool m_bUseChallenge; bool m_bRequestPerms; + bool m_bJoinOnInvite; void SetUsername(const CString& sUsername) { m_sUsername = sUsername; @@ -490,6 +510,11 @@ private: m_bRequestPerms = bRequestPerms; SetNV("RequestPerms", CString(bRequestPerms)); } + + void SetJoinOnInvite(const bool bJoinOnInvite) { + m_bJoinOnInvite = bJoinOnInvite; + SetNV("JoinOnInvite", CString(bJoinOnInvite)); + } }; template<> void TModInfo(CModInfo& Info) {