Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Commit

Permalink
perf(cpp): fix CI problem in last commit
Browse files Browse the repository at this point in the history
#96


Former-commit-id: 67ab6216f21b6936999cfb74f83ddcade94bd68b [formerly d097136a2364e9da2e7fa59e9dcf02d399cac86f]
Former-commit-id: 532de938b7af007590aadded404b22c98bd802bd
  • Loading branch information
Nambers committed Oct 21, 2021
1 parent 992b7a0 commit f7647da
Showing 1 changed file with 42 additions and 42 deletions.
84 changes: 42 additions & 42 deletions cpp/include/miraiCP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1446,12 +1446,26 @@ LightApp风格1
return MessageSource::deserializeFromString(re);
}

template<class T>
MessageSource quoteAndSend1(T s, QQID groupid = -1, JNIEnv *env = ThreadManager::getEnv(__FILE__, __LINE__)) {
static_assert(std::is_base_of_v<SingleMessage, T>, "只支持SingleMessage的派生类");
return this->quoteAndSend0(s.toMiraiCode(), groupid, env);
}

MessageSource quoteAndSend1(std::string s, QQID groupid, JNIEnv *env) {
return this->quoteAndSend0(s, groupid, env);
}

MessageSource quoteAndSend1(MessageChain mc, QQID groupid, JNIEnv *env) {
return this->quoteAndSend0(mc.toMiraiCode(), groupid, env);
}

public:
size_t size(){
size_t size() {
return this->content.size();
}

const std::vector<Message>& vector(){
const std::vector<Message> &vector() {
return this->content;
}

Expand Down Expand Up @@ -1572,23 +1586,7 @@ LightApp风格1
template<class T>
MessageSource
quoteAndSendMessage(T s, QQID groupid = -1, JNIEnv *env = ThreadManager::getEnv(__FILE__, __LINE__)) {
static_assert(std::is_base_of_v<SingleMessage, T>, "只支持SingleMessage的派生类");
return this->quoteAndSend0(s.toMiraiCode(), groupid, env);
}

template<>
MessageSource quoteAndSendMessage(std::string s, QQID groupid, JNIEnv *env) {
return this->quoteAndSend0(s, groupid, env);
}

template<>
MessageSource quoteAndSendMessage(const char *s, QQID groupid, JNIEnv *env) {
return this->quoteAndSend0(s, groupid, env);
}

template<>
MessageSource quoteAndSendMessage(MessageChain mc, QQID groupid, JNIEnv *env) {
return this->quoteAndSend0(mc.toMiraiCode(), groupid, env);
return this->quoteAndSend1(s, groupid, env);
}

/// 从string构建MessageChain, 常用于Incoming message
Expand Down Expand Up @@ -1702,7 +1700,30 @@ LightApp风格1
private:
/// 发送纯文本信息
/// @throw IllegalArgumentException, TimeOutException, BotIsBeingMutedException
MessageSource sendMsg0(const std::string& msg, int retryTime, bool miraicode = false, JNIEnv * = ThreadManager::getEnv(__FILE__, __LINE__));
MessageSource sendMsg0(const std::string &msg, int retryTime, bool miraicode = false,
JNIEnv * = ThreadManager::getEnv(__FILE__, __LINE__));

template<class T>
MessageSource send1(T msg, int retryTime, JNIEnv *env) {
static_assert(std::is_base_of_v<SingleMessage, T>, "只支持SingleMessage的派生类");
return sendMsg0(msg.toMiraiCode(), retryTime, true, env);
}

MessageSource send1(MessageChain msg, int retryTime, JNIEnv *env) {
return sendMsg0(msg.toMiraiCode(), retryTime, true, env);
}

MessageSource send1(MiraiCode msg, int retryTime, JNIEnv *env) {
return sendMsg0(msg.toMiraiCode(), retryTime, true, env);
}

MessageSource send1(std::string msg, int retryTime, JNIEnv *env) {
return sendMsg0(msg, retryTime, false, env);
}

MessageSource send1(const char *msg, int retryTime, JNIEnv *env) {
return sendMsg0(std::string(msg), retryTime, false, env);
}

protected:
int _type = 0;
Expand Down Expand Up @@ -1840,28 +1861,7 @@ LightApp风格1
/// @return MessageSource
template<class T>
MessageSource sendMessage(T msg, int retryTime = 3, JNIEnv *env = ThreadManager::getEnv(__FILE__, __LINE__)) {
static_assert(std::is_base_of_v<SingleMessage, T>, "只支持SingleMessage的派生类");
return sendMsg0(msg.toMiraiCode(), retryTime, true, env);
}

template<>
MessageSource sendMessage(MessageChain msg, int retryTime, JNIEnv *env) {
return sendMsg0(msg.toMiraiCode(), retryTime, true, env);
}

template<>
MessageSource sendMessage(MiraiCode msg, int retryTime, JNIEnv *env) {
return sendMsg0(msg.toMiraiCode(), retryTime, true, env);
}

template<>
MessageSource sendMessage<std::string>(std::string msg, int retryTime, JNIEnv *env) {
return sendMsg0(msg, retryTime, false, env);
}

template<>
MessageSource sendMessage<const char *>(const char *msg, int retryTime, JNIEnv *env) {
return sendMsg0(std::string(msg), retryTime, false, env);
return this->send1(msg, retryTime, env);
}

/// @brief 发送纯文本信息
Expand Down

0 comments on commit f7647da

Please sign in to comment.