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

Commit abc1785

Browse files
authored
Merge pull request #13 from cyanray/dev/cyanray
删除复制构造函数与赋值构造函数; 新增SetHost和SetPort方法;
2 parents 07c7bea + 7a79deb commit abc1785

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

include/mirai_bot.hpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ using nlohmann::json;
3131
#ifdef CreateEvent
3232
#undef CreateEvent
3333
#endif
34+
#ifdef SetPort
35+
#undef SetPort
36+
#endif
3437

3538
namespace Cyan
3639
{
@@ -44,8 +47,22 @@ namespace Cyan
4447
* \param port port
4548
*/
4649
MiraiBot(const string& host, int port);
50+
MiraiBot(const MiraiBot&) = delete;
51+
MiraiBot& operator=(const MiraiBot&) = delete;
4752
~MiraiBot();
4853

54+
/**
55+
* \brief 设置 Host
56+
* \param host Host
57+
* \return MiraiBot 引用
58+
*/
59+
MiraiBot& SetHost(const string& host);
60+
/**
61+
* \brief 设置 Port
62+
* \param port Port
63+
* \return MiraiBot 引用
64+
*/
65+
MiraiBot& SetPort(int port);
4966
/**
5067
* \brief 获得 mirai-cpp 适配的 API 版本
5168
* \return 用数字表示的版本号 (10605)

src/mirai_bot.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,19 @@ namespace Cyan
3030
{
3131
Release();
3232
}
33+
34+
MiraiBot& MiraiBot::SetHost(const string& host)
35+
{
36+
this->host_ = host;
37+
return *this;
38+
}
39+
40+
MiraiBot& MiraiBot::SetPort(int port)
41+
{
42+
this->port_ = port;
43+
return *this;
44+
}
45+
3346
string MiraiBot::GetSessionKey() const
3447
{
3548
return sessionKey_;

0 commit comments

Comments
 (0)