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

Commit bba93ec

Browse files
committed
支持 SetGroupAdmin 设置群管理员.
1 parent 04d7447 commit bba93ec

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

include/mirai/mirai_bot.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,14 @@ namespace Cyan
412412
*/
413413
Friend_t GetSessionInfo();
414414

415+
/**
416+
* @brief 设置群成员管理员
417+
* @param group 群号码
418+
* @param member 成员号码
419+
* @param assign 赋值(true: 设置为管理员; false: 取消管理员;)
420+
*/
421+
void SetGroupAdmin(const GID_t& group, const QQ_t& member, bool assign);
422+
415423
/**
416424
* \brief 监听事件
417425
* \tparam T 事件类型

src/mirai_bot.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -976,7 +976,19 @@ namespace Cyan
976976
Friend_t result;
977977
result.Set(re_json["data"]["qq"]);
978978
return result;
979+
}
979980

981+
void MiraiBot::SetGroupAdmin(const GID_t& group, const QQ_t& member, bool assign)
982+
{
983+
json data =
984+
{
985+
{ "sessionKey", pmem->sessionKey },
986+
{ "target", int64_t(group) },
987+
{ "memberId", int64_t(member) },
988+
{ "assign", assign }
989+
};
990+
auto res = pmem->httpClient->Post("/memberAdmin", data.dump(), CONTENT_TYPE.c_str());
991+
ParseOrThrowException(res);
980992
}
981993

982994
} // namespace Cyan

0 commit comments

Comments
 (0)