Skip to content

Commit

Permalink
🎨 修复bug,移除plugins文件夹
Browse files Browse the repository at this point in the history
  • Loading branch information
HibiKier committed Aug 29, 2024
1 parent e10fee7 commit 625f17a
Show file tree
Hide file tree
Showing 146 changed files with 578 additions and 18,318 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ fixture-parentheses = false
mark-parentheses = false

[tool.pyright]
pythonVersion = "3.9"
pythonVersion = "3.10"
pythonPlatform = "All"
defineConstant = { PYDANTIC_V2 = true }
executionEnvironments = [
Expand Down
53 changes: 26 additions & 27 deletions zhenxun/builtin_plugins/admin/group_member_update/_data_source.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
import time
from datetime import datetime, timedelta, timezone
from datetime import datetime, timezone, timedelta

from nonebot.adapters import Bot

# from nonebot.adapters.discord import Bot as DiscordBot
# from nonebot.adapters.dodo import Bot as DodoBot
from nonebot.adapters.dodo.models import MemberInfo

# from nonebot.adapters.kaiheila import Bot as KaiheilaBot
from nonebot.adapters.onebot.v11 import Bot as v11Bot
from nonebot.adapters.onebot.v12 import Bot as v12Bot

from zhenxun.services.log import logger
from zhenxun.configs.config import Config
from zhenxun.models.group_member_info import GroupInfoUser
from zhenxun.models.level_user import LevelUser
from zhenxun.services.log import logger
from zhenxun.models.group_member_info import GroupInfoUser

# from nonebot.adapters.discord import Bot as DiscordBot
# from nonebot.adapters.dodo import Bot as DodoBot


class MemberUpdateManage:
Expand Down Expand Up @@ -98,29 +96,27 @@ async def v11(cls, bot: v11Bot, group_id: str):
user_id = str(user_info["user_id"])
nickname = user_info["card"] or user_info["nickname"]
role = user_info["role"]
if default_auth:
if role in ["owner", "admin"] and not await LevelUser.is_group_flag(
user_id, group_id
):
if role == "owner":
await LevelUser.set_level(user_id, group_id, default_auth + 1)
else:
await LevelUser.set_level(user_id, group_id, default_auth)
if (
default_auth
and role in ["owner", "admin"]
and not await LevelUser.is_group_flag(user_id, group_id)
):
if role == "owner":
await LevelUser.set_level(user_id, group_id, default_auth + 1)
else:
await LevelUser.set_level(user_id, group_id, default_auth)
if user_id in bot.config.superusers:
await LevelUser.set_level(user_id, group_id, 9)
join_time = datetime.strptime(
time.strftime(
"%Y-%m-%d %H:%M:%S", time.localtime(user_info["join_time"])
),
"%Y-%m-%d %H:%M:%S",
).replace(tzinfo=timezone(timedelta(hours=8)))
join_time = datetime.fromtimestamp(
user_info["join_time"], timezone(timedelta(hours=8))
)
if cnt := db_user_uid.count(user_id):
users = [u for u in db_user if u.user_id == user_id]
user = users[0]
if cnt > 1:
for u in users[1:]:
delete_list.append(u.id)
if nickname != uid2name.get(user_id):
user = users[0]
user.user_name = nickname
update_list.append(user)
else:
Expand Down Expand Up @@ -156,7 +152,7 @@ async def v11(cls, bot: v11Bot, group_id: str):
user_id__in=delete_member_list, group_id=group_id
).delete()
logger.info(
f"删除已退群用户", "更新群组成员信息", group_id=group_id, platform="qq"
"删除已退群用户", "更新群组成员信息", group_id=group_id, platform="qq"
)

