From 25b6fa65d0d695617d5d0996998521303707ed9c Mon Sep 17 00:00:00 2001 From: Michael De Roover Date: Mon, 22 Mar 2021 10:53:11 +0100 Subject: [PATCH] Match commands more strictly --- ubot.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/ubot.py b/ubot.py index ca51ec6..b879994 100644 --- a/ubot.py +++ b/ubot.py @@ -12,7 +12,7 @@ client = TelegramClient('ubot', api_id, api_hash) async def edit(event): msg = event.raw_text - if '.alive' in msg: + if msg.startswith('.alive'): rpl = "Userbot alive and well!" await event.edit(rpl) @@ -21,7 +21,7 @@ async def edit(event): msg = event.text.replace('.shg', rpl) await event.edit(msg) - if '.stats' in msg: + if msg.startswith('.stats'): pms = bots = 0 groups = gadmin = gcreator = 0 chans = cadmin = ccreator = 0 @@ -71,11 +71,11 @@ async def edit(event): rpl += f'**Unread:** {unread} ({mentions} mentions)\n' await event.edit(rpl) - if '.fire' in msg: + if msg.startswith('.fire'): rpl = 'IMA FIRING MAH LAZER' await event.edit(rpl) - if '.purgeme' in msg: + if msg.startswith('.purgeme'): count = int(msg.split()[1]) i = 1 async for msgs in client.iter_messages(event.chat_id, from_user='me'): @@ -87,7 +87,7 @@ async def edit(event): rpl = "Purge complete! Purged " + str(count) + " messages." await client.send_message('me', rpl) - if '.sh' in msg: + if msg.startswith('.sh'): if event.is_channel and not event.is_group: await event.edit('Sorry, this is not allowed!') return @@ -101,7 +101,7 @@ async def edit(event): rpl += f'`{out}`\n' await event.edit(rpl) - if '.sys' in msg: + if msg.startswith('.sys'): mem = os.popen('free -m').readlines()[1].split()[2] disk = os.popen('df -h /').readlines()[1].split()[2] @@ -110,11 +110,11 @@ async def edit(event): rpl += f'**Disk:** {disk}\n' await event.edit(rpl) - if '.sauce' in msg: + if msg.startswith('.sauce'): rpl = 'Sauce: [ghnou/ubot](https://git.ghnou.su/ghnou/ubot)' await event.edit(rpl) - if '.help' in msg: + if msg.startswith('.help'): rpl = '**Available userbot commands:**\n' rpl += '.alive - Check whether the bot is running.\n' rpl += '.shg - ¯\_(ツ)_/¯\n'