mirror of
https://github.com/PaiGramTeam/PaiGram.git
synced 2024-11-25 01:29:42 +00:00
✨ get_chat support show can_manage_topics
This commit is contained in:
parent
8331698a7c
commit
41b9bac0f2
@ -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)
|
||||||
|
22
utils/bot.py
22
utils/bot.py
@ -12,17 +12,17 @@ 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:
|
||||||
qname = f"bot:chat:{chat_id}"
|
return await bot.app.bot.get_chat(chat_id)
|
||||||
data = await redis_db.client.get(qname)
|
qname = f"bot:chat:{chat_id}"
|
||||||
if data:
|
data = await redis_db.client.get(qname)
|
||||||
json_data = json.loads(data)
|
if data:
|
||||||
return Chat.de_json(json_data, bot.app.bot)
|
json_data = json.loads(data)
|
||||||
chat_info = await bot.app.bot.get_chat(chat_id)
|
return Chat.de_json(json_data, bot.app.bot)
|
||||||
await redis_db.client.set(qname, chat_info.to_json())
|
chat_info = await bot.app.bot.get_chat(chat_id)
|
||||||
await redis_db.client.expire(qname, ttl)
|
await redis_db.client.set(qname, chat_info.to_json())
|
||||||
return chat_info
|
await redis_db.client.expire(qname, ttl)
|
||||||
return await bot.app.bot.get_chat(chat_id)
|
return chat_info
|
||||||
|
|
||||||
|
|
||||||
def get_all_args(context: CallbackContext) -> List[str]:
|
def get_all_args(context: CallbackContext) -> List[str]:
|
||||||
|
Loading…
Reference in New Issue
Block a user