Add some fix and new bugs

This commit is contained in:
Yasir Aris M 2024-01-13 22:32:24 +07:00 committed by GitHub
parent 02d8946804
commit 18a21ef093
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 27 additions and 21 deletions

View file

@ -19,10 +19,10 @@ from ...helper.localization import (
)
async def member_permissions(chat_id: int, user_id: int, client):
async def member_permissions(chat_id: int, user_id: int):
perms = []
try:
member = (await client.get_chat_member(chat_id, user_id)).privileges
member = (await app.get_chat_member(chat_id, user_id)).privileges
if member.can_post_messages:
perms.append("can_post_messages")
if member.can_edit_messages:
@ -164,7 +164,7 @@ def adminsOnly(permission):
return await unauthorised(message, permission, subFunc2)
# For admins and sudo users
userID = message.from_user.id
permissions = await member_permissions(chatID, userID, client)
permissions = await member_permissions(chatID, userID)
if userID not in SUDO and permission not in permissions:
return await unauthorised(message, permission, subFunc2)
return await authorised(func, subFunc2, client, message, *args, **kwargs)

View file

@ -634,10 +634,10 @@ async def warn_user(client, message, strings):
@app.on_callback_query(filters.regex("unwarn_"))
@use_chat_lang()
async def remove_warning(client, cq, strings):
async def remove_warning(_, cq, strings):
from_user = cq.from_user
chat_id = cq.message.chat.id
permissions = await member_permissions(chat_id, from_user.id, client)
permissions = await member_permissions(chat_id, from_user.id)
permission = "can_restrict_members"
if permission not in permissions:
return await cq.answer(
@ -664,10 +664,10 @@ async def remove_warning(client, cq, strings):
@app.on_callback_query(filters.regex("unmute_"))
@use_chat_lang()
async def unmute_user(client, cq, strings):
async def unmute_user(_, cq, strings):
from_user = cq.from_user
chat_id = cq.message.chat.id
permissions = await member_permissions(chat_id, from_user.id, client)
permissions = await member_permissions(chat_id, from_user.id)
permission = "can_restrict_members"
if permission not in permissions:
return await cq.answer(
@ -687,10 +687,10 @@ async def unmute_user(client, cq, strings):
@app.on_callback_query(filters.regex("unban_"))
@use_chat_lang()
async def unban_user(client, cq, strings):
async def unban_user(_, cq, strings):
from_user = cq.from_user
chat_id = cq.message.chat.id
permissions = await member_permissions(chat_id, from_user.id, client)
permissions = await member_permissions(chat_id, from_user.id)
permission = "can_restrict_members"
if permission not in permissions:
return await cq.answer(

View file

@ -29,7 +29,7 @@ from psutil import net_io_counters, virtual_memory
from pyrogram import Client
from pyrogram import __version__ as pyrover
from pyrogram import enums, filters
from pyrogram.errors import ChatSendPhotosForbidden, FloodWait, MessageTooLong, PeerIdInvalid, ChatSendPlainForbidden
from pyrogram.errors import ChatSendPhotosForbidden, FloodWait, MessageTooLong, PeerIdInvalid, ChatSendPlainForbidden, ReactionInvalid
from pyrogram.raw.types import UpdateBotStopped
from pyrogram.types import (
InlineKeyboardButton,
@ -126,6 +126,10 @@ async def log_file(_, ctx: Message, strings):
@app.on_message(filters.command(["donate"], COMMAND_HANDLER))
async def donate(self: Client, ctx: Message):
try:
await ctx.react(emoji="❤️")
except ReactionInvalid:
pass
try:
await ctx.reply_photo(
"https://img.yasirweb.eu.org/file/9427d61d6968b8ee4fb2f.jpg",

View file

@ -35,7 +35,7 @@ from pyrogram.enums import ChatMemberStatus, ChatType, ParseMode
from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup
from misskaty.helper.functions import extract_user, extract_user_and_reason
from pyrogram.errors import FloodWait
from pyrogram.errors import FloodWait, PeerIdInvalid
from misskaty.core.decorator.errors import capture_err
__MODULE__ = "Federation"
@ -55,11 +55,11 @@ async def new_fed(self, message):
chat = message.chat
user = message.from_user
if message.chat.type != ChatType.PRIVATE:
return await message.reply_text(
return await message.reply_msg(
"Federations can only be created by privately messaging me."
)
if len(message.command) < 2:
return await message.reply_text("Please write the name of the federation!")
return await message.reply_msg("Please write the name of the federation!")
fednam = message.text.split(None, 1)[1]
if not fednam == "":
fed_id = str(uuid.uuid4())
@ -80,11 +80,11 @@ async def new_fed(self, message):
upsert=True,
)
if not x:
return await message.reply_text(
return await message.reply_msg(
f"Can't federate! Please contact {SUPPORT_CHAT} if the problem persist."
)
await message.reply_text(
await message.reply_msg(
"**You have succeeded in creating a new federation!**"
"\nName: `{}`"
"\nID: `{}`"
@ -597,8 +597,7 @@ async def fban_user(client, message):
chat = message.chat
from_user = message.from_user
if message.chat.type == ChatType.PRIVATE:
await message.reply_text("This command is specific to groups, not our pm!.")
return
return await message.reply_text("This command is specific to groups, not our pm!.")
fed_id = await get_fed_id(chat.id)
if not fed_id:
return await message.reply_text("**This chat is not a part of any federation.")
@ -617,7 +616,10 @@ async def fban_user(client, message):
"**You needed to specify a user or reply to their message!**"
)
user_id, reason = await extract_user_and_reason(message)
user = await app.get_users(user_id)
try:
user = await app.get_users(user_id)
except PeerIdInvalid:
return await message.reply_msg("Sorry, i never meet this user. So i cannot fban.")
if not user_id:
return await message.reply_text("I can't find that user.")
if user_id in all_admins or user_id in SUDO:
@ -871,7 +873,7 @@ async def fbroadcast_message(client, message):
sent += 1
await asyncio.sleep(sleep_time)
except FloodWait as e:
await asyncio.sleep(int(e.value))
await asyncio.sleep(e.value)
except Exception:
pass
await m.edit(f"**Broadcasted Message In {sent} Chats.**")

View file

@ -47,8 +47,8 @@ async def genss(self: Client, ctx: Message, strings):
url = the_url_parts.strip()
file_name = os.path.basename(url)
download_file_path = os.path.join("downloads/", file_name)
downloader = SmartDL(url, download_file_path, progress_bar=False, timeout=10, verify=False)
try:
downloader = SmartDL(url, download_file_path, progress_bar=False, timeout=10, verify=False)
downloader.start(blocking=False)
except Exception as err:
return await pesan.edit(str(err))

View file

@ -168,7 +168,7 @@ async def kang_sticker(self: Client, ctx: Message, strings):
elif not reply.sticker.file_name.endswith(".tgs"):
resize = True
else:
return await prog_msg.edit_msg()
return await prog_msg.edit_msg("I cannot kang this type.")
pack_prefix = "anim" if animated else "vid" if videos else "a"
packname = f"{pack_prefix}_{ctx.from_user.id}_by_{self.me.username}"