| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- """
- MIT License
- Copyright (c) 2021 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__ = "Admin Miscs"
- __HELP__ = """
- /set_chat_title - Change The Name Of A Group/Channel.
- /set_chat_photo - Change The PFP Of A Group/Channel.
- /set_user_title - Change The Administrator Title Of An Admin.
- """
- @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(
- "**Usage:**\n/set_chat_title NEW NAME"
- )
- 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"Successfully Changed Group Title From {old_title} To {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(
- "Reply to user's message to set his admin title"
- )
- if not message.reply_to_message.from_user:
- return await message.reply_text(
- "I can't change admin title of an unknown entity"
- )
- chat_id = message.chat.id
- from_user = message.reply_to_message.from_user
- if len(message.command) < 2:
- return await message.reply_text(
- "**Usage:**\n/set_user_title NEW ADMINISTRATOR TITLE"
- )
- title = message.text.split(None, 1)[1]
- await app.set_administrator_title(chat_id, from_user.id, title)
- await message.reply_text(
- f"Successfully Changed {from_user.mention}'s Admin Title To {title}"
- )
- @app.on_message(filters.command("set_chat_photo") & ~filters.private)
- @adminsOnly("can_change_info")
- async def set_chat_photo(_, message):
- if not message.reply_to_message:
- return await message.reply_text(
- "Reply to a photo to set it as chat_photo"
- )
- if (
- not message.reply_to_message.photo
- and not message.reply_to_message.document
- ):
- return await message.reply_text(
- "Reply to a photo to set it as chat_photo"
- )
- photo = await message.reply_to_message.download()
- await message.chat.set_photo(photo)
- await message.reply_text("Successfully Changed Group Photo")
- os.remove(photo)
|