Skip to content
This repository has been archived by the owner on Aug 2, 2020. It is now read-only.

Commit

Permalink
new feature: qq face to emoji
Browse files Browse the repository at this point in the history
  • Loading branch information
lvjiagao@outlook.com committed Feb 17, 2018
1 parent e254848 commit 2580f06
Show file tree
Hide file tree
Showing 5 changed files with 118 additions and 0 deletions.
2 changes: 2 additions & 0 deletions coolq-http-api.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<ClCompile Include="src\event\entry.cpp" />
<ClCompile Include="src\event\events.cpp" />
<ClCompile Include="src\event\filter.cpp" />
<ClCompile Include="src\forward\forward_constant.cpp" />
<ClCompile Include="src\forward\pre_handler.cpp" />
<ClCompile Include="src\forward\traffic_center.cpp" />
<ClCompile Include="src\forward\unified_message.cpp" />
Expand Down Expand Up @@ -68,6 +69,7 @@
<ClInclude Include="src\emoji_data.h" />
<ClInclude Include="src\event\events.h" />
<ClInclude Include="src\event\filter.h" />
<ClInclude Include="src\forward\forward_constant.h" />
<ClInclude Include="src\forward\pre_handler.h" />
<ClInclude Include="src\forward\traffic_center.h" />
<ClInclude Include="src\forward\unified_message.h" />
Expand Down
6 changes: 6 additions & 0 deletions coolq-http-api.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,9 @@
<ClCompile Include="src\forward\pre_handler.cpp">
<Filter>src\forward</Filter>
</ClCompile>
<ClCompile Include="src\forward\forward_constant.cpp">
<Filter>src\forward</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\cqp\def.h">
Expand Down Expand Up @@ -542,6 +545,9 @@
<ClInclude Include="src\forward\pre_handler.h">
<Filter>src\forward</Filter>
</ClInclude>
<ClInclude Include="src\forward\forward_constant.h">
<Filter>src\forward</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="post_build.bat" />
Expand Down
96 changes: 96 additions & 0 deletions src/forward/forward_constant.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
#include "forward\forward_constant.h"

nlohmann::json qq_emoji_list = {
{ "0", u8"\U0001F62E" },
{ "1", u8"\U0001F623" },
{ "2", u8"\U0001F60D" },
{ "3", u8"\U0001F633" },
{ "4", u8"\U0001F60E" },
{ "5", u8"\U0001F62D" },
{ "6", u8"\U0000263A" },
{ "7", u8"\U0001F637" },
{ "8", u8"\U0001F634" },
{ "9", u8"\U0001F62D" },
{ "10", u8"\U0001F630" },
{ "11", u8"\U0001F621" },
{ "12", u8"\U0001F61D" },
{ "13", u8"\U0001F603" },
{ "14", u8"\U0001F642" },
{ "15", u8"\U0001F641" },
{ "16", u8"\U0001F913" },
{ "18", u8"\U0001F624" },
{ "19", u8"\U0001F628" },
{ "20", u8"\U0001F60F" },
{ "21", u8"\U0001F60A" },
{ "22", u8"\U0001F644" },
{ "23", u8"\U0001F615" },
{ "24", u8"\U0001F924" },
{ "25", u8"\U0001F62A" },
{ "26", u8"\U0001F628" },
{ "27", u8"\U0001F613" },
{ "28", u8"\U0001F62C" },
{ "29", u8"\U0001F911" },
{ "30", u8"\U0001F44A" },
{ "31", u8"\U0001F624" },
{ "32", u8"\U0001F914" },
{ "33", u8"\U0001F910" },
{ "34", u8"\U0001F635" },
{ "35", u8"\U0001F629" },
{ "36", u8"\U0001F47F" },
{ "37", u8"\U0001F480" },
{ "38", u8"\U0001F915" },
{ "39", u8"\U0001F44B" },
{ "50", u8"\U0001F641" },
{ "51", u8"\U0001F913" },
{ "53", u8"\U0001F624" },
{ "54", u8"\U0001F92E" },
{ "55", u8"\U0001F628" },
{ "56", u8"\U0001F613" },
{ "57", u8"\U0001F62C" },
{ "58", u8"\U0001F911" },
{ "73", u8"\U0001F60F" },
{ "74", u8"\U0001F60A" },
{ "75", u8"\U0001F644" },
{ "76", u8"\U0001F615" },
{ "77", u8"\U0001F924" },
{ "78", u8"\U0001F62A" },
{ "79", u8"\U0001F44A" },
{ "80", u8"\U0001F624" },
{ "81", u8"\U0001F914" },
{ "82", u8"\U0001F910" },
{ "83", u8"\U0001F635" },
{ "84", u8"\U0001F629" },
{ "85", u8"\U0001F47F" },
{ "86", u8"\U0001F480" },
{ "87", u8"\U0001F915" },
{ "88", u8"\U0001F44B" },
{ "96", u8"\U0001F630" },
{ "97", u8"\U0001F605" },
{ "98", u8"\U0001F925" },
{ "99", u8"\U0001F44F" },
{ "100", u8"\U0001F922" },
{ "101", u8"\U0001F62C" },
{ "102", u8"\U0001F610" },
{ "103", u8"\U0001F610" },
{ "104", u8"\U0001F629" },
{ "105", u8"\U0001F620" },
{ "106", u8"\U0001F61E" },
{ "107", u8"\U0001F61F" },
{ "108", u8"\U0001F60F" },
{ "109", u8"\U0001F619" },
{ "110", u8"\U0001F627" },
{ "111", u8"\U0001F920" },
{ "172", u8"\U0001F61C" },
{ "173", u8"\U0001F62D" },
{ "174", u8"\U0001F636" },
{ "175", u8"\U0001F609" },
{ "176", u8"\U0001F913" },
{ "177", u8"\U0001F635" },
{ "178", u8"\U0001F61C" },
{ "179", u8"\U0001F4A9" },
{ "180", u8"\U0001F633" },
{ "181", u8"\U0001F913" },
{ "182", u8"\U0001F602" },
{ "183", u8"\U0001F913" },
{ "212", u8"\U0001F633" }
};
5 changes: 5 additions & 0 deletions src/forward/forward_constant.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#pragma once

#include "app.h"

extern nlohmann::json qq_emoji_list;
9 changes: 9 additions & 0 deletions src/forward/unified_message.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "unified_message.h"
#include "forward\forward_constant.h"
#include "structs.h"
#include "api\api.h"

Expand Down Expand Up @@ -126,6 +127,14 @@ void UnifiedMessage::fillQQGroupMessage(const json& payload) {
// fill message content
std::string str = payload["message"];
message_content = str;

// replace QQ face
for (nlohmann::json::iterator it = qq_emoji_list.begin(); it != qq_emoji_list.end(); ++it) {
std::string key = it.key();
std::string value = it.value();
boost::replace_all(message_content, "[CQ:face,id=" + key + "]", value);
}

}

std::string UnifiedMessage::parseTextMessage() {
Expand Down

0 comments on commit 2580f06

Please sign in to comment.