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

View File

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