mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2026-10-09 22:00:01 +08:00
feat(admin): 增加封禁用户理由并优化相关逻辑 (#1992)
检查bot是否运行正常 / bot check (push) Has been cancelled
CodeQL Code Security Analysis / Analyze (${{ matrix.language }}) (none, javascript-typescript) (push) Has been cancelled
CodeQL Code Security Analysis / Analyze (${{ matrix.language }}) (none, python) (push) Has been cancelled
Sequential Lint and Type Check / ruff-call (push) Has been cancelled
Release Drafter / Update Release Draft (push) Has been cancelled
Force Sync to Aliyun / sync (push) Has been cancelled
Update Version / update-version (push) Has been cancelled
Sequential Lint and Type Check / pyright-call (push) Has been cancelled
检查bot是否运行正常 / bot check (push) Has been cancelled
CodeQL Code Security Analysis / Analyze (${{ matrix.language }}) (none, javascript-typescript) (push) Has been cancelled
CodeQL Code Security Analysis / Analyze (${{ matrix.language }}) (none, python) (push) Has been cancelled
Sequential Lint and Type Check / ruff-call (push) Has been cancelled
Release Drafter / Update Release Draft (push) Has been cancelled
Force Sync to Aliyun / sync (push) Has been cancelled
Update Version / update-version (push) Has been cancelled
Sequential Lint and Type Check / pyright-call (push) Has been cancelled
* feat(admin): 增加封禁用户理由并优化相关逻辑
- 在 ban 命令中添加了 -r 或 --reason 选项,用于指定封禁理由
- 优化了 ban 命令的参数解析和处理逻辑
- 更新了数据库模型,增加了 ban_reason 字段用于存储封禁理由
- 修复了部分逻辑错误,如永久封禁的处理方式
* 🚨 auto fix by pre-commit hooks
* refactor(ban): 优化 ban 命令和相关功能
- 修复 ban 命令中的 reason 参数可选标记
- 完善恶意触发检测和用户昵称违规的禁言信息
- 统一禁言操作的参数顺序,提高代码可读性
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
co-authored by
pre-commit-ci[bot]
parent
c571bfb133
commit
59d72c3b3d
@@ -21,6 +21,8 @@ class BanConsole(Model):
|
||||
"""使用ban命令的用户等级"""
|
||||
ban_time = fields.BigIntField()
|
||||
"""ban开始的时间"""
|
||||
ban_reason = fields.TextField(null=True, default=None)
|
||||
"""ban的理由"""
|
||||
duration = fields.BigIntField()
|
||||
"""ban时长"""
|
||||
operator = fields.CharField(255)
|
||||
@@ -107,7 +109,9 @@ class BanConsole(Model):
|
||||
if user.duration == -1:
|
||||
return -1
|
||||
_time = time.time() - (user.ban_time + user.duration)
|
||||
return 0 if _time > 0 else int(time.time() - user.ban_time - user.duration)
|
||||
if _time < 0:
|
||||
return int(time.time() - user.ban_time - user.duration)
|
||||
await user.delete()
|
||||
return 0
|
||||
|
||||
@classmethod
|
||||
@@ -133,6 +137,7 @@ class BanConsole(Model):
|
||||
user_id: str | None,
|
||||
group_id: str | None,
|
||||
ban_level: int,
|
||||
reason: str | None,
|
||||
duration: int,
|
||||
operator: str | None = None,
|
||||
):
|
||||
@@ -157,6 +162,7 @@ class BanConsole(Model):
|
||||
group_id=group_id,
|
||||
ban_level=ban_level,
|
||||
ban_time=int(time.time()),
|
||||
ban_reason=reason,
|
||||
duration=duration,
|
||||
operator=operator or 0,
|
||||
)
|
||||
@@ -206,4 +212,5 @@ class BanConsole(Model):
|
||||
return [
|
||||
"CREATE INDEX idx_ban_console_user_id ON ban_console(user_id);",
|
||||
"CREATE INDEX idx_ban_console_group_id ON ban_console(group_id);",
|
||||
"ALTER TABLE ban_console ADD COLUMN ban_reason TEXT DEFAULT NULL;",
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user