From 8e59fb957c329851cc1052de6f07804815568d9b Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Mon, 21 Feb 2011 11:50:07 +0100 Subject: [PATCH] Add CModule::OnUnknownModCommand() This module hook is called to generate messages for unknown commands. This hook has a default implementation that actually does something! Signed-off-by: Uli Schlachter --- Modules.cpp | 11 ++++++++++- Modules.h | 7 +++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/Modules.cpp b/Modules.cpp index 65538e7d3a..7967ef5449 100644 --- a/Modules.cpp +++ b/Modules.cpp @@ -431,6 +431,8 @@ bool CModule::HandleCommand(const CString& sLine) { return true; } + OnUnknownModCommand(sLine); + return false; } @@ -478,10 +480,17 @@ void CModule::OnMode(const CNick& OpNick, CChan& Channel, char uMode, const CStr CModule::EModRet CModule::OnRaw(CString& sLine) { return CONTINUE; } CModule::EModRet CModule::OnStatusCommand(CString& sCommand) { return CONTINUE; } -void CModule::OnModCommand(const CString& sCommand) { HandleCommand(sCommand); } void CModule::OnModNotice(const CString& sMessage) {} void CModule::OnModCTCP(const CString& sMessage) {} +void CModule::OnModCommand(const CString& sCommand) { + HandleCommand(sCommand); +} +void CModule::OnUnknownModCommand(const CString& sLine) { + if (!m_mCommands.empty()) + PutModule("Unknown command!"); +} + void CModule::OnQuit(const CNick& Nick, const CString& sMessage, const vector& vChans) {} void CModule::OnNick(const CNick& Nick, const CString& sNewNick, const vector& vChans) {} void CModule::OnKick(const CNick& Nick, const CString& sKickedNick, CChan& Channel, const CString& sMessage) {} diff --git a/Modules.h b/Modules.h index ec2abc7398..1ba42b446a 100644 --- a/Modules.h +++ b/Modules.h @@ -494,6 +494,13 @@ class CModule { * @param sCommand The command that was sent. */ virtual void OnModCommand(const CString& sCommand); + /** This is similar to OnModCommand(), but it is only called if + * HandleCommand didn't find any that wants to handle this. This is only + * called if HandleCommand() is called, which practically means that + * this is only called if you don't overload OnModCommand(). + * @param sCommand The command that was sent. + */ + virtual void OnUnknownModCommand(const CString& sCommand); /** Called when a your module nick was sent a notice. * @param sMessage The message which was sent. */