@classmethod
Expand All @@ -165,7 +161,8 @@ async def v12(cls, bot: v12Bot, group_id: str):
pass
# exist_member_list = []
# default_auth = Config.get_config("admin_bot_manage", "ADMIN_DEFAULT_AUTH")
# group_member_list: list[GetGroupMemberInfoResp] = await bot.get_group_member_list(
# group_member_list: list[GetGroupMemberInfoResp] =
# await bot.get_group_member_list(
# group_id=group_id
# )
# for user_info in group_member_list:
Expand All @@ -180,7 +177,8 @@ async def v12(cls, bot: v12Bot, group_id: str):
# if str(user_id) in bot.config.superusers:
# await LevelUser.set_level(str(user_id), group_id, 9)
# join_time = datetime.strptime(
# time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(user_info["join_time"])),
# time.strftime("%Y-%m-%d %H:%M:%S",
# time.localtime(user_info["join_time"])),
# "%Y-%m-%d %H:%M:%S",
# )
# await GroupInfoUser.update_or_create(
Expand All @@ -194,7 +192,8 @@ async def v12(cls, bot: v12Bot, group_id: str):
# },
# )
# exist_member_list.append(str(user_id))
# logger.debug("更新成功", "更新群组成员信息", session=user_id, group_id=group_id)
# logger.debug("更新成功", "更新群组成员信息",
# session=user_id, group_id=group_id)
# if delete_member_list := list(
# set(exist_member_list).difference(
# set(await GroupInfoUser.get_group_member_id_list(group_id))
Expand Down
12 changes: 3 additions & 9 deletions zhenxun/builtin_plugins/auto_update/__init__.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
from nonebot.rule import to_me
from nonebot.adapters import Bot
from nonebot.permission import SUPERUSER
from nonebot.plugin import PluginMetadata
from nonebot.rule import to_me
from nonebot_plugin_alconna import Alconna, Args, Match, on_alconna
from nonebot_plugin_session import EventSession
from nonebot_plugin_alconna import Args, Match, Alconna, on_alconna

from zhenxun.configs.utils import PluginExtraData, RegisterConfig
from zhenxun.services.log import logger
from zhenxun.utils.enum import PluginType
from zhenxun.utils.message import MessageUtils
from zhenxun.configs.utils import RegisterConfig, PluginExtraData

from ._data_source import UpdateManage

Expand All @@ -32,12 +32,6 @@
help="是否检测更新版本",
default_value=True,
),
RegisterConfig(
key="UPDATE_REMIND",
value=True,
help="是否检测更新版本",
default_value=True,
),
],
).dict(),
)
Expand Down
40 changes: 21 additions & 19 deletions zhenxun/builtin_plugins/init/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import nonebot
from nonebot.adapters import Bot

from zhenxun.models.group_console import GroupConsole
from zhenxun.services.log import logger
from zhenxun.utils.platform import PlatformUtils
from zhenxun.models.group_console import GroupConsole

nonebot.load_plugins(str(Path(__file__).parent.resolve()))

Expand All @@ -20,22 +20,24 @@ async def _(bot: Bot):
参数:
bot: Bot
"""
if PlatformUtils.get_platform(bot) == "qq":
logger.debug(f"更新Bot: {bot.self_id} 的群认证...")
group_list, _ = await PlatformUtils.get_group_list(bot)
db_group_list = await GroupConsole.all().values_list("group_id", flat=True)
create_list = []
update_id = []
for group in group_list:
if group.group_id not in db_group_list:
group.group_flag = 1
create_list.append(group)
else:
update_id.append(group.group_id)
if create_list:
await GroupConsole.bulk_create(create_list, 10)
if PlatformUtils.get_platform(bot) != "qq":
return
logger.debug(f"更新Bot: {bot.self_id} 的群认证...")
group_list, _ = await PlatformUtils.get_group_list(bot)
db_group_list = await GroupConsole.all().values_list("group_id", flat=True)
create_list = []
update_id = []
for group in group_list:
if group.group_id not in db_group_list:
group.group_flag = 1
create_list.append(group)
else:
await GroupConsole.filter(group_id__in=update_id).update(group_flag=1)
logger.debug(
f"更新Bot: {bot.self_id} 的群认证完成,共创建 {len(create_list)} 条数据,共修改 {len(update_id)} 条数据..."
)
update_id.append(group.group_id)
if create_list:
await GroupConsole.bulk_create(create_list, 10)
else:
await GroupConsole.filter(group_id__in=update_id).update(group_flag=1)
logger.debug(
f"更新Bot: {bot.self_id} 的群认证完成,共创建 {len(create_list)} 条数据,"
"共修改 {len(update_id)} 条数据..."
)
Loading

0 comments on commit 625f17a

Please sign in to comment.