mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2026-10-08 05:10:01 +08:00
✨ 引用消息同意好友/群组请求 (#1902)
* ✨ 提供event日志表, 新增引用消息同意好友/群组请求 * ⚡ 移除城市列表更新 * ✨ 新增申请入群功能 * 💬 文本修改
This commit is contained in:
@@ -3,8 +3,10 @@ from typing_extensions import Self
|
||||
from nonebot.adapters import Bot
|
||||
from tortoise import fields
|
||||
|
||||
from zhenxun.configs.config import BotConfig
|
||||
from zhenxun.models.group_console import GroupConsole
|
||||
from zhenxun.services.db_context import Model
|
||||
from zhenxun.utils.common_utils import SqlUtils
|
||||
from zhenxun.utils.enum import RequestHandleType, RequestType
|
||||
from zhenxun.utils.exception import NotFoundError
|
||||
|
||||
@@ -34,6 +36,8 @@ class FgRequest(Model):
|
||||
RequestHandleType, null=True, description="处理类型"
|
||||
)
|
||||
"""处理类型"""
|
||||
message_ids = fields.CharField(max_length=255, null=True, description="消息id列表")
|
||||
"""消息id列表"""
|
||||
|
||||
class Meta: # pyright: ignore [reportIncompatibleVariableOverride]
|
||||
table = "fg_request"
|
||||
@@ -123,9 +127,24 @@ class FgRequest(Model):
|
||||
await GroupConsole.update_or_create(
|
||||
group_id=req.group_id, defaults={"group_flag": 1}
|
||||
)
|
||||
await bot.set_group_add_request(
|
||||
flag=req.flag,
|
||||
sub_type="invite",
|
||||
approve=handle_type == RequestHandleType.APPROVE,
|
||||
)
|
||||
if req.flag == "0":
|
||||
# 用户手动申请入群,创建群认证后提醒用户拉群
|
||||
await bot.send_private_msg(
|
||||
user_id=req.user_id,
|
||||
message=f"已同意你对{BotConfig.self_nickname}的申请群组:"
|
||||
f"{req.group_id},可以直接手动拉入群组,{BotConfig.self_nickname}会自动同意。",
|
||||
)
|
||||
else:
|
||||
# 正常同意群组请求
|
||||
await bot.set_group_add_request(
|
||||
flag=req.flag,
|
||||
sub_type="invite",
|
||||
approve=handle_type == RequestHandleType.APPROVE,
|
||||
)
|
||||
return req
|
||||
|
||||
@classmethod
|
||||
async def _run_script(cls):
|
||||
return [
|
||||
SqlUtils.add_column("fg_request", "message_ids", "character varying(255)")
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user