🐛 修复一些BUG

This commit is contained in:
Wuyi无疑 2023-07-22 03:20:02 +08:00
parent 0dbb35ea10
commit 242b0ec2b9
2 changed files with 21 additions and 2 deletions

View File

@ -47,7 +47,7 @@ class GsClient:
bot_id='Nonebot222', bot_id='Nonebot222',
user_type='direct', user_type='direct',
user_pm=1, user_pm=1,
group_id=None, group_id='12345678888',
user_id='511', user_id='511',
content=content, content=content,
) )

View File

@ -2,8 +2,8 @@ import re
import asyncio import asyncio
from typing import Dict, List, Literal, Optional from typing import Dict, List, Literal, Optional
from sqlmodel import SQLModel
from sqlalchemy.sql import text from sqlalchemy.sql import text
from sqlmodel import SQLModel, col
from sqlalchemy.future import select from sqlalchemy.future import select
from sqlalchemy import delete, update from sqlalchemy import delete, update
from sqlalchemy.orm import sessionmaker from sqlalchemy.orm import sessionmaker
@ -160,6 +160,25 @@ class SQLA:
uid_list.extend(item.uid.split("_") if item.uid else []) uid_list.extend(item.uid.split("_") if item.uid else [])
return uid_list return uid_list
async def get_bind_group_list(self, user_id: str) -> List[str]:
data = await self.select_bind_data(user_id)
return data.group_id.split("_") if data and data.group_id else []
async def get_bind_group(self, user_id: str) -> Optional[str]:
data = await self.get_bind_group_list(user_id)
return data[0] if data else None
async def get_group_all_uid(self, group_id: str):
async with self.async_session() as session:
async with session.begin():
result = await session.scalars(
select(GsBind).where(
col(GsBind.group_id).contains(group_id)
)
)
data = result.all()
return data[0] if data else None
async def get_bind_uid_list(self, user_id: str) -> List[str]: async def get_bind_uid_list(self, user_id: str) -> List[str]:
data = await self.select_bind_data(user_id) data = await self.select_bind_data(user_id)
return data.uid.split("_") if data and data.uid else [] return data.uid.split("_") if data and data.uid else []