Skip to content
This repository was archived by the owner on Aug 16, 2024. It is now read-only.

Commit ab4517c

Browse files
committed
MessageChain 支持比较;
1 parent 712c183 commit ab4517c

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

include/defs/message_chain.hpp

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,41 @@ namespace Cyan
7070
{
7171
return this->Plain(val);
7272
}
73+
bool operator==(const MessageChain& mc) const
74+
{
75+
auto it1 = mc.messages_.begin();
76+
auto it2 = messages_.begin();
77+
78+
for (; it1 != mc.messages_.end() && it2 != messages_.end(); ++it1, ++it2)
79+
{
80+
if (it1.value()["type"] != it2.value()["type"]) return false;
81+
if (it1.value()["type"] == "At")
82+
{
83+
if (it1.value()["target"] != it2.value()["target"]) return false;
84+
}
85+
if (it1.value()["type"] == "Face")
86+
{
87+
if (it1.value()["faceId"] != it2.value()["faceId"]) return false;
88+
}
89+
if (it1.value()["type"] == "Plain")
90+
{
91+
if (it1.value()["text"] != it2.value()["text"]) return false;
92+
}
93+
if (it1.value()["type"] == "Image")
94+
{
95+
if (it1.value()["imageId"] != it2.value()["imageId"]) return false;
96+
}
97+
if (it1.value()["type"] == "FlashImage")
98+
{
99+
if (it1.value()["imageId"] != it2.value()["imageId"]) return false;
100+
}
101+
if (it1.value()["type"] == "Poke")
102+
{
103+
if (it1.value()["name"] != it2.value()["name"]) return false;
104+
}
105+
}
106+
return true;
107+
}
73108
virtual ~MessageChain() = default;
74109
MessageChain& At(const QQ_t qq)
75110
{

0 commit comments

Comments
 (0)