mirror of
https://github.com/znc/znc.git
synced 2026-08-06 08:52:57 +02:00
Add CNumericMessage
This commit is contained in:
@@ -126,6 +126,11 @@ public:
|
||||
void SetText(const CString& sText) { SetParam(1, sText); }
|
||||
};
|
||||
|
||||
class CNumericMessage : public CMessage {
|
||||
public:
|
||||
unsigned int GetCode() const { return GetCommand().ToUInt(); }
|
||||
};
|
||||
|
||||
class CKickMessage : public CTargetMessage {
|
||||
public:
|
||||
CString GetKickedNick() const { return GetParam(1); }
|
||||
|
||||
+2
-1
@@ -182,8 +182,9 @@ void CIRCSock::ReadLine(const CString& sData) {
|
||||
}
|
||||
|
||||
if ((sCmd.length() == 3) && (isdigit(sCmd[0])) && (isdigit(sCmd[1])) && (isdigit(sCmd[2]))) {
|
||||
CNumericMessage& NumericMsg = static_cast<CNumericMessage&>(Message);
|
||||
CString sServer = Message.GetNick().GetHostMask();
|
||||
unsigned int uRaw = sCmd.ToUInt();
|
||||
unsigned int uRaw = NumericMsg.GetCode();
|
||||
CString sNick = Message.GetParam(0);
|
||||
CString sRest = Message.GetParams(1);
|
||||
CString sTmp;
|
||||
|
||||
@@ -189,6 +189,15 @@ TEST(MessageTest, Nick) {
|
||||
EXPECT_EQ(":nick NICK test", msg.ToString());
|
||||
}
|
||||
|
||||
TEST(MessageTest, Numeric) {
|
||||
CNumericMessage msg;
|
||||
msg.Parse(":server 123 user :foo bar");
|
||||
EXPECT_EQ("server", msg.GetNick().GetNick());
|
||||
EXPECT_EQ("123", msg.GetCommand());
|
||||
EXPECT_EQ(123u, msg.GetCode());
|
||||
EXPECT_EQ(CMessage::Type::Numeric, msg.GetType());
|
||||
}
|
||||
|
||||
TEST(MessageTest, Part) {
|
||||
CPartMessage msg;
|
||||
msg.Parse(":nick PART #chan :reason");
|
||||
|
||||
Reference in New Issue
Block a user