mirror of
https://github.com/znc/znc.git
synced 2026-03-28 17:42:41 +01:00
Merge CChanMessage & CPrivMessage to... CTextMessage
This naming is a bit hairy. I chose CTextMessage because this type of message carries a text argument. Alternatively, it could be also called CPrivateMessage, because the IRC protocol calls it PRIVMSG. On the other hand, ZNC module hooks use the "Priv" naming convention for private messages. It would look a bit weird to have OnChanMsg(CPrivMessage)... More details and reasoning of the merge in the previous commit message.
This commit is contained in:
@@ -93,12 +93,6 @@ public:
|
||||
void SetText(const CString& sText) { SetParam(1, "\001ACTION " + sText + "\001"); }
|
||||
};
|
||||
|
||||
class CChanMessage : public CMessage {
|
||||
public:
|
||||
CString GetText() const { return GetParam(1); }
|
||||
void SetText(const CString& sText) { SetParam(1, sText); }
|
||||
};
|
||||
|
||||
class CCTCPMessage : public CMessage {
|
||||
public:
|
||||
CString GetText() const { return GetParam(1).TrimPrefix_n("\001").TrimSuffix_n("\001"); }
|
||||
@@ -136,18 +130,18 @@ public:
|
||||
void SetReason(const CString& sReason) { SetParam(1, sReason); }
|
||||
};
|
||||
|
||||
class CPrivMessage : public CMessage {
|
||||
public:
|
||||
CString GetText() const { return GetParam(1); }
|
||||
void SetText(const CString& sText) { SetParam(1, sText); }
|
||||
};
|
||||
|
||||
class CQuitMessage : public CMessage {
|
||||
public:
|
||||
CString GetReason() const { return GetParam(0); }
|
||||
void SetReason(const CString& sReason) { SetParam(0, sReason); }
|
||||
};
|
||||
|
||||
class CTextMessage : public CMessage {
|
||||
public:
|
||||
CString GetText() const { return GetParam(1); }
|
||||
void SetText(const CString& sText) { SetParam(1, sText); }
|
||||
};
|
||||
|
||||
class CTopicMessage : public CMessage {
|
||||
public:
|
||||
CString GetTopic() const { return GetParam(1); }
|
||||
@@ -158,15 +152,14 @@ public:
|
||||
// They provide convenient access to message type speficic attributes, but are not
|
||||
// allowed to hold extra data of their own.
|
||||
static_assert(sizeof(CActionMessage) == sizeof(CMessage), "No data members allowed in CMessage subclasses.");
|
||||
static_assert(sizeof(CChanMessage) == sizeof(CMessage), "No data members allowed in CMessage subclasses.");
|
||||
static_assert(sizeof(CCTCPMessage) == sizeof(CMessage), "No data members allowed in CMessage subclasses.");
|
||||
static_assert(sizeof(CJoinMessage) == sizeof(CMessage), "No data members allowed in CMessage subclasses.");
|
||||
static_assert(sizeof(CNoticeMessage) == sizeof(CMessage), "No data members allowed in CMessage subclasses.");
|
||||
static_assert(sizeof(CPartMessage) == sizeof(CMessage), "No data members allowed in CMessage subclasses.");
|
||||
static_assert(sizeof(CPrivMessage) == sizeof(CMessage), "No data members allowed in CMessage subclasses.");
|
||||
static_assert(sizeof(CNickMessage) == sizeof(CMessage), "No data members allowed in CMessage subclasses.");
|
||||
static_assert(sizeof(CKickMessage) == sizeof(CMessage), "No data members allowed in CMessage subclasses.");
|
||||
static_assert(sizeof(CQuitMessage) == sizeof(CMessage), "No data members allowed in CMessage subclasses.");
|
||||
static_assert(sizeof(CTextMessage) == sizeof(CMessage), "No data members allowed in CMessage subclasses.");
|
||||
static_assert(sizeof(CTopicMessage) == sizeof(CMessage), "No data members allowed in CMessage subclasses.");
|
||||
|
||||
#endif // !_MESSAGE_H
|
||||
|
||||
@@ -790,7 +790,7 @@ public:
|
||||
* @return See CModule::EModRet.
|
||||
*/
|
||||
virtual EModRet OnPrivMsg(CNick& Nick, CString& sMessage);
|
||||
virtual EModRet OnPrivMessage(CPrivMessage& Message);
|
||||
virtual EModRet OnPrivMessage(CTextMessage& Message);
|
||||
/** Called when we receive a channel message <em>from IRC</em>.
|
||||
* @param Nick The nick which sent the message.
|
||||
* @param Channel The channel to which the message was sent.
|
||||
@@ -798,7 +798,7 @@ public:
|
||||
* @return See CModule::EModRet.
|
||||
*/
|
||||
virtual EModRet OnChanMsg(CNick& Nick, CChan& Channel, CString& sMessage);
|
||||
virtual EModRet OnChanMessage(CChanMessage& Message);
|
||||
virtual EModRet OnChanMessage(CTextMessage& Message);
|
||||
/** Called when we receive a private notice.
|
||||
* @param Nick The nick which sent the notice.
|
||||
* @param sMessage The notice message.
|
||||
@@ -1251,9 +1251,9 @@ public:
|
||||
bool OnChanAction(CNick& Nick, CChan& Channel, CString& sMessage);
|
||||
bool OnChanActionMessage(CActionMessage& Message);
|
||||
bool OnPrivMsg(CNick& Nick, CString& sMessage);
|
||||
bool OnPrivMessage(CPrivMessage& Message);
|
||||
bool OnPrivMessage(CTextMessage& Message);
|
||||
bool OnChanMsg(CNick& Nick, CChan& Channel, CString& sMessage);
|
||||
bool OnChanMessage(CChanMessage& Message);
|
||||
bool OnChanMessage(CTextMessage& Message);
|
||||
bool OnPrivNotice(CNick& Nick, CString& sMessage);
|
||||
bool OnPrivNoticeMessage(CNoticeMessage& Message);
|
||||
bool OnChanNotice(CNick& Nick, CChan& Channel, CString& sMessage);
|
||||
|
||||
Reference in New Issue
Block a user