From 7a79deb560bd29138df91bd6ccd028e54d30b08c Mon Sep 17 00:00:00 2001 From: cyanray Date: Thu, 21 May 2020 10:20:36 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=A4=8D=E5=88=B6=E6=9E=84?= =?UTF-8?q?=E9=80=A0=E5=87=BD=E6=95=B0=E4=B8=8E=E8=B5=8B=E5=80=BC=E6=9E=84?= =?UTF-8?q?=E9=80=A0=E5=87=BD=E6=95=B0;=20=E6=96=B0=E5=A2=9ESetHost?= =?UTF-8?q?=E5=92=8CSetPort=E6=96=B9=E6=B3=95;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/mirai_bot.hpp | 17 +++++++++++++++++ src/mirai_bot.cpp | 13 +++++++++++++ 2 files changed, 30 insertions(+) diff --git a/include/mirai_bot.hpp b/include/mirai_bot.hpp index 434a651..ace26bd 100644 --- a/include/mirai_bot.hpp +++ b/include/mirai_bot.hpp @@ -31,6 +31,9 @@ using nlohmann::json; #ifdef CreateEvent #undef CreateEvent #endif +#ifdef SetPort +#undef SetPort +#endif namespace Cyan { @@ -44,8 +47,22 @@ namespace Cyan * \param port port */ MiraiBot(const string& host, int port); + MiraiBot(const MiraiBot&) = delete; + MiraiBot& operator=(const MiraiBot&) = delete; ~MiraiBot(); + /** + * \brief 设置 Host + * \param host Host + * \return MiraiBot 引用 + */ + MiraiBot& SetHost(const string& host); + /** + * \brief 设置 Port + * \param port Port + * \return MiraiBot 引用 + */ + MiraiBot& SetPort(int port); /** * \brief 获得 mirai-cpp 适配的 API 版本 * \return 用数字表示的版本号 (10605) diff --git a/src/mirai_bot.cpp b/src/mirai_bot.cpp index 94cccff..9144af7 100644 --- a/src/mirai_bot.cpp +++ b/src/mirai_bot.cpp @@ -30,6 +30,19 @@ namespace Cyan { Release(); } + + MiraiBot& MiraiBot::SetHost(const string& host) + { + this->host_ = host; + return *this; + } + + MiraiBot& MiraiBot::SetPort(int port) + { + this->port_ = port; + return *this; + } + string MiraiBot::GetSessionKey() const { return sessionKey_;