Skip to content

Commit

Permalink
🐛 修复群组权限刷新 (#1700)
Browse files Browse the repository at this point in the history
  • Loading branch information
HibiKier authored Oct 16, 2024
1 parent 792bcaa commit 41b0dac
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 343 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ async def __handle_user(
uid2name = {u.user_id: u.user_name for u in db_user}
if member.id in driver.config.superusers:
await LevelUser.set_level(member.id, group_id, 9)
elif default_auth:
if role != "MEMBER" and not await LevelUser.is_group_flag(
elif role and default_auth:
if role.id != "MEMBER" and not await LevelUser.is_group_flag(
member.id, group_id
):
if role == "OWNER":
if role.id == "OWNER":
await LevelUser.set_level(member.id, group_id, default_auth + 1)
elif role == "ADMINISTRATOR":
elif role.id == "ADMINISTRATOR":
await LevelUser.set_level(member.id, group_id, default_auth)
if cnt := db_user_uid.count(member.id):
users = [u for u in db_user if u.user_id == member.id]
Expand Down
330 changes: 0 additions & 330 deletions zhenxun/builtin_plugins/platform/qq/group_handle.py

This file was deleted.

9 changes: 4 additions & 5 deletions zhenxun/builtin_plugins/platform/qq/group_handle/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,10 @@ async def _(bot: Bot, event: GroupIncreaseNoticeEvent | GroupMemberIncreaseEvent
group, _ = await GroupConsole.get_or_create(
group_id=group_id, channel_id__isnull=True
)
if group.group_flag == 0:
try:
await GroupManager.add_bot(bot, str(event.operator_id), group_id, group)
except ForceAddGroupError as e:
await PlatformUtils.send_superuser(bot, e.get_info())
try:
await GroupManager.add_bot(bot, str(event.operator_id), group_id, group)
except ForceAddGroupError as e:
await PlatformUtils.send_superuser(bot, e.get_info())
else:
await GroupManager.add_user(bot, user_id, group_id)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ async def __refresh_level(cls, bot: Bot, group_id: str):
).values_list("user_id", flat=True)
# 即刻刷新权限
for user_info in member_list:
user_id = user_info["user_id"]
user_id = str(user_info["user_id"])
role = user_info["role"]
if user_id in bot.config.superusers:
await LevelUser.set_level(user_id, user_info["group_id"], 9)
await LevelUser.set_level(user_id, group_id, 9)
logger.debug(
"添加超级用户权限: 9",
"入群检测",
Expand All @@ -100,8 +100,8 @@ async def __refresh_level(cls, bot: Bot, group_id: str):
):
await LevelUser.set_level(
user_id,
user_info["group_id"],
admin_default_auth,
group_id,
admin_default_auth if role == "admin" else admin_default_auth + 1,
)
logger.debug(
f"添加默认群管理员权限: {admin_default_auth}",
Expand Down

0 comments on commit 41b0dac

Please sign in to comment.