Delete commands /media and /stickers

This commit is contained in:
hok7z 2022-11-26 18:36:31 +02:00
parent f91b1836a8
commit a1c9c5db7f
2 changed files with 4 additions and 67 deletions

1
app.py
View File

@ -1,7 +1,6 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import logging import logging
from aiogram import executor from aiogram import executor
# from database import build
from database import db, Member, Restriction from database import db, Member, Restriction
from load import dp, bot from load import dp, bot

View File

@ -231,7 +231,7 @@ async def pin_message(message:types.Message):
async def readonly_mode(message:types.Message): async def readonly_mode(message:types.Message):
check = checkArg(message.text) check = checkArg(message.text)
if (not check): if (check is None):
await message.answer("Usage:!ro on,enable,start/off,disable,off\n") await message.answer("Usage:!ro on,enable,start/off,disable,off\n")
return return
@ -240,10 +240,12 @@ async def readonly_mode(message:types.Message):
# Set permissions # Set permissions
if (check): if (check):
await message.answer("🚨 Emergency situation!")
chat_permissions = ChatPermissions( chat_permissions = ChatPermissions(
can_send_messages=not check can_send_messages=not check
) )
else: else:
await message.answer("✅ The situation under control")
chat_permissions = ChatPermissions( chat_permissions = ChatPermissions(
can_send_messages=group_permissions['can_send_messages'], can_send_messages=group_permissions['can_send_messages'],
can_send_media_messages=group_permissions["can_send_media_messages"], can_send_media_messages=group_permissions["can_send_media_messages"],
@ -255,71 +257,7 @@ async def readonly_mode(message:types.Message):
can_pin_messages=group_permissions['can_pin_messages'] can_pin_messages=group_permissions['can_pin_messages']
) )
status = await bot.set_chat_permissions(chat_id=message.chat.id, permissions=chat_permissions) await bot.set_chat_permissions(chat_id=message.chat.id, permissions=chat_permissions)
if (status):
await message.answer(f"readonly - {check}")
@dp.message_handler(commands=["media"],commands_prefix="!",available_roles=[MemberRoles.ADMIN,MemberRoles.HELPER])
async def media_content(message: types.Message):
check = checkArg(message.text)
if (not check):
await message.answer("Usage: !media on,enable,start/off,disable,off")
return
# Get chat permissions
group_permissions = config.group_permissions
# Set permissions
chat_permissions = ChatPermissions(
can_send_messages=group_permissions['can_send_messages'],
can_send_media_messages=check,
can_send_other_messages=group_permissions['can_send_other_messages'],
can_send_polls=group_permissions['can_send_polls'],
can_invite_users=group_permissions['can_invite_users'],
can_change_info=group_permissions['can_change_info'],
can_add_web_page_previews=group_permissions['can_add_web_page_previews'],
can_pin_messages=group_permissions['can_pin_messages']
)
# Set chat pemissions and save results
status = await bot.set_chat_permissions(chat_id=message.chat.id, permissions=chat_permissions)
if status:
await message.answer(f"media - {check}")
@dp.message_handler(commands=["stickers"],commands_prefix="!",available_roles=[MemberRoles.ADMIN,MemberRoles.HELPER])
async def send_stickers(message: types.Message):
# Get arguments
check = checkArg(message.text)
if (not check):
await message.answer("Usage: !stickers on,enable,start/off,disable,off")
return
# Get chat permissions
group_permissions = config.group_permissions
# Set permissions.
chat_permissions = ChatPermissions(
can_send_messages=group_permissions['can_send_messages'],
can_send_media_messages=group_permissions['can_send_media_messages'],
can_send_other_messages=check,
can_send_polls=group_permissions['can_send_polls'],
can_invite_users=group_permissions['can_invite_users'],
can_change_info=group_permissions['can_change_info'],
can_add_web_page_previews=group_permissions['can_add_web_page_previews'],
can_pin_messages=group_permissions['can_pin_messages']
)
# Start and save to satus (bool)
status = await bot.set_chat_permissions(chat_id=message.chat.id, permissions=chat_permissions)
if status:
await message.answer(f"stickes - {check}")
@dp.message_handler(commands=["warn","w"],commands_prefix="!",available_roles=[MemberRoles.HELPER,MemberRoles.ADMIN]) @dp.message_handler(commands=["warn","w"],commands_prefix="!",available_roles=[MemberRoles.HELPER,MemberRoles.ADMIN])