Match commands more strictly

This commit is contained in:
Michael De Roover 2021-03-22 10:53:11 +01:00
parent d16ad8e70f
commit 25b6fa65d0
Signed by: vim
GPG Key ID: 075496E232CE04CB

16
ubot.py
View File

@ -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'