diff --git a/modules/block_motd.cpp b/modules/block_motd.cpp index b49e3218..ec8d4b68 100644 --- a/modules/block_motd.cpp +++ b/modules/block_motd.cpp @@ -19,23 +19,43 @@ class CBlockMotd : public CModule { public: MODCONSTRUCTOR(CBlockMotd) { + AddHelpCommand(); + AddCommand("GetMotd", static_cast(&CBlockMotd::OverrideCommand), "[]", "Override the block with this command. Can optionally specify which server to query."); } virtual ~CBlockMotd() { } + void OverrideCommand(const CString& sLine) { + m_bTemporaryAcceptMotd = true; + const CString sServer = sLine.Token(1); + + if (sServer.empty()) { + PutIRC("motd"); + } else { + PutIRC("motd " + sServer); + } + } + EModRet OnRaw(CString &sLine) override { const CString sCmd = sLine.Token(1); - if (sCmd == "375" /* begin of MOTD */ - || sCmd == "372" /* MOTD */) + if ((sCmd == "375" /* begin of MOTD */ || sCmd == "372" /* MOTD */) + && !m_bTemporaryAcceptMotd) return HALT; + if (sCmd == "376" /* End of MOTD */) { - sLine = sLine.Token(0) + " 422 " + - sLine.Token(2) + " :MOTD blocked by ZNC"; + if (!m_bTemporaryAcceptMotd) { + sLine = sLine.Token(0) + " 422 " + + sLine.Token(2) + " :MOTD blocked by ZNC"; + } + m_bTemporaryAcceptMotd = false; } return CONTINUE; } + +private: + bool m_bTemporaryAcceptMotd = false; }; template<> void TModInfo(CModInfo& Info) {