Skip to content

Commit

Permalink
fix GroupMemberInfo
Browse files Browse the repository at this point in the history
允许邀请者视为拥有群权限
优化群成员是否获取成功的检查
  • Loading branch information
mystringEmpty committed Aug 10, 2020
1 parent fb2f401 commit 48364a1
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 10 deletions.
17 changes: 11 additions & 6 deletions Dice/BlackListManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,22 +46,27 @@ void checkGroupWithBlackQQ(const DDBlackMark& mark, long long llQQ)
string strNotice;
for (auto& [id, grp] : ChatList)
{
if (grp.isset("已退") || grp.isset("忽略") || !grp.isGroup)continue;
if (getGroupMemberInfo(id, llQQ).QQID == llQQ)
if (grp.isset("已退") || grp.isset("未进") || grp.isset("忽略") || grp.isset("协议无效") || !grp.isGroup)continue;
if (GroupMemberInfo member = getGroupMemberInfo(id, llQQ); member.QQID == llQQ)
{
strNotice = printGroup(id);
if (grp.isset("免黑"))
if (grp.isset("协议无效"))
{
strNotice += "群协议无效";
}
else if (grp.isset("免黑")) {
if (mark.isSource(console.DiceMaid) && !mark.isType("local"))sendGroupMsg(id, mark.warning());
strNotice += "群免黑";
}
else if (getGroupMemberInfo(id, llQQ).permissions < getGroupMemberInfo(id, getLoginQQ()).permissions)
{
else if (GroupMemberInfo self = getGroupMemberInfo(id, console.DiceMaid); !self.permissions) {
continue;
}
else if (member.permissions < self.permissions) {
if (mark.isSource(console.DiceMaid && !mark.isType("local")))AddMsgToQueue(
mark.warning(), id, msgtype::Group);
strNotice += "对方群权限较低";
}
else if (getGroupMemberInfo(id, llQQ).permissions > getGroupMemberInfo(id, getLoginQQ()).permissions)
else if (member.permissions > self.permissions)
{
sendGroupMsg(id, mark.warning());
grp.leave("发现新增黑名单管理员" + printQQ(llQQ) + "\n" + GlobalMsg["strSelfName"] + "将预防性退群");
Expand Down
8 changes: 7 additions & 1 deletion Dice/Dice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,13 @@ bool eve_GroupAdd(Chat& grp)
if (ChatList.size() == 1 && !console.isMasterMode)sendGroupMsg(grp.ID, msgInit);
}
GroupInfo ginf(grp.ID);
grp.Name = ginf.strGroupName;
//群信息是否获取成功
if (ginf.llGroup) {
grp.Name = ginf.strGroupName;
}
else {
ginf.llGroup = grp.ID;
}
if (grp.boolConf.empty() && ginf.nGroupSize > 499) {
grp.set("协议无效");
}
Expand Down
2 changes: 1 addition & 1 deletion Dice/DiceEvent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,7 @@ int FromMsg::DiceReply()
strVar["nick"] = getName(fromQQ, fromGroup);
getPCName(*this);
strVar["at"] = intT ? "[CQ:at,qq=" + to_string(fromQQ) + "]" : strVar["nick"];
isAuth = trusted > 3 || intT != GroupT || getGroupMemberInfo(fromGroup, fromQQ).permissions > 1 || pGrp->inviter == fromQQ;
isAuth = trusted > 3 || intT != GroupT || getGroupMemberInfo(fromGroup, fromQQ).permissions != 1 || pGrp->inviter == fromQQ;
//指令匹配
if (strLowerMessage.substr(intMsgCnt, 9) == "authorize")
{
Expand Down
4 changes: 4 additions & 0 deletions Dice/ManagerSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@ Chat& Chat::id(long long grp) {
return *this;
}

bool Chat::is_except()const {
return boolConf.count("免黑") || boolConf.count("协议无效");
}

int groupset(long long id, string st)
{
if (!ChatList.count(id))return -1;
Expand Down
5 changes: 3 additions & 2 deletions Dice/ManagerSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,7 @@ class Chat
else CQ::sendDiscussMsg(ID, msg);
Sleep(500);
}
if (isGroup)CQ::setGroupLeave(ID);
else CQ::setDiscussLeave(ID);
isGroup ? CQ::setGroupLeave(ID) : CQ::setDiscussLeave(ID);
set("已退");
}

Expand All @@ -261,6 +260,8 @@ class Chat
return boolConf.count(key) || intConf.count(key) || strConf.count(key);
}

bool is_except()const;

void setConf(const string& key, int val)
{
intConf[key] = val;
Expand Down

0 comments on commit 48364a1

Please sign in to comment.