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

Commit e017325

Browse files
committed
更新: 重构 Command 相关质量;
修复: 编译错误.
1 parent 26aaa1e commit e017325

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

include/mirai/mirai_bot.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -337,9 +337,9 @@ namespace Cyan
337337
* @param helpMessage 指令帮助,执行出错时显示
338338
* @return *this
339339
*/
340-
MiraiBot& RegisterCommand(
340+
void RegisterCommand(
341341
const string& commandName,
342-
const vector<string> alias,
342+
const vector<string>& alias,
343343
const string& description,
344344
const string& helpMessage = "");
345345

@@ -349,7 +349,7 @@ namespace Cyan
349349
* @param args 参数
350350
* @return *this
351351
*/
352-
MiraiBot& SendCommand(const string& commandName, const vector<string> args);
352+
void SendCommand(const string& commandName, const vector<string>& args);
353353

354354
/**
355355
* @brief 获得 Managers

src/mirai_bot.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ using std::stringstream;
1616

1717
namespace
1818
{
19-
const string CONTENT_TYPE = "application/json;charset=UTF-8"s;
19+
const string CONTENT_TYPE = "application/json;charset=UTF-8";
2020

2121
// 因为 httplib 使用 string 来保存文件内容,这里返回值也跟着适配
2222
string ReadFile(const string& filename)
@@ -659,9 +659,9 @@ namespace Cyan
659659
return result;
660660
}
661661

662-
MiraiBot& MiraiBot::RegisterCommand(
662+
void MiraiBot::RegisterCommand(
663663
const string& commandName,
664-
const vector<string> alias,
664+
const vector<string>& alias,
665665
const string& description,
666666
const string& helpMessage)
667667
{
@@ -675,10 +675,9 @@ namespace Cyan
675675
};
676676
auto res = http_client_.Post("/command/register", data.dump(), CONTENT_TYPE.c_str());
677677
ParseOrThrowException(res);
678-
return *this; // TODO: 修改返回值类型
679678
}
680679

681-
MiraiBot& MiraiBot::SendCommand(const string& commandName, const vector<string> args)
680+
void MiraiBot::SendCommand(const string& commandName, const vector<string>& args)
682681
{
683682
json data =
684683
{
@@ -688,7 +687,6 @@ namespace Cyan
688687
};
689688
auto res = http_client_.Post("/command/send", data.dump(), CONTENT_TYPE.c_str());
690689
ParseOrThrowException(res);
691-
return *this; // TODO: 修改返回值类型
692690
}
693691

694692
vector<QQ_t> MiraiBot::GetManagers()

0 commit comments

Comments
 (0)