From 287c8bd9070e51357074a61b348e980a6c00f0d4 Mon Sep 17 00:00:00 2001 From: rking32 Date: Sat, 5 Feb 2022 00:38:23 +0530 Subject: [PATCH] optimize it for sudo users --- userge/core/types/raw/command.py | 8 ++++++-- userge/plugins/utils/notes.py | 2 +- userge/plugins/utils/voice_call.py | 10 +++++----- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/userge/core/types/raw/command.py b/userge/core/types/raw/command.py index ed12f5e67..5a9f91605 100644 --- a/userge/core/types/raw/command.py +++ b/userge/core/types/raw/command.py @@ -118,8 +118,12 @@ def _public_logic(m: Message, trigger: str, _) -> bool: return ( not m.edit_date and ( - True if not trigger else m.text.startswith(Config.CMD_TRIGGER) - if m.from_user and m.from_user.id in Config.OWNER_ID else m.text.startswith(trigger) + True if not trigger + else m.text.startswith(Config.CMD_TRIGGER) + if m.from_user and m.from_user.id in Config.OWNER_ID + else m.text.startswith(Config.SUDO_TRIGGER) + if Config.SUDO_ENABLED and m.from_user and m.from_user.id in Config.SUDO_USERS + else m.text.startswith(trigger) ) ) diff --git a/userge/plugins/utils/notes.py b/userge/plugins/utils/notes.py index c874bd461..f0b4bae12 100644 --- a/userge/plugins/utils/notes.py +++ b/userge/plugins/utils/notes.py @@ -160,7 +160,7 @@ async def mv_to_global_note(message: Message) -> None: 'usage': "#[notename]\nget notename"}, group=-1, name="get_note", - trigger='', + trigger=None, filter_me=False, check_client=True) async def get_note(message: Message) -> None: diff --git a/userge/plugins/utils/voice_call.py b/userge/plugins/utils/voice_call.py index 393dae741..19656229d 100644 --- a/userge/plugins/utils/voice_call.py +++ b/userge/plugins/utils/voice_call.py @@ -528,7 +528,7 @@ async def force_play_music(msg: Message): @userge.on_cmd("current", about={ 'header': "View Current playing Song.", 'usage': "{tr}current"}, - trigger=Config.SUDO_TRIGGER, check_client=True, + trigger=Config.PUBLIC_TRIGGER, check_client=True, filter_me=False, allow_bots=False) @vc_chat @check_enable_for_all @@ -549,7 +549,7 @@ async def current(msg: Message): @userge.on_cmd("queue", about={ 'header': "View Queue of Songs", 'usage': "{tr}queue"}, - trigger=Config.SUDO_TRIGGER, check_client=True, + trigger=Config.PUBLIC_TRIGGER, check_client=True, filter_me=False, allow_bots=False) @vc_chat @check_enable_for_all @@ -608,7 +608,7 @@ async def set_volume(msg: Message): @userge.on_cmd("skip", about={ 'header': "Skip Song", 'usage': "{tr}skip"}, - trigger=Config.SUDO_TRIGGER, check_client=True, + trigger=Config.PUBLIC_TRIGGER, check_client=True, filter_me=False, allow_bots=False) @vc_chat async def skip_music(msg: Message): @@ -622,7 +622,7 @@ async def skip_music(msg: Message): @userge.on_cmd("pause", about={ 'header': "Pause Song.", 'usage': "{tr}pause"}, - trigger=Config.SUDO_TRIGGER, check_client=True, + trigger=Config.PUBLIC_TRIGGER, check_client=True, filter_me=False, allow_bots=False) @vc_chat async def pause_music(msg: Message): @@ -636,7 +636,7 @@ async def pause_music(msg: Message): @userge.on_cmd("resume", about={ 'header': "Resume Song.", 'usage': "{tr}resume"}, - trigger=Config.SUDO_TRIGGER, check_client=True, + trigger=Config.PUBLIC_TRIGGER, check_client=True, filter_me=False, allow_bots=False) @vc_chat async def resume_music(msg: Message):