| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- """
- MIT License
- Copyright (c) 2024 TheHamkerCat
- Permission is hereby granted, free of charge, to any person obtaining a copy
- of this software and associated documentation files (the "Software"), to deal
- in the Software without restriction, including without limitation the rights
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- copies of the Software, and to permit persons to whom the Software is
- furnished to do so, subject to the following conditions:
- The above copyright notice and this permission notice shall be included in all
- copies or substantial portions of the Software.
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- SOFTWARE.
- """
- import os
- from pyrogram import filters
- from wbb import app
- from wbb.core.decorators.permissions import adminsOnly
- __MODULE__ = "群资料管理"
- __HELP__ = """
- /set_chat_title - 修改群组或频道名称。
- /set_chat_photo - 回复图片,将其设为群头像。
- /set_user_title - 回复管理员消息,修改其管理员头衔。
- """
- @app.on_message(filters.command("set_chat_title") & ~filters.private)
- @adminsOnly("can_change_info")
- async def set_chat_title(_, message):
- if len(message.command) < 2:
- return await message.reply_text("**用法:**\n/set_chat_title 新群名称")
- old_title = message.chat.title
- new_title = message.text.split(None, 1)[1]
- await message.chat.set_title(new_title)
- await message.reply_text(
- f"群名称已从“{old_title}”修改为“{new_title}”。"
- )
- @app.on_message(filters.command("set_user_title") & ~filters.private)
- @adminsOnly("can_change_info")
- async def set_user_title(_, message):
- if not message.reply_to_message:
- return await message.reply_text(
- "请回复该管理员的消息。"
- )
- if not message.reply_to_message.from_user:
- return await message.reply_text(
- "无法修改匿名身份或未知实体的管理员头衔。"
- )
- chat_id = message.chat.id
- from_user = message.reply_to_message.from_user
- if len(message.command) < 2:
- return await message.reply_text(
- "**用法:**\n/set_user_title 新管理员头衔"
- )
- title = message.text.split(None, 1)[1]
- await app.set_administrator_title(chat_id, from_user.id, title)
- await message.reply_text(
- f"{from_user.mention} 的管理员头衔已修改为“{title}”。"
- )
- @app.on_message(filters.command("set_chat_photo") & ~filters.private)
- @adminsOnly("can_change_info")
- async def set_chat_photo(_, message):
- reply = message.reply_to_message
- if not reply:
- return await message.reply_text(
- "请回复要设为群头像的图片。"
- )
- file = reply.document or reply.photo
- if not file:
- return await message.reply_text(
- "请回复图片或图片文件。"
- )
- if file.file_size > 5000000:
- return await message.reply("文件不能超过 5 MB。")
- photo = await reply.download()
- await message.chat.set_photo(photo)
- await message.reply_text("群头像已更新。")
- os.remove(photo)
|