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

Commit 60facea

Browse files
committed
Try git submodule
1 parent 994f15a commit 60facea

File tree

4 files changed

+41
-0
lines changed

4 files changed

+41
-0
lines changed

.gitmodules

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[submodule "extern/librcnb"]
2+
path = extern/librcnb
3+
url = [email protected]:rcnbapp/librcnb.git
4+
branch = 45dd2e77d3f06165c7f0511d9556b88b4497c0dc

CMakeLists.txt

+4
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ include(FixDebugLibraryLookup)
1414
include_directories(${VCPKG_INCLUDE_DIR})
1515
include_directories(src)
1616

17+
add_subdirectory(extern/librcnb)
18+
include_directories(extern/librcnb/include)
19+
1720
add_definitions(-DBOOST_CONFIG_SUPPRESS_OUTDATED_MESSAGE
1821
-D_WIN32_WINNT=0x0501
1922
-DWIN32_LEAN_AND_MEAN
@@ -44,6 +47,7 @@ target_link_libraries(${LIB_NAME} PRIVATE ${CURL_AND_DEPS_LIBRARIES})
4447
target_link_libraries(${LIB_NAME} PRIVATE ${SPDLOG_AND_DEPS_LIBRARIES})
4548
target_link_libraries(${LIB_NAME} PRIVATE sqlite3)
4649
target_link_libraries(${LIB_NAME} PRIVATE crypt32 bcrypt)
50+
target_link_libraries(${LIB_NAME} PRIVATE rcnb-static)
4751

4852
cotire(${LIB_NAME})
4953

extern/librcnb

Submodule librcnb added at 45dd2e7

src/cqhttp/core/action.cpp

+32
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
#include "cqhttp/utils/jsonex.h"
1111
#include "cqhttp/utils/string.h"
1212

13+
#include "rcnb/decode.h"
14+
#include "rcnb/encode.h"
15+
1316
using namespace std;
1417
namespace api = cq::api;
1518
namespace fs = std::filesystem;
@@ -549,5 +552,34 @@ namespace cqhttp {
549552
}
550553
}
551554

555+
#pragma endregion
556+
557+
#pragma region Easter Egg
558+
559+
HANDLER(rcnb) {
560+
const auto text = params.get_string("text");
561+
const auto action = params.get_string("action");
562+
if (action == "encode") {
563+
rcnb::encoder enc;
564+
stringstream ss;
565+
wstringstream wss;
566+
ss << text;
567+
enc.encode(ss, wss);
568+
result.data = ws2s(wss.str());
569+
} else if (action == "decode") {
570+
rcnb::decoder dec;
571+
stringstream ss;
572+
wstringstream wss;
573+
wss << s2ws(text);
574+
dec.decode(wss, ss);
575+
result.data = ss.str();
576+
} else {
577+
logging::warning("NB", "你的 action 不够 NB!");
578+
return;
579+
}
580+
logging::info_success("NB", "XXNB!");
581+
result.code = Codes::OK;
582+
}
583+
552584
#pragma endregion
553585
} // namespace cqhttp

0 commit comments

Comments
 (0)