Skip to content

Commit

Permalink
Group fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ruecat committed Jan 30, 2024
1 parent f82da25 commit de19e0b
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions bot/func/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ async def generate(payload: dict, modelname: str, prompt: str):
def perms_allowed(func):
@wraps(func)
async def wrapper(message: types.Message = None, query: types.CallbackQuery = None):
if message and message.chat.type in ["supergroup", "group"]:
pass # Ignore messages from supergroups
user_id = message.from_user.id if message else query.from_user.id
if user_id in admin_ids or user_id in allowed_ids:
if message:
Expand All @@ -69,8 +67,12 @@ async def wrapper(message: types.Message = None, query: types.CallbackQuery = No
return await func(query=query)
else:
if message:
if message and message.chat.type in ["supergroup", "group"]:
return
await message.answer("Access Denied")
elif query:
if message and message.chat.type in ["supergroup", "group"]:
return
await query.answer("Access Denied")

return wrapper
Expand All @@ -80,7 +82,7 @@ def perms_admins(func):
@wraps(func)
async def wrapper(message: types.Message = None, query: types.CallbackQuery = None):
if message and message.chat.type in ["supergroup", "group"]:
pass # Ignore messages from supergroups
pass
user_id = message.from_user.id if message else query.from_user.id
if user_id in admin_ids:
if message:
Expand All @@ -89,11 +91,15 @@ async def wrapper(message: types.Message = None, query: types.CallbackQuery = No
return await func(query=query)
else:
if message:
if message and message.chat.type in ["supergroup", "group"]:
return
await message.answer("Access Denied")
logging.info(
f"[MSG] {message.from_user.first_name} {message.from_user.last_name}({message.from_user.id}) is not allowed to use this bot."
)
elif query:
if message and message.chat.type in ["supergroup", "group"]:
return
await query.answer("Access Denied")
logging.info(
f"[QUERY] {message.from_user.first_name} {message.from_user.last_name}({message.from_user.id}) is not allowed to use this bot."
Expand Down

0 comments on commit de19e0b

Please sign in to comment.