Update sementara

This commit is contained in:
yasirarism 2023-08-06 22:41:05 +07:00 committed by GitHub
parent 924853f45b
commit f251daeb74
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 31 additions and 21 deletions

View file

@ -88,6 +88,7 @@ async def reply_text(
await asleep(del_in) await asleep(del_in)
return bool(await msg.delete_msg()) return bool(await msg.delete_msg())
except FloodWait as e: except FloodWait as e:
LOGGER.warning(f"Got floodwait in {self.chat.id} for {e.value}'s.")
await asleep(e.value) await asleep(e.value)
return await reply_text(self, text, *args, **kwargs) return await reply_text(self, text, *args, **kwargs)
except TopicClosed: except TopicClosed:
@ -134,7 +135,7 @@ async def edit_text(
await asleep(del_in) await asleep(del_in)
return bool(await msg.delete_msg()) return bool(await msg.delete_msg())
except FloodWait as e: except FloodWait as e:
LOGGER.warning(str(e)) LOGGER.warning(f"Got floodwait in {self.chat.id} for {e.value}'s.")
await asleep(e.value) await asleep(e.value)
return await edit_text(self, text, *args, **kwargs) return await edit_text(self, text, *args, **kwargs)
except MessageNotModified: except MessageNotModified:

View file

@ -28,7 +28,7 @@ from logging import getLogger
from time import time from time import time
from pyrogram import Client, enums, filters from pyrogram import Client, enums, filters
from pyrogram.errors import ChatAdminRequired, FloodWait, PeerIdInvalid from pyrogram.errors import ChatAdminRequired, FloodWait, PeerIdInvalid, UsernameNotOccupied
from pyrogram.types import ChatPermissions, ChatPrivileges, Message from pyrogram.types import ChatPermissions, ChatPrivileges, Message
from database.warn_db import add_warn, get_warn, remove_warns from database.warn_db import add_warn, get_warn, remove_warns
@ -573,7 +573,10 @@ async def unmute(_, message, strings):
@ratelimiter @ratelimiter
@use_chat_lang() @use_chat_lang()
async def warn_user(client, message, strings): async def warn_user(client, message, strings):
user_id, reason = await extract_user_and_reason(message) try:
user_id, reason = await extract_user_and_reason(message)
except UsernameNotOccupied:
return await message.reply_msg("Sorry, i didn't know that user.")
chat_id = message.chat.id chat_id = message.chat.id
if not user_id: if not user_id:
return await message.reply_text(strings("user_not_found")) return await message.reply_text(strings("user_not_found"))

View file

@ -24,7 +24,7 @@ SOFTWARE.
import asyncio import asyncio
from pyrogram import filters from pyrogram import filters
from pyrogram.errors import ChatNotModified, FloodWait from pyrogram.errors import ChatNotModified, FloodWait, ChatAdminRequired
from pyrogram.types import ChatPermissions from pyrogram.types import ChatPermissions
from misskaty import app from misskaty import app
@ -120,7 +120,7 @@ async def tg_lock(message, permissions: list, perm: str, lock: bool):
@adminsOnly("can_restrict_members") @adminsOnly("can_restrict_members")
async def locks_func(_, message): async def locks_func(_, message):
if len(message.command) != 2: if len(message.command) != 2:
return await message.reply_text(incorrect_parameters) return await message.reply_msg(incorrect_parameters)
chat_id = message.chat.id chat_id = message.chat.id
parameter = message.text.strip().split(None, 1)[1].lower() parameter = message.text.strip().split(None, 1)[1].lower()
@ -134,24 +134,30 @@ async def locks_func(_, message):
if parameter in data: if parameter in data:
await tg_lock(message, permissions, data[parameter], state == "lock") await tg_lock(message, permissions, data[parameter], state == "lock")
elif parameter == "all" and state == "lock": elif parameter == "all" and state == "lock":
await app.set_chat_permissions(chat_id, ChatPermissions()) try:
await message.reply_text(f"Locked Everything in {message.chat.title}") await app.set_chat_permissions(chat_id, ChatPermissions())
await message.reply_text(f"Locked Everything in {message.chat.title}")
except ChatAdminRequired:
await message.reply_msg("Give me proper admin permission to use this command.")
elif parameter == "all" and state == "unlock": elif parameter == "all" and state == "unlock":
await app.set_chat_permissions( try:
chat_id, await app.set_chat_permissions(
ChatPermissions( chat_id,
can_send_messages=True, ChatPermissions(
can_send_media_messages=True, can_send_messages=True,
can_send_other_messages=True, can_send_media_messages=True,
can_add_web_page_previews=True, can_send_other_messages=True,
can_send_polls=True, can_add_web_page_previews=True,
can_change_info=False, can_send_polls=True,
can_invite_users=True, can_change_info=False,
can_pin_messages=False, can_invite_users=True,
), can_pin_messages=False,
) ),
await message.reply(f"Unlocked Everything in {message.chat.title}") )
await message.reply(f"Unlocked Everything in {message.chat.title}")
except ChatAdminRequired:
await message.reply_msg("Give me full admin permission to use this command.")
@app.on_message(filters.command("locks", COMMAND_HANDLER) & ~filters.private) @app.on_message(filters.command("locks", COMMAND_HANDLER) & ~filters.private)