diff --git a/Client.cpp b/Client.cpp index 20b38796..081458cb 100644 --- a/Client.cpp +++ b/Client.cpp @@ -222,6 +222,24 @@ void CClient::ReadLine(const CString& sData) { if (!sMessage.empty()) { sLine += " :" + sMessage; } + } else if (sCommand.CaseCmp("TOPIC") == 0) { + CString sChan = sLine.Token(1); + CString sTopic = sLine.Token(2, true); + bool bUnset = false; + + if (sTopic.Left(1) == ":") { + sTopic.LeftChomp(); + if (sTopic.empty()) + bUnset = true; + } + + MODULECALL(OnUserTopic(sChan, sTopic), m_pUser, this, return); + + sLine = "TOPIC " + sChan; + + if (!sTopic.empty() || bUnset) { + sLine += " :" + sTopic; + } } else if (sCommand.CaseCmp("MODE") == 0) { CString sTarget = sLine.Token(1); CString sModes = sLine.Token(2, true); diff --git a/Modules.cpp b/Modules.cpp index 06e39be2..680c3cfc 100644 --- a/Modules.cpp +++ b/Modules.cpp @@ -520,6 +520,7 @@ CModule::EModRet CModule::OnUserMsg(CString& sTarget, CString& sMessage) { retur CModule::EModRet CModule::OnUserNotice(CString& sTarget, CString& sMessage) { return CONTINUE; } CModule::EModRet CModule::OnUserJoin(CString& sChannel, CString& sKey) { return CONTINUE; } CModule::EModRet CModule::OnUserPart(CString& sChannel, CString& sMessage) { return CONTINUE; } +CModule::EModRet CModule::OnUserTopic(CString& sChannel, CString& sTopic) { return CONTINUE; } CModule::EModRet CModule::OnCTCPReply(CNick& Nick, CString& sMessage) { return CONTINUE; } CModule::EModRet CModule::OnPrivCTCP(CNick& Nick, CString& sMessage) { return CONTINUE; } @@ -624,6 +625,7 @@ bool CModules::OnUserMsg(CString& sTarget, CString& sMessage) { MODHALTCHK(OnUse bool CModules::OnUserNotice(CString& sTarget, CString& sMessage) { MODHALTCHK(OnUserNotice(sTarget, sMessage)); } bool CModules::OnUserJoin(CString& sChannel, CString& sKey) { MODHALTCHK(OnUserJoin(sChannel, sKey)); } bool CModules::OnUserPart(CString& sChannel, CString& sMessage) { MODHALTCHK(OnUserPart(sChannel, sMessage)); } +bool CModules::OnUserTopic(CString& sChannel, CString& sTopic) { MODHALTCHK(OnUserTopic(sChannel, sTopic)); } bool CModules::OnQuit(const CNick& Nick, const CString& sMessage, const vector& vChans) { MODUNLOADCHK(OnQuit(Nick, sMessage, vChans)); return false; } bool CModules::OnNick(const CNick& Nick, const CString& sNewNick, const vector& vChans) { MODUNLOADCHK(OnNick(Nick, sNewNick, vChans)); return false; } diff --git a/Modules.h b/Modules.h index e97eff9b..03212399 100644 --- a/Modules.h +++ b/Modules.h @@ -263,6 +263,7 @@ public: virtual EModRet OnUserNotice(CString& sTarget, CString& sMessage); virtual EModRet OnUserJoin(CString& sChannel, CString& sKey); virtual EModRet OnUserPart(CString& sChannel, CString& sMessage); + virtual EModRet OnUserTopic(CString& sChannel, CString& sTopic); virtual EModRet OnCTCPReply(CNick& Nick, CString& sMessage); virtual EModRet OnPrivCTCP(CNick& Nick, CString& sMessage); @@ -400,6 +401,7 @@ public: virtual bool OnUserNotice(CString& sTarget, CString& sMessage); virtual bool OnUserJoin(CString& sChannel, CString& sKey); virtual bool OnUserPart(CString& sChannel, CString& sMessage); + virtual bool OnUserTopic(CString& sChannel, CString& sTopic); virtual bool OnCTCPReply(CNick& Nick, CString& sMessage); virtual bool OnPrivCTCP(CNick& Nick, CString& sMessage); diff --git a/modules/sample.cpp b/modules/sample.cpp index 4fbcac91..3d05e86e 100644 --- a/modules/sample.cpp +++ b/modules/sample.cpp @@ -7,6 +7,7 @@ */ #include "Chan.h" +#include "User.h" #include "Modules.h" class CSampleTimer : public CTimer { @@ -171,6 +172,12 @@ public: return CONTINUE; } + virtual EModRet OnUserTopic(CString& sTarget, CString& sTopic) { + PutModule("* " + m_pUser->GetCurNick() + " changed topic on " + sTarget + " to '" + sTopic + "'"); + + return CONTINUE; + } + virtual EModRet OnUserMsg(CString& sTarget, CString& sMessage) { PutModule("[" + sTarget + "] usermsg [" + sMessage + "]"); sMessage = "Sample: \0034" + sMessage + "\003";