get_chat support show can_manage_topics

This commit is contained in:
xtaodada 2022-11-29 21:48:10 +08:00
parent 8331698a7c
commit 41b9bac0f2
Signed by: xtaodada
GPG Key ID: 4CBB3F4FA8C85659
2 changed files with 14 additions and 13 deletions

View File

@ -12,7 +12,7 @@ from core.sign import SignServices
from core.user import UserService
from core.user.error import UserNotFoundError
from modules.gacha_log.log import GachaLog
from utils.bot import get_all_args
from utils.bot import get_all_args, get_chat as get_chat_with_cache
from utils.decorators.admins import bot_admins_rights_check
from utils.helpers import get_genshin_client
from utils.log import logger
@ -48,6 +48,7 @@ class GetChat(Plugin):
text += "D" if admin.can_delete_messages else "_"
text += "R" if admin.can_restrict_members else "_"
text += "I" if admin.can_invite_users else "_"
text += "T" if admin.can_manage_topics else "_"
text += "P" if admin.can_pin_messages else "_"
text += "V" if admin.can_manage_video_chats else "_"
text += "N" if admin.can_promote_members else "_"
@ -120,7 +121,7 @@ class GetChat(Plugin):
await message.reply_text("参数错误,请指定群 id ")
return
try:
chat = await message.get_bot().get_chat(args[0])
chat = await get_chat_with_cache(args[0])
if chat_id < 0:
admins = await chat.get_administrators() if chat_id < 0 else None
text = await self.parse_group_chat(chat, admins)

View File

@ -12,17 +12,17 @@ redis_db = cast(RedisDB, redis_db)
async def get_chat(chat_id: Union[str, int], ttl: int = 86400) -> Chat:
if redis_db:
qname = f"bot:chat:{chat_id}"
data = await redis_db.client.get(qname)
if data:
json_data = json.loads(data)
return Chat.de_json(json_data, bot.app.bot)
chat_info = await bot.app.bot.get_chat(chat_id)
await redis_db.client.set(qname, chat_info.to_json())
await redis_db.client.expire(qname, ttl)
return chat_info
return await bot.app.bot.get_chat(chat_id)
if not redis_db:
return await bot.app.bot.get_chat(chat_id)
qname = f"bot:chat:{chat_id}"
data = await redis_db.client.get(qname)
if data:
json_data = json.loads(data)
return Chat.de_json(json_data, bot.app.bot)
chat_info = await bot.app.bot.get_chat(chat_id)
await redis_db.client.set(qname, chat_info.to_json())
await redis_db.client.expire(qname, ttl)
return chat_info
def get_all_args(context: CallbackContext) -> List[str]: