Skip to content

Commit

Permalink
fix: anonymous admin
Browse files Browse the repository at this point in the history
  • Loading branch information
AsmSafone committed Jan 19, 2022
1 parent f66c911 commit f5e1a6c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 12 deletions.
23 changes: 14 additions & 9 deletions core/admins.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,26 @@


async def is_sudo(message):
if message.from_user and message.from_user.id in config.SUDOERS:
if (
message.from_user and message.from_user.id in config.SUDOERS
):
return True
else:
return False


async def is_admin(message):
if (
message.from_user.id
in [
admin.user.id
for admin in (await message.chat.get_members(filter="administrators"))
]
or message.from_user.id in config.SUDOERS
):
if message.from_user and (
message.from_user.id
in [
admin.user.id
for admin in (await message.chat.get_members(filter="administrators"))
]
):
return True
elif message.from_user and message.from_user.id in config.SUDOERS:
return True
elif message.sender_chat and message.sender_chat.id == message.chat.id:
return True
else:
return False
7 changes: 5 additions & 2 deletions core/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,18 @@ async def decorator(client, obj: Union[Message, int, Update], *args):

def only_admins(func: Callable) -> Callable:
async def decorator(client: Client, message: Message, *args):
if (
if message.from_user and (
message.from_user.id
in [
admin.user.id
for admin in (await message.chat.get_members(filter="administrators"))
]
or message.from_user.id in config.SUDOERS
):
return await func(client, message, *args)
elif message.from_user and message.from_user.id in config.SUDOERS:
return await func(client, message, *args)
elif message.sender_chat and message.sender_chat.id == message.chat.id:
return await func(client, message, *args)

return decorator

Expand Down
2 changes: 1 addition & 1 deletion core/queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def __str__(self):
string = ""
for x, item in enumerate(queue):
if x < 10:
string += f"**{x+1}. [{item.title}]({item.source})** \n- Requested By: {item.requested_by.mention}\n"
string += f"**{x+1}. [{item.title}]({item.source})** \n- Requested By: {item.requested_by.mention if item.requested_by else item.request_msg.sender_chat.title}\n"
else:
string += f"`\n...{len(queue)-10}`"
return string
Expand Down

0 comments on commit f5e1a6c

Please sign in to comment.